Skip to content

feat(pr): resolve out-of-diff threads via the root comment fence - #310

Merged
nownabe merged 1 commit into
mainfrom
feat/270-out-of-diff-resolve
Sep 20, 2026
Merged

nownabe merged 1 commit into
mainfrom
feat/270-out-of-diff-resolve

Conversation

@nownabe

@nownabe nownabe commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Why

Out-of-diff comments — the design doc's default path — are posted as plain PR issue comments, which have no GraphQL review thread. ADR 0002 §7 made GitHub's isResolved the sole source of truth for resolution, and that field exists only for review threads, so issue-comment threads could never get a Thread with a remote identity. The consequences were concrete: Resolve was hidden for them (#182), and an author who accepted an out-of-diff suggestion got the commit but no resolution — setThreadResolved was a no-op, the accepted decision was cleared, and the suggestion reappeared as open on the next load (where Accept then failed the quote check).

What

Resolved state for an out-of-diff thread now lives in the hidden metadata of the thread's root issue comment: the v2 envelope gains an optional resolved: boolean, written by a read-modify-write (GET → re-embed the fence → PATCH) of that comment. GitHub stays the sole source of truth, no extra timeline comments are posted, and the read side is the extractMetadata call the fetcher already makes on every issue comment.

  • Wire format (lib/pr/metadata.ts): WireMetadata.resolved?: boolean. parseV2 reads it as === true and drops any other value, so a stray field never demotes a real Bark comment to foreign.
  • Entity (lib/pr/types.ts): Thread.remoteIssueCommentId?: number, the second remote identity, plus the shared hasRemoteIdentity(t) predicate and findRemoteThread(remoteThreads, t) (review threads join on the node id, out-of-diff threads on their local id). Everything downstream keys on "has a remote identity" instead of "has a remoteThreadId".
  • Fetcher (lib/pr/remote-fetcher.ts): fetchRemoteState synthesises a Thread for each issue comment that is the earliest bearer of its threadId (the [Medium] Bark metadata fence trusts attacker-controlled identity — thread/comment spoofing #190 ownership rule already computed in buildFenceOwners), skipping ids already claimed by a review thread (the [Medium] Reply to an out-of-diff thread always fails — planner routes every reply to the review-reply endpoint #184 out-of-diff-reply flow). A later comment reusing a threadId is a reply, never the root, so a forged fence can neither resolve someone else's thread nor duplicate a Thread id. Standalone fetchThreads stays GraphQL-only (documented).
  • Pipeline: UpdateThreadResolved now carries the thread's remote identity; the Planner routes remoteIssueCommentId → the new SetIssueThreadResolved step, remoteThreadId → the existing GraphQL steps. New Transport.setIssueThreadResolved, executor dispatch, and state-machine handling (local: synced / draft+lastError; remote mirror: resolved updated). The read-modify-write race on the root comment is marked with a simplify: comment naming the ceiling and the updated_at-conditional upgrade path.
  • UI (App.tsx): resolvableThreadKeys filters on hasRemoteIdentity, so Resolve/Reopen appears for out-of-diff threads. The Accept flow needed no code change — setThreadResolved now finds a Thread, and the fence-backed resolved keeps the thread closed after a reload.
  • Docs: ADR 0002 §3/§5/§7 and ADR 0003 §2/§4/§5/§7 updated per the design; the 2026-06-18 resolve spec gets a superseded banner. (The full docs-drift sweep remains [Low] Docs drift: design doc, ADR and spec statements that no longer hold #294.)

Out of scope, per the design: creating a Thread when a draft is composed (#272 — a thread posted in the current session becomes resolvable after the next refresh, same as in-diff today), and hiding Resolve for viewers without write access (#274 — a 403 surfaces as draft + lastError → Snackbar).

Red-test log

Every test was written first and run against unmodified code; each failure below is the observed red.

  1. tests/pr/metadata.test.ts — "the v2 envelope round-trips resolved and coerces non-booleans": expect(received).toBeUndefined() / Received: "yes" (parseV2 passed unknown keys through verbatim).
  2. tests/pr/remote-fetcher.test.ts — "fetchRemoteState synthesises a Thread for a Bark out-of-diff thread from its root fence": expected 2 threads, Received: [].
  3. tests/pr/remote-fetcher.test.ts — "resolved is read only from the thread's root … (issue [Medium] Bark metadata fence trusts attacker-controlled identity — thread/comment spoofing #190)": expected 1 thread, Received: [].
  4. tests/pr/remote-fetcher.test.ts — "an issue fence claiming a review thread's synthesised id does not duplicate the Thread (issue [Medium] Bark metadata fence trusts attacker-controlled identity — thread/comment spoofing #190)": a second { id: "foreign-thread-PRT_1", remoteIssueCommentId: 506 } was synthesised alongside the review thread (this is the test that makes the taken guard load-bearing; the design's "[Medium] Reply to an out-of-diff thread always fails — planner routes every reply to the review-reply endpoint #184 reply" case, also added, is green either way because the ownership rule already covers it).
  5. tests/pr/reconciler.test.ts — "a syncing Thread with remoteIssueCommentId emits UpdateThreadResolved matched by local id": expected 1 op, Received: [] (the remoteThreadId === undefined guard skipped it).
  6. tests/pr/planner.test.ts — "an op carrying remoteIssueCommentId → SetIssueThreadResolved": got { kind: "resolve-review-thread", remoteThreadId: undefined }.
  7. tests/pr/executor.test.ts — "a SetIssueThreadResolved step is dispatched to transport.setIssueThreadResolved": expected 1 recorded call, Received: [].
  8. tests/pr/github-transport.test.ts — all four sub-cases (GET→PATCH, no-fence, 403, v1 upgrade): TypeError: transport.setIssueThreadResolved is not a function.
  9. tests/pr/state-machine.test.ts — four reds: setThreadResolvedToSyncing left the draft at "draft"; completeNoopThreadSyncs left the thread "syncing"; applyStepResults and applyStepResultsToRemote both returned undefined for the unknown step kind (TypeError: undefined is not an object). A fifth, "keeps a protected local out-of-diff Thread that already has a remoteIssueCommentId", failed with the pending toggle clobbered by remote (resolved: true/"syncing" → false/"synced") — the design predicted the mirror-image adopt case, which already passes since lacksRemoteIdentity only checked remoteThreadId.
  10. tests/pr/repository.test.ts — "an out-of-diff thread resolves via SetIssueThreadResolved and stays resolved across refresh and reload": as an end-to-end test over units already built by step 9, it was green on first run; reverting the reconciler's identity guard reproduced the design's predicted red (expected 1 dispatched step, Received: []), confirming it is load-bearing. The guard was restored immediately.

One pre-existing test was updated rather than added: tests/pr/remote-fetcher.test.ts "a review thread cannot claim an out-of-diff (issue) thread's id" asserted out.threads by exact equality, and the legitimate out-of-diff thread now correctly gets its own Thread entity. Its security assertions are unchanged.

Manual verification

bun run build succeeds; load .output/chrome-mv3 as an unpacked extension and:

  1. As a reviewer, select text outside the diff of a changed .md, comment, Submit, then refresh. The thread now shows ✓ Resolve. Click it: no error, the thread moves to the Resolved facet. On github.com, open that issue comment's raw source and confirm the trailing <!-- bark:v2 … --> fence decodes to JSON containing "resolved":true — and that no new comment was posted.
  2. Reload the Bark tab: the thread is still resolved. Click Reopen: the fence flips to false and the thread returns to Submitted.
  3. As a reviewer, post an out-of-diff suggestion; as the author, Accept it and Submit. The commit lands, the thread resolves on GitHub, and after a full reload it stays closed with Accept no longer offered.
  4. Regression: an in-diff thread still resolves via GraphQL (the review thread collapses on github.com), and a foreign issue comment posted natively still shows no Resolve control.
  5. Negative: with a read-only user, resolving another user's out-of-diff thread shows the Snackbar error and the thread stays unresolved.

Checks: bun run test (672 pass / 0 fail), check:lint, check:format, typecheck, build — all green.

Closes #270

Issue-comment threads have no GraphQL review thread, so ADR 0002's GraphQL-only resolution left them with no lifecycle: Resolve was hidden, and an accepted out-of-diff suggestion reopened on every reload. Their resolved state now lives in the hidden metadata of the thread's root issue comment, keeping GitHub the sole source of truth and posting no extra comments.

Closes #270
@nownabe nownabe self-assigned this Sep 20, 2026
@nownabe
nownabe merged commit 7e0ecb9 into main Sep 20, 2026
10 checks passed
@nownabe
nownabe deleted the feat/270-out-of-diff-resolve branch September 20, 2026 05:59
nownabe added a commit that referenced this pull request Sep 20, 2026
PR #310 widened the Transport interface after #307 added these mocks, so typecheck was red on main.
nownabe added a commit that referenced this pull request Sep 20, 2026
PR #310 widened the Transport interface after #307 added these mocks, so typecheck was red on main.
nownabe added a commit that referenced this pull request Sep 20, 2026
…317)

## Why

`bun run typecheck` is red on `main` since #310 merged: it added
`setIssueThreadResolved` to the `Transport` interface, while
`tests/AppSubmitFailure.test.tsx` (added by #307, which branched before
#310) still builds two `Transport` mocks without it. Every open PR's CI
inherits the failure.

## What

Add a `setIssueThreadResolved` stub (`{ ok: true }`) to
`failingTransport()` and `happyTransport()` in
`tests/AppSubmitFailure.test.tsx`. No behaviour change; the five tests
in that file still pass.

Checks: `typecheck` clean, `test tests/AppSubmitFailure.test.tsx` 5
pass, `check:lint` and `check:format` clean.

Merge this first so the CI of #315 and the other open PRs goes green.
nownabe added a commit that referenced this pull request Sep 20, 2026
## Why

Two pieces of the tree had no consumers and only cost maintenance:

- `scripts/check-metadata.ts`, `scripts/check-suggest.ts`,
`scripts/check-suggestion.ts` were manual one-off checks never wired
into `package.json`, CI or docs. What they assert is already covered by
`tests/suggest.test.ts`, `tests/github.test.ts` and
`tests/pr/metadata.test.ts`, so they could only drift against the
modules they poke at (two of them still import the v1 codec slated for
removal in #298).
- `lib/linemap.ts` was a second LCS `buildLineMap` with the same
contract as `lib/pr/linemap.ts`. Production imports only
`lib/pr/linemap` (via `lib/pr/reanchor.ts` and `lib/suggest.ts`); the
copy was reachable from its own test alone. Two implementations of one
contract silently diverge — and the trailing-newline convention that
`lib/anchor.buildLineIndex` depends on is exactly the kind of thing that
drifts.

## What

- `git rm -r scripts/` (144 lines).
- Deleted `lib/linemap.ts` + `tests/linemap.test.ts` (104 lines), after
porting the trailing-newline convention case into
`tests/pr/linemap.test.ts`.
- Dropped the stray `biome-ignore` comment in `lib/pr/linemap.ts` — the
repo lints with oxlint, so it directed nothing.

**249 lines removed, 9 added.**

### Deletion safety

Grepped the whole tree (excluding `node_modules`/`.git`) for
`scripts/check`, `check-metadata`, `check-suggest`, `check-suggestion`:
three hits, all inside the scripts' own `// Run:` header comments.
`package.json`, `.github/workflows/*`, `README.md`, `AGENTS.md` and
`docs/` have none. Importers of the top-level `lib/linemap`: exactly
`tests/linemap.test.ts:2`. There is no `@/lib` alias and no
`lib/index.ts` barrel, so no indirect path existed.

## Test evidence

The ported case as written in `tests/linemap.test.ts:47-52` passes
against `lib/pr/linemap.ts` unchanged — both implementations split on
`"\n"` identically. That makes it a green-on-arrival test, so I checked
it actually has teeth by mutating `lib/pr/linemap.ts` to strip a
trailing newline before splitting:

```
(fail) linemap > treats a trailing newline as a final (empty) line, matching buildLineIndex
error: expect(received).toBe(expected)  Expected: 4  Received: undefined
  at tests/pr/linemap.test.ts:58
```

The original assertions (`a → 2`, `b → 3`) survived that mutation
untouched — they never tested the convention. The ported test therefore
also asserts that the trailing empty line maps (`map.get(3) === 4`),
which is the assertion that fails when the convention changes. Mutation
reverted; suite green.

## Checks

`bun run test` 689 pass / 0 fail (61 files, down from 695/62 — the 6
dropped are the deleted `tests/linemap.test.ts`), `check:lint` clean,
`check:format` clean, `bun run build` OK.

`bun run typecheck` fails on `tests/AppSubmitFailure.test.tsx:81,105`
(`Property 'setIssueThreadResolved' is missing ... in type
'Transport'`). This is **pre-existing on `main` at 7e0ecb9** and
unrelated to this PR: that file was last touched by #307 and #310 later
added `setIssueThreadResolved` to `Transport` without updating its two
mock transports. This PR touches neither file. It needs its own fix.

Closes #297
nownabe added a commit that referenced this pull request Sep 20, 2026
## Why

ADR 0002 says `Comment.threadId` is "always set", but nothing created
the `Thread`. The submit
therefore had no local Thread to hand the new thread's remote identity
to, so a thread posted in
the current session stayed unresolvable until the next full refresh (the
#182 symptom), and
`AppState.threadGroups` had to synthesise placeholders for Bark's own
threads.

## What

- `PullRequestRepository.upsertComment` creates the Thread: a top-level
Comment with no existing
Thread for its `threadId` also inserts `{ id, state: "draft", resolved:
false }`, in one
persist. Doing it in the shared Repository method fixes every producer
at once (`addDraft`, the
suggestion-draft loops in `submitReview` / `submitAuthor`, tests).
Replies create nothing.
- `discardComment` drops a Thread that has no remaining Comments and no
remote identity.
- The missing transition: on `post-issue-comment` success for a
**top-level** comment, the Thread
becomes `synced` with `remoteIssueCommentId` = the root issue comment's
REST id (exactly the
identity #310 defined) — in `LocalState` and in the `RemoteState`
mirror. A freshly posted
thread is now resolvable immediately, in and out of diff. The in-diff
path already worked via
`applyReviewBatchSuccess`; its mirror upsert is now shared as
`upsertRemoteThread`.
- ADR 0002 §3, ADR 0001 §3's lifecycle sequence, and ADR 0003 §7 step 3
updated; the
`buildThreadGroups` and `resolvableThreadKeys` comments now say the
synthesis is only for
  foreign comments.

## Red-test evidence

`bun run test tests/pr/state-machine.test.ts
tests/pr/repository.test.ts` before the fix — 4 failures:

- `repository — mutations > upsertComment of a top-level draft creates a
draft Thread with the same id (issue #272)`
  → `threads` was `[]`.
- `repository — out-of-diff threads (issue #272) > a freshly submitted
out-of-diff thread is resolvable in the same session`
→ `calls` was `["post-issue-comment"]`, missing
`"set-issue-thread-resolved"` (no Thread, no identity).
- `state-machine — applyStepResults: PostReply / PostIssueComment >
post-issue-comment success on a top-level comment marks its Thread
synced with remoteIssueCommentId (issue #272)`
  → thread stayed `state: "syncing"` with no `remoteIssueCommentId`.
- `state-machine — applyStepResultsToRemote > PostIssueComment success
mirrors a new out-of-diff Thread into RemoteState (issue #272)`
  → `threads` was `[]`.

Guards that passed before and still pass: reply creates no Thread;
`upsertComment` never
overwrites an existing Thread; `appstate` still synthesises a group for
comments without a Thread.

After the fix: 705 pass, 0 fail across 62 files.

## Note

A `PostReviewBatch` mapping without `remoteThreadId` (the confirm
listing found the comment but
not its thread) leaves the Thread `syncing` at the end of the
invocation. #271 (next in this
stack) adds the end-of-invocation sweep that returns it to `draft +
lastError`; until then the
next refresh adopts it by id via `mergeBy`.

## Checks

`bun run test` (705 pass / 0 fail), `check:lint`, `check:format`,
`typecheck`, `build` — all clean.

Closes #272
nownabe added a commit that referenced this pull request Sep 20, 2026
## Why

GitHub only accepts `resolveReviewThread` from the PR author or a user
with write access, and only accepts the out-of-diff root rewrite (#310's
transport, `PATCH /issues/comments/{id}`) from that comment's author or
a writer. Bark showed Resolve/Reopen to every reviewer, so for a
read-only reviewer — the usual external reviewer on a public repo — the
mutation always failed: the Thread landed in `draft + lastError` and the
Snackbar showed a raw GraphQL error. A dead-end control.

## What

- `Thread.viewerCanResolve?: boolean` — a mirrored fact like `resolved`,
`undefined` while the thread is a local draft.
- `fetchRepoPushPermission(client, ref)` reads `permissions.push` from
`GET /repos/{o}/{r}`. It joins the existing `Promise.all` in
`fetchRemoteState` and is `.catch(() => false)`-guarded: a refresh must
never fail because of the permission probe, and without the signal we
withhold the affordance rather than offer a dead end. The GET is
ETag-cached by `github-api`, so every refresh after the first is a 304
at no rate-limit cost.
- Per-thread rule, from data the fetcher already has: a review thread is
resolvable when `canWrite || viewer.login === pullRequest.author.login`;
an out-of-diff thread when `canWrite || viewer.login ===
rootIssueComment.user.login` (logins compared case-insensitively).
`fetchThreads` standalone passes nothing and its output is unchanged.
- `canResolveThread(t)` in `types.ts` (`hasRemoteIdentity(t) &&
t.viewerCanResolve === true`) replaces the bare `hasRemoteIdentity`
filter behind App.tsx's `resolvableThreadKeys`. `ThreadItem` keeps the
#182 pattern: a thread that cannot be resolved simply shows no control.
- ADR 0002 §3 documents the field; ADR 0003 §5 records that the gate
lives in the UI, not the Planner — the Executor still runs any Op it
receives, and a GitHub refusal still lands the Thread in `draft +
lastError`.

**Rejected:** GraphQL's per-thread `viewerCanResolve` (precise for
review threads, but out-of-diff threads still need the write signal —
two mechanisms plus a change to `listReviewThreads`'s return shape);
`PullRequest.viewerCanUpdate` (true for the PR author, who still cannot
PATCH a reviewer's issue comment); disabling with a tooltip (a new UI
state for a control the user cannot use).

**Known limitation**, to carry into #278's design rather than fix here:
a PR author without write access cannot resolve an out-of-diff thread
rooted in a *reviewer's* issue comment, because the transport edits that
comment. With this change they at least see no Resolve button there.

## Red-test evidence (before the fix)

`bun run test tests/pr/types.test.ts tests/pr/remote-fetcher.test.ts` →
**6 fail, 1 error**:

- `canResolveThread (issue #274)` (4 tests) — `SyntaxError: Export named
'canResolveThread' not found in module '.../lib/pr/types.ts'`.
- `remote-fetcher — viewerCanResolve (issue #274) > a read-only reviewer
cannot resolve a review thread` — `Expected: false, Received:
undefined`.
- `> write access can resolve a review thread` — `Expected: true,
Received: undefined`.
- `> the PR author can resolve a review thread without write access` —
`Expected: true, Received: undefined`.
- `> an out-of-diff thread is resolvable by its root comment's author` —
`Expected: true, Received: undefined`.
- `> a failed permission probe defaults to no write access and does not
fail the refresh` — `Expected: false, Received: undefined`.

Fixture churn, as predicted: the existing whole-object `toEqual`s on
`out.threads` gained `viewerCanResolve: true` (their viewer is alice,
who is both PR author and root author). Test fetch handlers also gained
a `/repos/o/r` branch — without it the probe's thrown fetch is treated
as a transient failure and retried with backoff, which added ~1.2 s per
affected test (the suite went 2.4 s → 9.8 s). With the stubs it is back
to 2.5 s.

## Checks

`bun run test` 715 pass / 0 fail (63 files) · `check:lint` OK ·
`check:format` OK · `typecheck` OK · `build` OK.

Closes #274
nownabe added a commit that referenced this pull request Sep 20, 2026
)

## Why

ADR 0002 §7 defines a rejected suggestion as "the thread is resolved,
with no corresponding commit", and says the local `RejectedSuggestions`
set is removed. The code still wrote `"rejected"` into the per-browser
dismissed map and stopped there: the reviewer never learned their
suggestion was declined, another browser of the same author saw it as
still open, and GitHub knew nothing. The local entry also hid the
suggestion forever in that one browser.

## What

- Reject calls `setThreadResolved(t, true)` — the existing
immediate-action path (`syncing` → GraphQL `resolveReviewThread`, or the
#310 root-fence rewrite for out-of-diff threads) with its `resolvingId`
and Snackbar handling. `rejectSuggestion` is deleted; no marker comment,
no reason, no reply (ADR 0002 §7 removed marker comments, and GitHub
already shows the resolved state). The author undoes with the existing
Reopen button, which brings Accept/Reject back.
- `SuggestionDecision` narrows to `"accepted"` — the map now carries
only the transient "accepted, awaiting commit" decisions.
`listDismissedSuggestions` filters non-accepted values on read, so a
`"rejected"` entry persisted by an earlier build stops hiding a
suggestion; `clearAcceptedDecisions` simplifies to a plain id filter.
- `ThreadItem`: author actions are hidden on a resolved thread (a
rejected suggestion IS one — re-offering Accept/Reject would invite a
contradictory second decision); the `decision` branch renders only the
accepted note; Reject is `disabled` when the thread cannot be resolved
by this viewer, with the same title pattern Accept uses.

No ADR amendment: ADR 0002 §7 already states the rule. The code catches
up with it.

**Rejected:** posting a "Rejected via Bark" reply (marker comments are
gone; if the author wants to say why, the reply box is right there);
keeping `"rejected"` locally as a cache of the resolved state (a second
source of truth that diverges per browser — the bug itself); batching
the reject into Submit like accepts (a reject has no commit dependency).

## Behaviour change to note

Reject now round-trips to GitHub, so it can fail (network, or a 403 for
a PR author without write access on an out-of-diff root — see #274's
known limitation). `setThreadResolved` reports it via Snackbar, the
thread returns to `draft + lastError`, and the buttons stay available
for a retry. Users who rejected suggestions with an earlier build see
them reappear once; rejecting again resolves them on GitHub.

## Red-test evidence (before the fix)

- `tests/drafts.test.ts` → `listDismissedSuggestions (issue #287) >
drops legacy 'rejected' entries`
`expect(received).toEqual(expected)` — Received `{ "1": "accepted", "2":
"rejected" }`, Expected `{ "1": "accepted" }`.
- `tests/ThreadItem.test.tsx` → `ThreadItem — reject (issue #287) >
author actions are hidden on a resolved thread`
`expect(received).toBeNull()` — Received an `HTMLDivElement` (the
`.comment__actions` row). And `> Reject is disabled when the thread
cannot be resolved` — `Expected: true, Received: false`.
- `tests/AppRejectSuggestion.test.tsx` (new) → `App — author rejects a
suggestion (issue #287) > resolves the thread through the transport and
stores no local decision`
`expect(received).toEqual(expected)` — Received `[]`, Expected
`["resolve-review-thread"]`: clicking Reject reached GitHub not at all.

The new App test copies the `mock.module` save/restore dance from
`tests/AppSubmitFailure.test.tsx` verbatim (bun's module mocks are
process-wide). Fixture churn: `tests/useDismissedSuggestions.test.tsx`
and the `clearAcceptedDecisions` cases that constructed `"rejected"`
decisions now use accepted-only data.

## Checks

`bun run test` 719 pass / 0 fail (64 files) · `check:lint` OK ·
`check:format` OK · `typecheck` OK · `build` OK.

Closes #287
nownabe added a commit that referenced this pull request Sep 20, 2026
…#350)

## 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` (#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 #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`
(#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:
- **ADR 0002 §6** rewritten to describe materialise-at-submit as
implemented:
`SuggestionEdit` is persisted on its own `:suggestion-edits` key (400 ms
debounce, read-modify-write per path), stays "live" in the editor until
Submit, and only then becomes draft `Comment`s whose id is derived, not
minted, from `(path, baseSha, range, replacement)` (#337/#308). The
stale
"lost on reload" trade-off and the auto-save Deferred item are replaced
by
the real consequence: two persistence paths, with folding
`SuggestionEdit`
     into the Repository as the deferred work.
- **ADR 0005 §2** "already-fetched pairs are retained" deleted. A full
refresh
replaces `RemoteState` wholesale, refetching every pair; the sentence is
replaced by why that is fine (ETag `If-None-Match` on every GET, 304
costs no
     rate limit) and a pointer to the still-deferred persistent cache.
- **ADR 0001 §4 `useAppState`** — already fixed by #329; §4 is the
conflict
     policy and names no hook. Verified, no change.

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`
(#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 #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
nownabe pushed a commit that referenced this pull request Sep 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.4.0](bark-v0.3.0...bark-v0.4.0)
(2026-09-20)


### Features

* **pr:** accept .markdown and .mdx as Markdown
([#322](#322))
([e22ee68](e22ee68)),
closes [#293](#293)
* **pr:** commit fork pull requests to the fork's repository
([#342](#342))
([4e2adef](4e2adef)),
closes [#273](#273)
* **pr:** create a top-level draft Comment's Thread with it
([#323](#323))
([6e192f3](6e192f3)),
closes [#272](#272)
* **pr:** resolve out-of-diff threads via the root comment fence
([#310](#310))
([7e0ecb9](7e0ecb9)),
closes [#270](#270)
* **reanchor:** bounded region search for single-line anchors and
line-local suggestion merge
([#309](#309))
([0f735da](0f735da)),
closes [#269](#269)
* **reanchor:** locate multi-line anchors per endpoint in the region
search ([#347](#347))
([f4fd457](f4fd457)),
closes [#311](#311)
* **review:** preview the merge for shifted suggestions in the editor
([#354](#354))
([f822f41](f822f41)),
closes [#312](#312)


### Bug Fixes

* **anchor:** define anchor.quote as the source text at anchor.range
([#327](#327))
([11a935d](11a935d)),
closes [#276](#276)
* **background:** focus an existing review tab instead of opening a
second one ([#325](#325))
([58efa63](58efa63)),
closes [#277](#277)
* **pr:** compose the quote and permalink for every out-of-diff post
([#351](#351))
([f85b99b](f85b99b)),
closes [#282](#282)
* **pr:** count patch lines starting with ++ or -- in parseRightRanges
([#314](#314))
([9dfbd46](9dfbd46)),
closes [#284](#284)
* **pr:** keep the rel=next link in the ETag cache so 304 pages still
paginate ([#318](#318))
([6472de2](6472de2)),
closes [#286](#286)
* **pr:** offer Resolve only when GitHub would accept it
([#335](#335))
([b05fdcc](b05fdcc)),
closes [#274](#274)
* **pr:** park a failed resolve toggle in synced, not draft
([#320](#320))
([56e815b](56e815b)),
closes [#275](#275)
* **pr:** post drafts in the current head's coordinates
([#303](#303))
([28ef345](28ef345))
* **pr:** recover comments stuck in syncing instead of re-posting them
([#305](#305))
([3548086](3548086))
* **pr:** refuse commits to a merged or closed PR
([#330](#330))
([2a239ff](2a239ff)),
closes [#288](#288)
* **pr:** refuse to submit a draft whose quoted text changed upstream
([#346](#346))
([d4118a4](d4118a4)),
closes [#313](#313)
* **pr:** route replies on the parent's GitHub object kind
([#326](#326))
([1df6462](1df6462)),
closes [#285](#285)
* **pr:** serialise refresh and execution under one Repository lock
([#336](#336))
([1864488](1864488)),
closes [#281](#281)
* **pr:** sweep entities left syncing at the end of a submit
([#331](#331))
([108caa9](108caa9)),
closes [#271](#271)
* **release:** pin publish-browser-extension to ^4.0.5
([#263](#263))
([b77104f](b77104f))
* **review:** derive a suggestion draft's cid from the hunk it
materialises ([#337](#337))
([963339d](963339d)),
closes [#308](#308)
* **review:** end a whole-line selection on the line it actually covers
([#319](#319))
([3364d18](3364d18)),
closes [#291](#291)
* **review:** map comment positions between head and edited coordinates
([#348](#348))
([9465718](9465718)),
closes [#283](#283)
* **review:** reject a suggestion by resolving its thread on GitHub
([#340](#340))
([d088a8d](d088a8d)),
closes [#287](#287)
* **review:** resolve accepted-suggestion threads only after the commit
lands ([#341](#341))
([770f901](770f901)),
closes [#278](#278)
* **review:** surface failed comment posts and keep the reviewer's edits
([#307](#307))
([48cb675](48cb675))
* **review:** validate the PR number from the review URL
([#321](#321))
([457a942](457a942)),
closes [#295](#295)
* **storage:** bound chrome.storage.local growth and stop quota errors
losing drafts ([#332](#332))
([1f96120](1f96120)),
closes [#289](#289)
* **suggest:** consume a longer closing fence instead of leaking a
backtick ([#316](#316))
([d2e0683](d2e0683)),
closes [#290](#290)


### Performance Improvements

* **reanchor:** replace the LCS table with a memoised line-level Myers
diff ([#344](#344))
([8caebdd](8caebdd)),
closes [#280](#280)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please-nownabe-bark[bot] <295690643+release-please-nownabe-bark[bot]@users.noreply.github.com>
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.

[High] Out-of-diff threads have no resolution mechanism since event markers were removed

1 participant