Skip to content

docs: correct design doc, ADR and spec statements that no longer hold - #350

Merged
nownabe merged 1 commit into
mainfrom
docs/294-drift
Sep 20, 2026
Merged

nownabe merged 1 commit into
mainfrom
docs/294-drift

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

docs/ had accumulated statements that no longer describe the code: a wire
format two versions old, a storage backend that was never built, an ADR rule the
UI does not follow, and superpowers specs that contradict the ADRs without saying
so. A newcomer following the reading order AGENTS.md prescribes was being misled.

Documentation only — no behaviour change. The ADRs were amended heavily between
the issue and this PR (#303–#348), so every item was re-audited against the code
on main (9465718) before editing; two were already fixed and are recorded as
such below.

What

Per item of #294:

  1. ADR 0003 §7 "Legacy metadata is discarded" → rewritten as "read, never
    rewritten". lib/pr/metadata.ts accepts bark:v1 and its docreview:v1
    alias read-only (extractMetadata → parseV1) and maps them to the v2 shape;
    only an unparseable, invalid or unknown-version payload is dropped. The note
    says why there is no migration path: v1 payloads live in comment bodies on
    github.com, which no client release can rewrite. The two cross-references that
    repeated the old claim (ADR 0001 and ADR 0002 closing notes) now distinguish
    local legacy keys, which are dropped, from on-GitHub metadata, which is not.

  2. ADR 0004 §5 force-push bullet → replaced. GET contents?ref={sha}
    addresses a commit object, not a ref, so a force-pushed sha normally stays
    fetchable (and PR heads are retained under refs/pull/N/head); re-anchoring
    proceeds through the line map as usual, and only a real 404 (garbage-collected
    commit, path or repo gone) leaves FileContent missing and yields outdated.
    Design doc §12-3 is closed accordingly.

  3. ADR 0005 §1/§5 manual refresh → amended to match the code rather than
    gating the fab. DebugFab is always rendered; the Refresh button lives one
    click deeper, inside the debug popover, next to the internal-state dump. §5
    carries an explicit amendment note saying that is accepted for v1 and why.
    docs/design-principle.md's floating-controls bullet now states the rule the
    two FABs actually follow: reveal-only may ship, behaviour-changing is
    build-gated (.role-fab / BARK_DEV_ROLE_SWITCH).

  4. Design doc §7.1 / §7.7 / §10 → the raw-JSON bark:v1 example is replaced
    by a real bark:v2 base64 envelope with its decoded payload, the optional
    resolved and quoteDigest/quoteLength (fix(pr): bound the comment body to GitHub's 65,536-character limit #334) fields, and a pointer to
    lib/pr/metadata.ts as the authoritative field list. §7.7 now describes
    chrome.storage.local as the only store, lists the three per-PR keys, and
    states plainly that the IndexedDB plan was never built; §10's "persist state to
    IndexedDB" bullet and its ETag sentence are rewritten to what the client does.

  5. 2026-06-18 resolve spec → the superseded banner added by feat(pr): resolve out-of-diff threads via the root comment fence #310 is present
    and correct; verified, not touched. Its plan had none, so it got one. The
    design doc's authority paragraph now covers docs/superpowers/ explicitly:
    history, not authority, and the absence of a banner is not a promise of
    currency.

  6. §7.9 addressed vs ADR 0004 shifted → ADR 0004 §4 gains a paragraph
    stating that shifted is the raw mechanical signal and R9's addressed (R9: Track review↔fix round history #3)
    is derived from it plus the review rounds, specified separately and stored
    nowhere. Design doc §7.9 now references the ADR statuses instead of inventing
    its own, and notes that the addressedBySha in lib/github.ts is an
    unreferenced legacy type, not part of the model.

  7. Design doc §11 status → R8 cross-file navigation is marked shipped (the
    changed-.md selector in Topbar.tsx, fed by RemoteState.changedFiles), so
    M5 is done and M4 (R9/R10) is the remaining open work.

  8. ADR statements not implemented — decided in favour of the code:

Also folded in (from the #299 agent, found while reviewing PR #349):

  • AGENTS.md / README.md layout described lib/github.ts as "GitHub API". It
    is not: it holds PR types and four pure helpers, while the client, the
    Repository pipeline, re-anchoring and the wire format all live in lib/pr/.
    Both are rewritten around lib/pr/ as the place to start, and the non-existent
    lib/reanchor.ts is dropped. (CLAUDE.md is a symlink to AGENTS.md, so one
    edit covers both.)
  • 2026-06-21 author-role-derivation spec and plan describe deriveRole and a
    GitHubClient.getAuthenticatedUser lookup; the live derivation is computeRole
    in lib/pr/appstate.ts, which also withholds author when headRepo is null
    ([Medium] Fork PRs: PullRequest has no head repository, so Commit targets the base repo #273). Both files get a Superseded banner pointing there and at ADR 0002 §4.

Every ADR amended here records it in the header in ADR 0004's existing
- Amended: <date> (#issue) — <what> format; two prior amendments that had
changed an ADR body without a header line (#267 on ADR 0004/0005, #289 on
ADR 0001) are backfilled from their commits, and ADR 0002's in-place 2026-07-22
note is now also listed in the header.

Testing

No test accompanies this change: it edits only Markdown, and there is no
assertion a docs edit could make fail. The verification was reading each claim
against the code it describes — lib/pr/metadata.ts, lib/pr/reanchor.ts,
lib/pr/remote-fetcher.ts, lib/pr/chrome-storage.ts, lib/drafts.ts,
entrypoints/review/hooks/useSuggestionEdits.ts,
entrypoints/review/components/DebugFab.tsx, entrypoints/review/reviewItems.ts
— and the base64 example in §7.1 is generated, not hand-written, so it decodes to
the JSON printed beneath it.

Checks

bun run test (822 pass / 0 fail, 65 files) · check:lint · check:format ·
typecheck · build — all clean. Note for future docs PRs: oxfmt does
format Markdown in this repo, and it reflowed the README table.

Noted, out of scope

  • lib/storage.ts:2-3 still promises "IndexedDB: per-PR pending comments/
    suggestions, snapshots (later slice)" in its header comment — the same drift as
    item 4, but in code. Left for a code PR since this one touches no .ts.
  • lib/github.ts keeps the dead CommentStatus / ReviewComment /
    addressedBySha types that nothing imports. PR refactor: give PrRef, ChangedFile and PullRequest one home each #349 removes them.
  • Nothing links to docs/superpowers/ or docs/chrome-web-store/, and
    docs/adr/ has no index page. The authority paragraph now explains what
    superpowers/ is, which covers the misleading part; an index is a separate
    question.

Closes #294

A newcomer reading docs/ in the order AGENTS.md prescribes was misled about the wire format, local storage, the refresh UI and which spec still applies. Each statement here was re-checked against the code on main and either corrected or recorded as a decision in the owning ADR.

Closes #294
@nownabe nownabe self-assigned this Sep 20, 2026
@nownabe
nownabe merged commit bda2582 into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the docs/294-drift branch September 20, 2026 10:21
nownabe added a commit that referenced this pull request Sep 20, 2026
#353)

## Why

Comments that say where code *used to* live, or that name a
refactor-plan phase
(`Pack B / R8b`, `L7e-1`, `Phase 4`), send the reader looking for
something that
either moved or was never in this repo. CSS rules with no markup and
exports with
no importer cost the same kind of lookup. Two of them were worse than
noise: the
`pr:{owner}/{repo}#{n}` key prefix and the UTF-8 base64 decoder each had
two
independent definitions that could silently drift.

Net **-130 lines** (135 insertions / 265 deletions) across 29 files,
plus one
deleted file. No behaviour change.

## What

**1. Tombstone / phase-tag comments.** Re-located by content (the
issue's line
numbers are from before #303–#350). Rewritten to say what the code is,
or deleted
where the comment only described history: `App.tsx` (a garbled
half-sentence, six
"now lives in …" markers, and the `L5` / `L6c` / `L6d-1` / `L7e-1` /
`R3` / `R6`
tags), the five `hooks/` headers, both `adapters/` headers plus
`displayPositionToAnchorStatus.ts`, `highlight.ts`, `suggestionView.ts`,
`lib/drafts.ts`, `lib/comments.ts`, `lib/pr/repository.ts`.
`lib/storage.ts`'s
header advertised an IndexedDB layer that does not exist — it now says
chrome.storage.local and points at ADR 0001 §2. Real "why not" sentences
(the
reviewer note on thread visibility, the `canAccept` rationale, every
`simplify:`
and issue-numbered note) are untouched.

**2. Dead CSS.** Deleted `.field--mono`, `.badge--review`,
`.badge--suggestion`,
`.badge--anchored`, `.composer__routing`, `.radio-row` (+ `.radio-row
label`)
after an exact-token search over `entrypoints/`, `lib/`, `tests/` found
no
producer. `.badge--anchored` is unreachable by construction as well:
`ThreadItem`
builds `badge--${status}` from `AnchorStatus` (`current` | `reanchored`
|
`outdated`), gated on `STATUS_LABEL[status]`, which only defines
`reanchored` and
`outdated`. `docs/design-principle.md` no longer lists `.field--mono`.

**3. No-consumer leftovers.**
- Deleted the empty root `components/` directory (nothing in
`wxt.config.ts`,
`tsconfig.json` or the docs configures a root components dir; the real
one is
  `entrypoints/review/components/`).
- Dropped `useUiPanels.closePrInfo` (only the hook's own test called
it).
- Un-exported `APP_SLUG`, `SubmitCommitGroup`, `SubmitSummary` — all
used only in
their defining module. `SubmitGroup` stays exported:
`SubmitConfirmModal` imports it.
- `prStorageKey` / `prStorageKeys` now build on `storageKeys.pr`, the
same prefix
`lib/drafts.ts` builds, so #332's eviction and the drafts keys cannot
drift.
- `base64Decode` is exported from `lib/pr/metadata.ts` and reused by
`remote-fetcher.ts`; the fetcher keeps its own whitespace strip (GitHub
wraps
its base64 at 60 chars) rather than pushing that into the fence decoder.
- Deleted `fetchThreads` (no production caller — `fetchRemoteState`
inlines
  `listReviewThreads` + `threadsFromRaw`). Its four tests now call
`threadsFromRaw(await listReviewThreads(...))` through a 2-line local
helper, so
the paging coverage is unchanged and the only export is a function
production
  actually uses.

**4. `AppState.currentFiles`.** Verified no consumer anywhere in
`entrypoints/`;
deleted it with `buildCurrentFiles` and its two tests.

## Test evidence

This is a deletion PR, so there is no red step except for the two shared
helpers,
where the rule was to pin current behaviour *before* unifying:

- `tests/pr/chrome-storage.test.ts` — "shares its prefix with the keys
  lib/drafts.ts builds": `prStorageKey("acme","site",42)` ===
`` `${storageKeys.pr("acme","site",42)}:state` ``. Added and run **green
against
the two independent definitions**, then `prStorageKey` was rewritten
onto
  `storageKeys.pr`; still green.
- `tests/pr/remote-fetcher.test.ts` — "decodes UTF-8 from the
line-wrapped base64
GitHub returns": multibyte source, base64 wrapped at 60 chars. Added and
run
green against the fetcher's private decoder, then repointed at the
shared
  `base64Decode`; still green.

Full set on the rebased branch: **816 pass / 0 fail** (`bun run test`),
`check:lint`, `check:format`, `typecheck` and `build` all clean.

## Dropped from the issue (already fixed on main)

- `DebugFab.tsx`'s undefined `var(--green)` — gone with DebugFab's
preview.
- `lib/pr/bootstrap.ts:8-17` — the current header describes the live
composition
  accurately; nothing to remove.
- `lib/pr/repository.ts:159` — that line is live code today; only the
`(Phase 4)`
  tag on line 8 needed a fix.

## Left out, on purpose

Two phase tags remain in `App.tsx`'s submit flow — `// already
double-written by
L4/L6a` and `// (the L6d-1 effect is best-effort…)`. Both sit inside the
`composeDraftBody` call regions that the still-open #351 edits, so they
are left
for a one-line follow-up after that merges rather than handed #351 a
conflict.

Closes #301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Low] Docs drift: design doc, ADR and spec statements that no longer hold

1 participant