Repository navigation
M7 migrated read surfaces checkpoint - #127
aliceisjustplaying wants to merge 58 commits into
Conversation
Add docs/agents/ pointing skills (to-issues, triage, to-prd, qa, improve-codebase-architecture, diagnose, tdd, grill-with-docs) at: - Linear (team Aliceisjustplaying, project Bluepy) via the official Linear MCP server for issue tracking - Linear workflow states (Triage / Backlog / Todo / Canceled) for the five triage roles, with a label fallback noted for needs-info - Single-context CONTEXT.md + docs/adr/ layout Mirror the new Agent skills index section into both runbooks.
The pre-write hook was blocking Edit/Write tool calls whenever the session cwd (passed through as .cwd in the hook payload) resolved to the bluesky checkout, even when file_path targeted a worktree on a different branch. That made the documented "worktree off bluesky" workflow unusable from a Claude session launched in the main checkout. Move the workdir branch check into the fallback arm, after file_path and patch-path resolution. workdir is still consulted when no concrete file target is available (preserving the apply_patch relative-path case), and a direct write into the bluesky checkout is still blocked.
…plans 0001-0002) Output of a /grill-with-docs session pinning the architectural decisions for ripping out the Mastodon-API-shaped adapter (src/utils/atproto-adapter.ts and its v1/v2 surface) and rebuilding Bluepy's data layer ATProto-native. Phase (b) is big-bang via an AFK coding agent; this design is the spec. - CONTEXT.md: glossary — At-URI, Permalink, PDS, AppView, Active AppView, Bluesky AppView, plus a dialogue showing how they relate. - ADRs 0001-0011: foundational decisions — at-URI URL form, @atproto/api over atcute (library swap deferred), domain verbs + hooks + lexicon types, three-client dispatch (pds/active-appview/bsky-appview), mutations with selective optimistic, Zustand for UI state, hook-level loading (no Suspense), flat pagination shape, cache-key factory + account scoping, session lifecycle (OAuth lib owns OAuth, Zustand owns UI), render pipeline (facet rendering + sanitizer outside data layer). - ADRs 0012-0015: compose-specific — intent-keyed multi-draft, upload-on-submit (because ATProto has no deleteBlob), all-or-nothing submit pipeline with warn-on-aux-fail for threadgate/postgate, author picker for multi-account users. - docs/plan/0001-data-layer-rebuild.md: Phase (b) spec — file structure, per-module signatures, provider tree, consumer migration patterns, acceptance criteria (incl. zero new `as any` in touched code). - docs/plan/0002-compose-flow.md: compose subsystem spec — state model, facet detection, mentions autocomplete, link card via cardyb, submit pipeline, video upload via service auth, acceptance criteria.
…try, shell ADRs added: - 0016 per-URI canonical TanStack cache; list queries return references - 0017 preferences split (server putPreferences + device-local Zustand) - 0018 shortcut bar hybrid (savedFeedsPrefV2 pinned + local Phanpy types) - 0019 rebuild test bar (fresh e2e + fixture-driven unit core, anti-tautology) - 0020 telemetry via self-hosted Plausible; error tracking via Sentry - 0021 client shell: eager first paint, no progressive hydration, PWA + web push, read-only offline via persistQueryClient Updates: - 0005 mutation patches target keys.post/keys.profile canonical entries only - 0009 canonical vs list key distinction (full bodies vs URI references) - plan 0001 addenda folds in the new ADRs, full Valtio state inventory dispositions, and revised acceptance criteria
…018, new 0022, plans 0001/0002)
- ADR-0004: 4-category dispatch (public-active-appview / authenticated-active-appview-via-pds / public-bluesky-appview / pds-direct). Default for logged-in users is the PDS-proxied path, not unauth AppView.
- ADR-0009: viewer-scope key prefix (viewerDid, appviewDid, labelersHash) on every key.
- ADR-0016: viewer-scope canonical keys, embed-variant primer spec (viewRecord/viewNotFound/viewBlocked/viewDetached/non-post-record/unknown), direct-route hooks refetch on mount with finite staleTime.
- ADR-0017: hard rule — putPreferences must preserve unknown $type entries byte-for-byte; covered by unit test in done-bar.
- ADR-0018: reconcileShortcutBar is a pure function returning {items, nextOrder, changed}; writeback happens in useEffect, never useMemo.
- ADR-0022: new moderation/labels subsystem (src/data/moderation.ts + src/render/moderation-decision.ts), mandatory in phase (b).
- Plan 0001: Phase 0 scaffolding section (TanStack/Zustand install, Playwright config fix for .spec.ts + retries=0, provider tree wiring) before per-module specs. Round-3 must-fix delta block in addenda.
- Plan 0002: video upload audience fixed against ~/src/a/social-app — two separate service-auth tokens (getUploadLimits uses video service DID, uploadBlob uses author PDS hostname).
…mpose polish
- Plan 0001: M1–M11 milestone table with per-milestone done-bars + commit naming convention (`phase-b/M{N}-<name>`). M2 unit gate hard-blocks M3. One live e2e tier, no mocked tier. Acceptance criteria gain offline-persistence (criterion 9) and milestone-commit-trail (criterion 10).
- Plan 0002: DraftKey canonical serializer spec (`draftKeyToString` / `parseDraftKey`, v1: prefix, fixed field order, unit-tested round-trip); attachment fork ref-counting spec (shared File, separate IDs, refcounted objectURLs); Cardyb privacy leak documented + follow-up pref deferred.
…tems - AGENTS.md + CLAUDE.md: reference clone path is `~/social-app` on Linux/VPS, `~/src/a/social-app` on macOS dev; runbook tells the agent to try the alternate if the documented path is missing. - Plan 0001: cleared the stale "Things to confirm before the agent runs" and round-2 "Remaining open items" blocks. Only two items left intentionally open — `bskyAppviewAgent` exceptions (empirical by ADR-0004) and `workers/push/` (plan 0004 out of scope).
… review bundles Narrower companion to scripts/concat-source-for-llm.sh: emits CONTEXT.md + docs/adr/*.md only (no plans, no source, no tests). Defaults to ~/tmp/bluepy-context-and-adrs.txt. Used when handing the architecture layer (and only the architecture layer) to an external reviewer.
Folds the second-round external review into the spec before AFK handoff:
- ADR-0009: split AccountScope ([viewerDid]) for preferences from
ViewerScope ([viewerDid, appviewKey, labelersHash]) for AppView views.
appviewKey = `${did}|${origin}` so preview/dev deploys partition
cleanly. profileByDid + actorResolution split prevents stale-handle
duplication.
- ADR-0004: 5-mode dispatch — public-active-appview /
authenticated-active-appview-via-pds / public-bluesky-appview /
authenticated-bluesky-appview-via-pds / pds-repo-direct. Preconfigured
per-mode agents with fixed proxy + accepted-labeler headers; shared-
agent header mutation in queryFn/mutationFn forbidden.
- ADR-0017: preferences keyed by AccountScope (circularity fix —
labelersHash is derived from labelersPref).
- ADR-0022: baseline labelers first-class in ModerationContext;
acceptedLabelerDids = baseline ∪ subscribed; adult-content semantics
per official ATProto rules.
- ADR-0020: trackPage takes RouteCategory enum, never raw pathname (at-
URIs leak DIDs). Sentry beforeSend covers request.url, transaction
names, breadcrumbs, tags, exception messages, stacktrace frames.
- ADR-0011: mention/profile links use full at://<did>/app.bsky.actor.
profile/self, never bare at://<did>.
- ADR-0012 + ADR-0015: DraftKey includes authorDid; author-switch
forks (no overwrite).
- ADR-0019: expanded unit-test list (preferences-preserve-unknown,
moderation-decision, route-category, sentry-scrub, compose/draft-key).
- ADR-0005 + ADR-0016: cross-scope same-viewer optimistic patching
prevents stale engagement across cached AppView/labeler scopes.
- ADR-0021: push behind featureFlags.push (no-op shell) in phase (b);
Worker side is plan 0004. No-tokens-in-payload rules restated.
- plan/0001: round-4 deltas appended; remaining-open-items refreshed.
- plan/0002: cache-invalidation block updated to author-scoped
ViewerScope.
Drafted via /grill-with-docs design tree:
- Trigger: manual paste into Cursor Composer 2.5
- Implementer: Composer 2.5; reviewer: gpt-5.5 model_reasoning_effort=high
via codex exec, recursive loop driven by Composer
- Checkpoints: M5 (post-foundation) and M11 (post-cleanup); hard cap
5 review rounds per checkpoint
- Stop conditions: document + proceed by default; halt with
STUCK-*.md only on hard blockers
- Branch: stay on `rewrite`, one mega-branch, draft PR at M11
- Per-milestone NOTES-M{N}.md for non-blocking judgement calls
- Explicit conflict order: ADRs > plans > runbooks > existing code
- Explicit scope allow-list to prevent unrelated drive-bys
- Codex review diff form is bluesky...HEAD (not HEAD) since milestones
commit before review
CLAUDE.md and AGENTS.md only listed the original 5 vars; source.env has grown to 13 (added second test account, prod/main account creds, Sentry DSN, Plausible host+domain, OAuth client metadata URL). The AFK rebuild prompt's pre-flight invariant points at this list, so drift would let the agent pass pre-flight even with empty critical vars. Variable names extracted by reading source.env directly (no values exposed; secret-name hook respected).
Pre-flight for the AFK rebuild (ADR-0019). 12 structural fixtures totalling 1.2 MB, each captured from the main account via @atproto/api and deterministically sanitized: - DIDs (did:plc:*, did:web:*) -> did:plc:fixtureNNN (stable per-run mapping) - handles -> fixture-N.test - displayName -> "Fixture User N" - description/bio -> "Fixture description/bio" - post text -> "Fixture post content #idx" (facet structure preserved) - birthDate -> 1990-01-01 - mutedWordsPref items -> ["fixture-muted-N"] - hiddenPostsPref items -> remapped URIs - emails -> fixture-N@example.test - external embeds (uri/title/description) -> example.test placeholders - thumb URLs walked (DIDs inside cdn paths sanitized) - CIDs, rkeys, blob refs -> intact (opaque, not PII) - $type discriminators -> intact (lexicon contract) - AT URI collections (app.bsky.*, com.atproto.*, etc.) -> intact Endpoints captured: getTimeline, getProfile (basic + with-pinned), getPostThread (deep), getAuthorFeed, getActorLikes, searchPosts, getPreferences (full + with-unknown variant for the preserve-unknown test), listNotifications, getFollows, getFollowers. Verified 0 PII leaks via regex sweep (no real DIDs, no real .bsky.social handles, no real emails, no broken $types). Scripts are committed so future re-captures use the same sanitization contract. Raw output (/tmp/bluepy-fixtures-raw/) is deleted post-run. Not yet captured: moderation/ subdir per ADR-0019 (one fixture per cause). Defer to a follow-up; agent may halt at M6 with STUCK-M6-VERIFY.md if it needs moderation fixtures the spec requires.
…G.md)
Per ADR-0019, ADR-0022's moderation decision needs one fixture per cause.
Captured from the main account using getTimeline + getProfile + getPosts +
getBlocks + getMutes:
- label.json (PostView with .labels populated)
- muted-word.json (PostView whose record.text matches a mutedWordsPref entry)
- not-found.json (getPosts on a fake URI -> notFoundPost variant)
- blocking-profile.json (ProfileView with viewer.blocking; for decideProfileModeration)
- muted-profile.json (ProfileView with viewer.muted; for decideProfileModeration)
- hidden-post-reuse.json (label fixture reused; moderation test sets URI in
ModerationContext.hiddenPosts at test setup time)
MISSING (documented in moderation/MISSING.md, not blocking M6):
- blocked-by: no post with author.viewer.blockedBy in scanned data
- detached: no embed.$type ending in #viewDetached in scanned data
- hidden-post (true capture): hiddenPostsPref is empty on this account;
hidden-post-reuse.json substitutes the post shape
Capture script extended via scripts/capture-moderation-fixtures.ts (separate
from the structural capture for clarity). Sanitize script extended to walk
the moderation subdir too. Raw dir (/tmp/bluepy-fixtures-raw-mod/) deleted
post-run.
Note: structural and moderation fixtures use independent DID mappings (both
start fresh at fixture001) because they were sanitized in separate runs.
The agent's tests typically load one fixture at a time, so cross-fixture
identity isn't required. If a future test needs aligned mapping, re-capture
both in one sanitize pass.
- source.env's lines don't include `export`, so plain `source` only sets shell vars, not env-vars-for-subprocesses. The agent would fail the "vars non-empty" pre-flight invariant on `bun` calls. Use `set -a; source ...; set +a` everywhere. Discovered while running the fixture-capture scripts. - OAuth localhost note: vite.config.js generates the OAuth client metadata dynamically from the dev server origin, so `bun run dev` + Playwright Just Work without any deploy.
The previous regex matched the literal word "env" anywhere in a bash command followed by CLOUDFLARE/ATPROTO/PASSWORD/API_KEY anywhere later. That trips on prose like "env vars are non-empty: CLOUDFLARE_..." inside heredoc bodies, even though no secret is being printed. Narrow to: env|printenv followed by a real command shape (flag, VAR=val, pipe, end, or shell separator). Prose match no longer fires; real leak vectors (env | grep CLOUDFLARE, env -i, env FOO=bar) still do.
- Add @tanstack/react-query, zustand, and react-query-devtools - Create query-client factory (ADR-0007/0009 defaults) - Add ClientBundle stub and SessionProvider scaffold (ADR-0004, ADR-0010) - Mount QueryClientProvider + SessionProvider in main.tsx - Split Playwright projects: e2e/*.spec.ts (retries 0) + legacy atproto specs - Fix pre-existing capture-script type errors blocking typecheck gate Co-authored-by: Cursor <cursoragent@cursor.com>
- Add cache-key factory with AccountScope/ViewerScope (ADR-0009) - Implement primePosts/primeProfiles with embed viewRef reshaping (ADR-0016) - Add optimistic patchers for engagement mutations (ADR-0005) - Add pure reconcileShortcutBar (ADR-0018) - Add renderPostText with profile at-URI mentions (ADR-0011) - Add decidePost/ProfileModeration mapping @atproto/api moderation (ADR-0022) - Add fixture-driven unit suite under tests/unit/ (ADR-0019) Co-authored-by: Cursor <cursoragent@cursor.com>
- Implement ClientBundle with preconfigured per-mode agents (ADR-0004) - Add getReadAgent/getWriteAgent/getPdsRepoAgentFor dispatch helpers - Add Zustand sessions store with per-account AppView prefs (ADR-0010) - Wire SessionProvider to OAuth restore and known-DID reconciliation - Expose useViewerScope/useAccountScope hooks (ADR-0009) - Add NotAuthenticatedError and AppViewNotSupportedError Co-authored-by: Cursor <cursoragent@cursor.com>
- Add useInfiniteList helper (ADR-0008) and feed dispatch helpers - Implement posts, profiles, feeds, notifications, search, lists, feed-generators, and bookmarks read hooks with primer integration - Direct-route hooks use refetchOnMount + 60s staleTime (ADR-0016) - Canonical post/profile reads use Infinity staleTime via primers Co-authored-by: Cursor <cursoragent@cursor.com>
…eration context Add server-backed usePreferences with preserve-unknown mutation hooks, hybrid useShortcutBar reconcile/writeback, and useModerationContext wired into accepted-labeler client headers and ViewerScope cache keys. Co-authored-by: Cursor <cursoragent@cursor.com>
- Include baseline labelers in moderation opts.labelers so default labels apply. - Split handle resolution (actorResolution → DID) from profileByDid body cache. - Prime posts in useListFeed, not just authors. - Guard post primer to skip non-post viewRecord embeds; add ADR-0016 embed tests. Co-authored-by: Cursor <cursoragent@cursor.com>
- Pass labelDefs from fetched labeler views into moderation opts. - Use per-field profile UI contexts for avatar/banner/displayName/bio blur. - Implement ADR-0004 getPdsRepoAgentFor(clients, did) with OAuth restore path. Co-authored-by: Cursor <cursoragent@cursor.com>
- Hydrate notification posts via notificationStatusURI for like/repost chains. - Restore legacy non-atproto Playwright project for existing *.spec.js coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
- Treat noOverride blurs as blur visibility, not warn downgrade. - Reject unsafe facet link schemes; add javascript: XSS regression test. Co-authored-by: Cursor <cursoragent@cursor.com>
- Expose noOverride on post/profile moderation decisions for non-revealable blurs. - Pin blocking blur decisions as noOverride in moderation-decision unit test. Co-authored-by: Cursor <cursoragent@cursor.com>
Gate timeline reads when logged out, serialize preference writes per DID, surface contentMedia blur separately, and align lists/prefs/moderation helpers with review feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce typed UI-state slices per ADR-0006 and ADR-0017, with unit tests for modal reset, spoiler reveals, and per-DID ui preference isolation. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26365015427-20260524151815. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26365070754-20260524152046. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26365111965-20260524152234. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26365181556-20260524152540. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26365395237-20260524153500. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26367707442-20260524171712. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26368516692-20260524175251. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26369499980-20260524183719. |
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26373836511-20260524215716. |
Unlike, unrepost, unfollow, and unblock previously deleted whatever repo the record URI claimed. Resolved URIs now flow through parseOwnedRecordUri, which requires repo === activeDid and a matching collection, and the deletes use the typed app.bsky.<col>.delete with the validated repo and rkey.
|
Preview deployed for OAuth metadata: Verified |
|
Agent needs human attention: Claude review failed or returned unparsable structured output. See logs under /workspace/agent-worktrees/bluepy/logs/26374470258-20260524222703. |
Draft checkpoint for manual M7 sanity testing.\n\nVerified before push:\n- bun run typecheck\n- bun run test:unit\n- bun run build\n- bun run test:e2e: 183 passed, 0 failed, 0 skipped\n- changed-file oxlint exited 0 with warnings only\n\nCommit: 900ba14
Summary by cubic
Migrated all read surfaces to an ATProto‑native data layer with
@tanstack/react-query, three‑client dispatch, and a moderation layer; ships the M7 checkpoint across posts, profiles, timelines, lists, notifications, search, bookmarks, and profile graphs. Also ports core engagement and graph mutations (M8) with optimistic caching, and hardens record‑URI deletes to validate the active DID.New Features
pds/Active AppView/Bluesky AppView) with per‑viewer cache keys and a<SessionProvider>for OAuth, Active AppView, and labelers.useFollowers/useFollows.PostUriFeed,TimelineFeed,NotificationsFeed,ListFeed,ProfileFeed,PostThreadPage,PostByUri,ProfileByDid,PostText.src/data/keys.ts.@tanstack/react-query,@tanstack/react-query-devtools,zustand.Bug Fixes
Written for commit c2ae49c. Summary will update on new commits. Review in cubic