Skip to content

fix(memory): stop treating thematic breaks as instruction units - #213

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
Pantoria:fix/192-thematic-break-units
Oct 15, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
Pantoria:fix/192-thematic-break-units

Conversation

@Pantoria

@Pantoria Pantoria commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fix issue #192: a thematic-break-only line (---, **, ___) was parsed as an instruction unit by parseMemoryUnits (src/memory.js), inflating the status instruction count, getting an AG id in the analysis index, and showing as a similarity-1.00 cross-surface overlap against skills that also contain ---. The user (issue author, Pantoria) asked to implement their own ready-for-pr backpass issues, each in its own worktree and PR. Follow AGENTS.md invariants and VISION.md. No live model calls were made while implementing.
Change: CommonMark thematic breaks outside fences (3+ of the same -/
/_ char, optional internal spaces/tabs, up to 3 leading spaces) are not units and flush the current unit. Maintainer cautions honored: '- item' list items stay units, and --- inside fenced blocks stays content. Deliberate decision: a dash-only line directly under a plain paragraph is a setext H2 underline as in CommonMark, so the paragraph becomes the section name like a ## heading (neither is a unit); under a list item, quote, or fence it is an ordinary break; *** and ___ never underline. ANALYSIS_INDEX_VERSION bumped 3->4 deliberately, per the AGENTS.md rule, because analysis evidence stores positional AG ids validated by sanitizeEvidence and the cache key (memory content hash) would not change when only the parser does - so cached evidence on files containing --- would otherwise cite shifted ids. Rejection instructionIds are content hashes and stay valid. Out of scope: === setext and 1-2 dash underlines.

What Changed

  • parseMemoryUnits (src/memory.js) uses a new exported THEMATIC_BREAK pattern (CommonMark: 3 or more of the same -, * or _, optional internal spaces or tabs, up to 3 leading spaces). A break line outside a fence is no longer an instruction unit and ends the current unit. A dash-only line directly under a plain paragraph is now read as a setext H2 underline, so that paragraph becomes the section heading. Under a list item, a quote, or a fenced line it stays an ordinary break, and *** / ___ never act as underlines. - item list items still count as units, and --- inside fences stays content.
  • splitRemovalHunk (src/workspace.js) keeps a setext title and its dash underline with the content they introduce, the same way it handles ATX headings. It skips plain thematic breaks when looking for a heading's content.
  • ANALYSIS_INDEX_VERSION goes from 3 to 4 (src/state.js). Cached analysis evidence uses positional AG ids, and those ids shift for files that contain ---, so old cache entries are invalidated. Covered by the new test/memory-units.test.js plus new cases in test/status.test.js and test/workspace.test.js.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The parser fix is small, matches the stated intent and bumps ANALYSIS_INDEX_VERSION correctly, but the setext-heading behavior removes a unit boundary that splitRemovalHunk relied on, so an extraction can now split a heading from its content.

Testing

I ran the real backpass status CLI, in both text and JSON form, on a throwaway git repo with an isolated home directory, once at the base commit and once at the target commit. The target no longer counts ---, *** or _ _ _ lines as instructions (10 → 6) and drops the false similarity-1.00 skill overlaps. List items, content inside fences and setext sections behave as the intent describes. Adversarial edge-case files were parsed at both commits. The removal-split guard and the analysis-index version bump can only be reached through stages that call a model, so they are marked untested live. Offline checks of both passed: direct function calls, plus the three focused test files (43/43). The temporary files were removed.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
User runs backpass status on an AGENTS.md containing ---, *** and _ _ _ breaks; the instruction count no longer counts the breaks ✅ pass live ~/.no-mistakes/evidence/01M503RN2X4TE17RKBGZ6T3XDP/status-before-after.txt (base: 10 instructions, target: 6 instructions; --json budgets[0].instructions=6)
User runs backpass status with a skill whose frontmatter/body contains ---; no similarity-1.00 CROSS-SURFACE line is reported for a break ✅ pass live status-before-after.txt: base printed 'AG-002 restates demo body · similarity 1.00' (AG-002 = '---'); target prints no CROSS-SURFACE section; --json crossSurfaceDuplicates=[]
Adversarial: '- item' and '* item' list items stay units, --- / *** inside ``` or ~~~ fences stays content, and a 4-space-indented ---- is not treated as a break ✅ pass live ~/.no-mistakes/evidence/01M503RN2X4TE17RKBGZ6T3XDP/edge-cases-units.txt and status-before-after.txt (fence unit '\n---\n' kept; list items AG-002/003 kept)
Setext decision: 'Release steps\n---' turns the paragraph into a section name. --- under a list item or quote, and *** or ___ under a paragraph, act as ordinary breaks ✅ pass live status-before-after.txt (target unit 'Tag the commit before release.' in section [Guide > Release steps]); edge-cases-units.txt (list/quote/paragraph units are separated rather than merged as at base)
Removal-hunk split guard: a setext title stays with its section, a plain break does not tie an extraction to a later deletion, and an ATX heading followed by a break is not orphaned ⏸️ untested no The prior payload did not establish a live result. This path only runs inside propose/apply after a synthesis model call, and live model calls were out of scope here (no acpx/model access allowed by u…
Cached analysis evidence from before the parser change is invalidated (ANALYSIS_INDEX_VERSION 3->4) ⏸️ untested no The prior payload did not establish a live result. Creating real cached evidence needs a live backpass analyze model call through acpx, which was out of scope (no live model calls). It was only chec…
Evidence: status before/after (base vs target CLI transcript)
$ cat AGENTS.md
     1	# Guide
     2	
     3	Run the linter before you commit.
     4	
     5	---
     6	
     7	## Tests
     8	
     9	- Run the unit tests with `make test`.
    10	- Keep fixtures small.
    11	
    12	***
    13	
    14	Keep commits small.
    15	
    16	 _ _ _
    17	
    18	Release steps
    19	---
    20	
    21	Tag the commit before release.
    22	
    23	## Fences
    24	
    25	`` `
    26	---
    27	`` `

$ cat .agents/skills/demo/SKILL.md
---
name: demo
description: Use when releasing.
---

# Release

Write the changelog entry.

---

Push the tag.

===== base commit: backpass status
repo /tmp/bp-test.QGqs/repo

BUDGET (always-loaded)
  AGENTS.md + skill descriptions [................................] 63 / 5,000 tok · 10 instructions
  overflow: 1 skill(s) in .agents/skills · 28 tok on trigger, 5 tok always loaded

CROSS-SURFACE (report-only)
  AG-002 restates demo body · 1 tok · similarity 1.00 · body loads on trigger; weigh placement
  AG-010 restates demo body · 3 tok · similarity 1.00 · body loads on trigger; weigh placement

--- parsed units (base)
AG-001	L3-3	[Guide]	"Run the linter before you commit."
AG-002	L5-5	[Guide]	"---"
AG-003	L9-9	[Guide > Tests]	"- Run the unit tests with `make test`."
AG-004	L10-10	[Guide > Tests]	"- Keep fixtures small."
AG-005	L12-12	[Guide > Tests]	"***"
AG-006	L14-14	[Guide > Tests]	"Keep commits small."
AG-007	L16-16	[Guide > Tests]	" _ _ _"
AG-008	L18-19	[Guide > Tests]	"Release steps\n---"
AG-009	L21-21	[Guide > Tests]	"Tag the commit before release."
AG-010	L25-27	[Guide > Fences]	"`` `\n---\n`` `"

===== target commit: backpass status
repo /tmp/bp-test.QGqs/repo

BUDGET (always-loaded)
  AGENTS.md + skill descriptions [................................] 63 / 5,000 tok · 6 instructions
  overflow: 1 skill(s) in .agents/skills · 28 tok on trigger, 5 tok always loaded

CACHE
  scan cache      0 file(s) fingerprinted
  evidence        0 ok · 0 skipped · 0 failed
  rejections      0 remembered
--- parsed units (target)
AG-001	L3-3	[Guide]	"Run the linter before you commit."
AG-002	L9-9	[Guide > Tests]	"- Run the unit tests with `make test`."
AG-003	L10-10	[Guide > Tests]	"- Keep fixtures small."
AG-004	L14-14	[Guide > Tests]	"Keep commits small."
AG-005	L21-21	[Guide > Release steps]	"Tag the commit before release."
AG-006	L25-27	[Guide > Fences]	"`` `\n---\n`` `"
Evidence: edge-case unit parsing (lists, quotes, fences, *** / ___)
     1	# Edge
     2	
     3	- first item
     4	---
     5	> quoted rule
     6	---
     7	Plain para
     8	***
     9	Another para
    10	___
    11	* * *
    12	- - -
    13	    ----
    14	~~~
    15	***
    16	~~~
    17	- item stays
    18	* star item stays

     1	# Edge
     2	
     3	    ----
     4	
     5	~~~
     6	***
     7	~~~
     8	
     9	- item stays
    10	* star item stays
    11	- ---
===== base
AG-001	L3-10	[Edge]	"- first item\n---\n> quoted rule\n---\nPlain para\n***\nAnother para\n___"
AG-002	L11-11	[Edge]	"* * *"
AG-003	L12-16	[Edge]	"- - -\n    ----\n~~~\n***\n~~~"
AG-004	L17-17	[Edge]	"- item stays"
AG-005	L18-18	[Edge]	"* star item stays"
---
AG-001	L3-3	[Edge]	"    ----"
AG-002	L5-7	[Edge]	"~~~\n***\n~~~"
AG-003	L9-9	[Edge]	"- item stays"
AG-004	L10-10	[Edge]	"* star item stays"
AG-005	L11-11	[Edge]	"- ---"
===== target
AG-001	L3-3	[Edge]	"- first item"
AG-002	L5-5	[Edge]	"> quoted rule"
AG-003	L7-7	[Edge]	"Plain para"
AG-004	L9-9	[Edge]	"Another para"
AG-005	L13-18	[Edge]	"    ----\n~~~\n***\n~~~\n- item stays\n* star item stays"
---
AG-001	L3-3	[Edge]	"    ----"
AG-002	L5-7	[Edge]	"~~~\n***\n~~~"
AG-003	L9-9	[Edge]	"- item stays"
AG-004	L10-10	[Edge]	"* star item stays"
Evidence: splitRemovalHunk review cases base vs target
== /tmp/bp-test.QGqs/base
setext title + its section (expect null: keep together):
   null
plain break before stale deletion (expect split):
   [{"text":"Tag the commit before release.\n\n---\n"},{"text":"\nDrop this stale note.\n\n"}]
ATX heading, break, extracted content (expect null):
   null
== ~/.no-mistakes/worktrees/8ce6865cb38e/01M503RN2X4TE17RKBGZ6T3XDP
setext title + its section (expect null: keep together):
   null
plain break before stale deletion (expect split):
   [{"text":"Tag the commit before release.\n\n---\n"},{"text":"\nDrop this stale note.\n\n"}]
ATX heading, break, extracted content (expect null):
   null
Evidence: analysis index version invalidation
base version 3 -> target 4
v3 evidence fresh under target (same memory hash): false

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ src/memory.js:112 - Setext headings now leave splitRemovalHunk (src/workspace.js:404-421) unguarded, so an extraction can separate a heading from its content. Before this change, Release steps\n--- was one unit, and the unit-kind check returned null whenever its lines had mixed kinds. With the setext branch (src/memory.js:112-125), the title line and its underline belong to no unit. The heading/content guard at src/workspace.js:416-421 only recognizes ATX # headings, so nothing else catches this. Verified: with old text # Guide\n\nKeep it small.\n\nRelease steps\n---\n\nTag the commit.\n\n## Other..., a created skill ---\nname: release\n...\n---\n\n# Release\n\nTag the commit. and a removal hunk over lines 5-9, the merged hunk is now split into two decisions: Release steps\n (deleted) and ---\n\nTag the commit.\n\n (recovered). The old parser kept them as one hunk. Every created SKILL.md's frontmatter contributes --- to the recovered counts, which makes the mismatch easy to hit. If the user accepts only the extraction, Release steps is left as an orphan paragraph. Fix: extend the heading/content guard in splitRemovalHunk to treat a setext title plus its --- underline as a heading, e.g. require the title line, the underline and the next content line to share one kind. Alternatively, expose heading spans from parseMemoryUnits so this check doesn't re-derive them.
  • ℹ️ src/memory.js:113 - The setext check only looks at buffer[0]. A paragraph whose later line starts a list item (the parser keeps it in the same buffer because only a list-item buffer[0] flushes) is turned into a heading as a whole, e.g. Intro\n- item\n--- becomes the section Intro - item. In CommonMark, the list item interrupts the paragraph, so the --- would be a thematic break. This is a rare edge case, and the old parser already merged these lines into one unit, so it is noted only.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ src/memory.js:113 - The setext check only looks at buffer[0]. A paragraph whose later line starts a list item (the parser keeps it in the same buffer because only a list-item buffer[0] flushes) is turned into a heading as a whole, e.g. Intro\n- item\n--- becomes the section Intro - item. In CommonMark, the list item interrupts the paragraph, so the --- would be a thematic break. This is a rare edge case, and the old parser already merged these lines into one unit, so it is noted only.
  • ⚠️ src/workspace.js:418 - Round 1's fix fixed the setext case but made the guard too broad. It now treats every non-blank line outside a unit as a heading that must share a kind with the next unit. That includes plain thematic breaks, which introduce nothing, so splitting now fails in the common case this change creates. Every created SKILL.md's frontmatter adds two --- lines to recovered, so a --- separator in the memory file usually counts as "recovered". When that break directly precedes a deleted paragraph or list item, the guard returns null and the extraction and the unrelated deletion merge back into one decision. Verified on the current code: old text # Guide\n\nKeep it small.\n\nTag the commit before release.\n\n---\n\nDrop this stale note.\n\n## Other\n\nStay.\n, a skill containing Tag the commit before release., and hunk 5-10 gives null. At the base commit, --- was a single-line unit, and at feaf96a it was ignored by the ATX-only guard, so both split this into [recovered, deleted]. The same thing happens for - a\n---\n- b, where a break follows a list item. A related case: an ATX heading directly followed by --- (## X\n---) is now one block that must share a kind, so it also refuses to split. Minimal fix: apply the guard only to heading blocks, meaning ATX # lines or a block of two or more lines ending in a dash-only setext underline. Skip a block that is a lone thematic break, which preserves the base splitting behavior. This defect is in code added by the round-1 fix for review-1.

🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:

  • ℹ️ src/memory.js:113 - The setext check only looks at buffer[0]. A paragraph whose later line starts a list item (the parser keeps it in the same buffer because only a list-item buffer[0] flushes) is turned into a heading as a whole, e.g. Intro\n- item\n--- becomes the section Intro - item. In CommonMark, the list item interrupts the paragraph, so the --- would be a thematic break. This is a rare edge case, and the old parser already merged these lines into one unit, so it is noted only.
  • ⚠️ src/workspace.js:418 - Round 1's fix fixed the setext case but made the guard too broad. It now treats every non-blank line outside a unit as a heading that must share a kind with the next unit. That includes plain thematic breaks, which introduce nothing, so splitting now fails in the common case this change creates. Every created SKILL.md's frontmatter adds two --- lines to recovered, so a --- separator in the memory file usually counts as "recovered". When that break directly precedes a deleted paragraph or list item, the guard returns null and the extraction and the unrelated deletion merge back into one decision. Verified on the current code: old text # Guide\n\nKeep it small.\n\nTag the commit before release.\n\n---\n\nDrop this stale note.\n\n## Other\n\nStay.\n, a skill containing Tag the commit before release., and hunk 5-10 gives null. At the base commit, --- was a single-line unit, and at feaf96a it was ignored by the ATX-only guard, so both split this into [recovered, deleted]. The same thing happens for - a\n---\n- b, where a break follows a list item. A related case: an ATX heading directly followed by --- (## X\n---) is now one block that must share a kind, so it also refuses to split. Minimal fix: apply the guard only to heading blocks, meaning ATX # lines or a block of two or more lines ending in a dash-only setext underline. Skip a block that is a lone thematic break, which preserves the base splitting behavior. This defect is in code added by the round-1 fix for review-1.
  • ⚠️ src/workspace.js:436 - The round-2 narrowing (which fixed review-r2-1) introduced a regression: an ATX heading can now be split from its content when a thematic break sits between them. For an ATX heading, contentLine is the next non-blank line in the hunk. When that line is a ---/*** break, the break is no longer a unit (this change's purpose), so !unitLines.has(contentLine) hits continue and the heading is never compared with the content that follows the break. The break line itself also fails isSetextTitle(lineNo - 1) because the line before it is ATX, so nothing guards the pair.

Verified on HEAD: old text # Guide\n\nKeep it small.\n\n## Notes\n---\n\nTag the commit before release.\n\n## Other\n\nStay.\n, a created skill ---\nname: release\n...\n---\n\n# Release\n\nTag the commit before release.\n, and hunk 5-9 return ["## Notes\n", "---\n\nTag the commit before release.\n\n"]. That splits the deleted heading from its extracted section. If the user accepts only the extraction, ## Notes is left as an orphan heading over ## Other. At the base commit, --- was a unit whose kind (recovered) differed from the heading (deleted), so the result was null; at feaf96a the ATX guard compared against the next non-blank line, also giving null. The ## X\n\n---\n\ncontent layout follows the same path.

The round-2 test afterHeading (test/workspace.test.js) only covers a heading the skill also contains, so it passes either way. Fix: when looking for an ATX heading's contentLine (and a setext underline's, same loop), skip lines that match THEMATIC_BREAK, so the heading is compared with the first real unit line after it. Add the case above to the test, expecting null.

🔧 Fix applied.
1 info still open:

  • ℹ️ src/memory.js:113 - The setext check only looks at buffer[0]. A paragraph whose later line starts a list item (the parser keeps it in the same buffer because only a list-item buffer[0] flushes) is turned into a heading as a whole, e.g. Intro\n- item\n--- becomes the section Intro - item. In CommonMark, the list item interrupts the paragraph, so the --- would be a thematic break. This is a rare edge case, and the old parser already merged these lines into one unit, so it is noted only.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
User runs backpass status on an AGENTS.md containing ---, *** and _ _ _ breaks; the instruction count no longer counts the breaks ✅ pass live ~/.no-mistakes/evidence/01M503RN2X4TE17RKBGZ6T3XDP/status-before-after.txt (base: 10 instructions, target: 6 instructions; --json budgets[0].instructions=6)
User runs backpass status with a skill whose frontmatter/body contains ---; no similarity-1.00 CROSS-SURFACE line is reported for a break ✅ pass live status-before-after.txt: base printed 'AG-002 restates demo body · similarity 1.00' (AG-002 = '---'); target prints no CROSS-SURFACE section; --json crossSurfaceDuplicates=[]
Adversarial: '- item' and '* item' list items stay units, --- / *** inside ``` or ~~~ fences stays content, and a 4-space-indented ---- is not treated as a break ✅ pass live ~/.no-mistakes/evidence/01M503RN2X4TE17RKBGZ6T3XDP/edge-cases-units.txt and status-before-after.txt (fence unit '\n---\n' kept; list items AG-002/003 kept)
Setext decision: 'Release steps\n---' turns the paragraph into a section name. --- under a list item or quote, and *** or ___ under a paragraph, act as ordinary breaks ✅ pass live status-before-after.txt (target unit 'Tag the commit before release.' in section [Guide > Release steps]); edge-cases-units.txt (list/quote/paragraph units are separated rather than merged as at base)
Removal-hunk split guard: a setext title stays with its section, a plain break does not tie an extraction to a later deletion, and an ATX heading followed by a break is not orphaned ⏸️ untested no The prior payload did not establish a live result. This path only runs inside propose/apply after a synthesis model call, and live model calls were out of scope here (no acpx/model access allowed by u…
Cached analysis evidence from before the parser change is invalidated (ANALYSIS_INDEX_VERSION 3->4) ⏸️ untested no The prior payload did not establish a live result. Creating real cached evidence needs a live backpass analyze model call through acpx, which was out of scope (no live model calls). It was only chec…
  • backpass status and backpass status --json (real CLI, isolated HOME/XDG_CONFIG_HOME, disposable git repo) at base e6a030a and target b96b4fb
  • parseMemoryUnits dump of the disposable AGENTS.md and two adversarial edge-case files at base and target
  • splitRemovalHunk run on the setext, plain-break and ATX+break review cases at base and target (offline)
  • evidenceKey/isEvidenceFresh check that v3-keyed evidence is stale under v4 (offline)
  • node --import ./test/helpers/hermetic-config.js --test test/workspace.test.js test/memory-units.test.js test/status.test.js
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Zexuan Liu and others added 4 commits October 15, 2026 11:20
A break-only line (`---`, `***`, `___` and CommonMark variants) outside a
fence was parsed as its own instruction unit, inflating the status count,
taking an AG id, and matching any skill body break as a 1.00 overlap.
parseMemoryUnits now drops such lines and flushes the current unit. A
dash run directly under a plain paragraph is treated as a setext H2
heading, as in CommonMark; under a list item, quote, or fence it stays a
break.

Positional AG ids shift for unchanged memory text, so cached evidence
would point at the wrong units: bump ANALYSIS_INDEX_VERSION to 4.

Fixes kunchenguid#192

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous command-loss issue is fixed.

Reviews (2) · Last reviewed commit: "no-mistakes(ci): Fixed Greptile finding ..." · Reviewed by Greptile

Comment thread src/memory.js Resolved
…MemoryUnits` (src/memory.js), indented code was treated as a setext heading title. Because of that, ` npm test\n---\nNext.\n` dropped the command and used it as the section name for `Next.`. Rule that must hold: a line can only be a setext title if it has at most 3 leading spaces (CommonMark). A line indented 4+ spaces or with a tab is indented code; it stays a unit, and the `---` after it is a plain thematic break. Fix: one extra condition on the setext check, `/^ {0,3}\S/.test(buffer[0])`. Checking only `buffer[0]` is enough: indented code cannot interrupt a paragraph, so if the first line is indented, the whole buffer is code. The only other place that decides what a setext title is, `isSetextTitle` in `splitRemovalHunk` (src/workspace.js), already skips any line that belongs to a unit. The indented line is now a unit, so that function picks up the fix without a separate change. I added both the space-indented example from the finding and a tab-indented one to the existing "dash run under a list item, quote, indented code, or fence is a break" test in `test/memory-units.test.js`. That test fails on the original code (7 pass, 1 fail) and passes with the fix. `pnpm run check` (lint, format, typecheck, all tests) passes: 940/940
@kunchenguid
kunchenguid merged commit d605c97 into kunchenguid:main Oct 15, 2026
5 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @Pantoria — really appreciate you taking the time on this.

@Pantoria
Pantoria deleted the fix/192-thematic-break-units branch October 16, 2026 20:02
MrGTV-love added a commit to MrGTV-love/backpass that referenced this pull request Oct 20, 2026
* fix(acpx): report acpx budget kills as timeouts, not empty-output (kunchenguid#145)

Closes kunchenguid#143.

Names acpx --timeout blank-quiet kills as timedOut on execOneShot and sessionPrompt (0.9 budget floor); leaves genuine fast blanks as empty-output; leaves synthesis openSession/prompt() alone.

* chore(main): release backpass 0.1.27 (kunchenguid#149)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(redact): stop secret redaction from eating benign tool arguments (kunchenguid#153)

* fix(redact): anchor ASSIGNMENT identifier, bound value, skip numerics

Benign telemetry names that merely contain a secret word
(max_output_tokens, prompt_tokens, token_count) no longer match:
the identifier must now end with the secret word. The value stops
at whitespace, a quote, or a comma, so comma-joined JS-literal
argument lists survive, and purely numeric values are left alone.
Genuine assignments (API_KEY=, GITHUB_TOKEN:, password=) still redact.

* no-mistakes(review): restore secret-word breadth, drop numeric redaction bypass

* no-mistakes(review): redact unterminated-quote secrets, pin value-bound tests

* no-mistakes(document): format new redaction tests, docs already accurate

* no-mistakes(document): align redact comment with final value pattern

* fix(redact): keep quoted values on one line

An unterminated quote no longer redacts across newlines: the
closed-quote alternatives exclude \n, so a truncated assignment
falls through to the bounded unquoted form and following trace
text survives.

* no-mistakes(ci): ci-4 fixed in src/redact.js. Invariant: a fully closed quoted secret value must be redacted whole, even across newlines, without a stray later quote swallowing benign prose. Change: the ASSIGNMENT pattern now tries two newline-spanning quoted alternatives first — `"([^"]{8,})"` and `'([^']{8,})'`, each gated by a lookahead `(?=[ \t]*(?:$|[,;})\]]))` with the `m` flag — before the existing single-line quoted alternatives and the bare fallback. Both quote directions (double and single) got the same edit, and the replace callback's group chain became `dqMulti ?? sqMulti ?? dq ?? sq ?? bare` so every alternative still feeds the already-redacted guard. Traced: `PASSWORD="abcdefgh\nijklmnop"` (closing quote at end of line) now masks both lines. `DB_PASSWORD="hunter2hunter2secret\nRun tests and note "done"` still fails the lookahead (the only candidate closing quote is followed by `done"`), so it falls through to the bare form and masks only the first-line value, leaving the Run-tests line visible. The single-line quoted alternatives remain reachable (e.g. `password="secretvalue" trailing words`). Comma/unterminated-quote cases from earlier rounds unchanged. Test added in test/distill.test.js next to the existing unterminated-quote case. `pnpm run check` exits 0: 692 tests pass, lint, format:check and typecheck clean

---------

Co-authored-by: firstmate <firstmate@local>

* docs: trim always-loaded agent guidance (kunchenguid#156)

* docs(agents): trim AGENTS.md to every-session invariants with pointers

AGENTS.md is loaded into every agent session. Keep only hard invariants and
orientation as short lines pointing at the source file that owns the detail.

Before: 406 lines, 4663 words, 33498 bytes. After: 87 lines, 907 words, 7001 bytes.
No detail moved to docs: every removed explanation already lives in the named
module's header/inline comments and tests. CLAUDE.md stays the @AGENTS.md pointer.

* no-mistakes(ci): Corrected AGENTS.md to state that skillSearchPaths skills are withheld from staging but remain fingerprinted, and restored the >= 20% placement table as prompt guidance rather than a buildProposal gate. pnpm run check passed (692 tests)

* chore(main): release backpass 0.1.28 (kunchenguid#155)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: train named nested memory files in monorepos (kunchenguid#159)

* test(harness-invoke): widen the signal-forwarding budget

The signal round-trip test spawns two node processes and forwards a
signal between them. Alone it finishes well under a second, but with
the whole suite running in parallel it intermittently exceeded the
2-second bound. A wrapper that swallows the signal never exits, so a
10-second bound still fails it.

* feat(memory): train nested memory files in a monorepo

Monorepos keep per-directory memory files (apps/api/AGENTS.md) that
harnesses load on top of the root file only when a session works under
that directory. backpass only trained the root file, and a nested file
listed in memoryFiles was misreported as a separate file to consolidate.

nestedMemoryFiles (project scope, default []) names each nested file a
human wants trained; nothing is discovered. Each named file is a weight
of its own:

- evidence: only sessions that worked under its directory, judged
  against it with the root file shown as already loaded, in its own
  state under .backpass/nested/
- attribution: deterministic, from the session cwd and the paths tool
  calls name in structured fields (plus apply_patch file headers),
  resolved against known checkouts of the repo; ssh sessions and paths
  outside every checkout stay unattributed and feed only the root file
- routing: a new instruction lands in the most specific named file
  whose directory every session behind it worked in; cross-cutting or
  unattributed evidence stays with the root file, enforced by fold and
  by a buildProposal gate on pure additions
- budget: nestedBudgetTokens (budgetTokens when unset), re-checked at
  apply against the accepted subset
- review: one proposal and one apply surface, each nested edit labeled
  with its file; the 2-session floor, verbatim evidence, and apply as
  the only writer are unchanged

The per-directory pointer model matches the root: a sibling CLAUDE.md
that imports the nested AGENTS.md is fine, and a nested entry that is
only a pointer is refused by name. --target on a nested file is refused
and --memory-file runs never train nested files. With nestedMemoryFiles
unset, runs are unchanged.

Closes kunchenguid#158

* no-mistakes(review): Fix nested evidence routing and per-directory memory checks

* no-mistakes(review): Correct nested attribution for tool paths and cwd

* no-mistakes(review): Guard nested apply scope and independent budgets

* no-mistakes(review): Allow nested proposals past unchanged over-budget roots

* no-mistakes(review): Share root-owned gap decisions with nested passes

* no-mistakes(test): Document root-owned gap route type in foldEvidence

* no-mistakes(document): Clarify nested targeting and apply scope in README

* no-mistakes(review): Require nested synthesis before exempting root budget

* no-mistakes(document): Clarify nested memory budgets and skipped training

* no-mistakes(review): Fix mixed-edit routing and relative path attribution

* no-mistakes(review): Protect named memory files during synthesis

* no-mistakes(review): Include nested ancestors in analysis context and hash

* no-mistakes(test): Fix tuple typing and formatting; focused tests pass, checks prohibited

* no-mistakes(test): Adjust nested formatting; focused tests pass, formatter verification prohibited

* no-mistakes(document): Clarify nested memory documentation and pass lint checks

* doc: Revise explanation of AGENTS.md and backpass functionality

Updated README to clarify the role of AGENTS.md and backpass.

* doc: Update README to include skills in backpass description

* fix(discovery): include Hermes TUI sessions with absolute cwd (kunchenguid#146)

* fix(hermes): discover TUI sessions with absolute cwd

* no-mistakes(document): Confirm Hermes documentation and format changed test

* feat(apply): keep reworded rejected edits suppressed and record optional reject reasons (kunchenguid#162)

* feat: remember rejected gaps and instruction units across rewordings

Rejecting an add, rewrite, or remove now stores measured gap and
instruction identities so a later proposal of the same decision in
different bytes stays suppressed until more sessions arrive. Extract
and move stay hunk-key only. The browser apply surface can attach an
optional reason; terminal review does not prompt for one.

* no-mistakes(review): Key rejections on unit hashes and absorbed gap aliases

* chore(main): release backpass 0.1.29 (kunchenguid#160)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* docs: trim trailing space in README (kunchenguid#170)

Prettier format:check fails on main because the scientific rigor
sentence has a trailing space after the period.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

* test: isolate the suite's config home and temp fixtures per test process (kunchenguid#167)

* test: isolate the suite from the developer's personal config home

loadConfig layers $XDG_CONFIG_HOME/backpass/config.json under every run, and
the suite never set XDG_CONFIG_HOME, so a contributor with personal ladders in
~/.config/backpass/config.json saw 14 failures in agents.test.js and
config.test.js (0 with an empty config home). A setup module loaded with
--import gives every test process an empty config home of its own; tests
that need one still set and restore XDG_CONFIG_HOME themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* no-mistakes(ci): I fixed the Greptile P2 in `test/helpers/hermetic-config.js`, following your instructions. Before this, the temporary config home was only removed on a normal `exit`, so a test run stopped with SIGINT or SIGTERM left it behind in the temp directory. **Change:** the existing `exit` cleanup is unchanged, now through a shared `removeConfigHome` function. I added one `process.once` listener each for SIGINT and SIGTERM. When a signal arrives, the listener: - deletes the directory (recursive, force, and any error is ignored); - removes its own listeners for both signals; - re-sends the same signal with `process.kill(process.pid, signal)`, so the process still ends the normal way for that signal. Every process that loads the helper through `--import` gets this, and nothing else changed. **Verification:** - **Signals:** I started a process with the helper loaded, checked its config directory existed, then sent it a signal. After SIGTERM it exited with 143 and the directory was gone; after SIGINT it exited with 130 and the directory was gone. - **Tests:** `npm test` passed 738 of 738, with 0 failed and 0 cancelled. - **Lint, types, formatting:** eslint and `tsc --noEmit` pass, and prettier passes on the changed file. - **`pnpm run check`:** this still fails at `format:check`, but only on `README.md`, which this change doesn't touch. Open PR kunchenguid#166 already fixes that file. I have not committed the change; it is left in the worktree for the pipeline

* test: give each test process its own temp root so fixtures stop leaking

Tests create fixtures with fs.mkdtempSync(os.tmpdir()) and never remove them:
a full run left about 1,275 backpass-* directories (~130 MiB) in the system
temp dir, over 10,000 after a day of runs. The hermetic helper now points
TMPDIR (read by os.tmpdir() on every call, inherited by spawned CLI children)
at one per-process root and removes it on exit, SIGINT and SIGTERM. The config
home moves inside that root. Full suite 743/743 and 0 directories left behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: make the temp-root cleanup best-effort and survive read-only fixtures

Now that one root holds every fixture, a test that fails before restoring a
0o555 directory (apply-cli, proposal, user-apply tests) made rmSync throw
EACCES inside the exit listener: exit 1, an unrelated stack trace, and the
root left behind. Removal now restores write permission and retries, and never
throws from exit or signal handlers. Old vs new on that scenario: exit 1 +
stack + root left, vs exit 0 + clean + removed. Full suite 743/743, 0 leaked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(acpx): retry timed-out adapter verification instead of aborting the run (kunchenguid#168)

* fix(acpx): a timed-out adapter-config check fails the call, not the run

verifyHarnessInvocation read a timed-out `acpx config show` (code null) as a
permanent verification failure and raised a UserError, which analyze.js
rethrows: one slow node start on a loaded host (load average ~30) rejected the
analysis pool at 23/100 with advice to upgrade acpx. A timeout says nothing
about the adapter map, so it is now handled before generic exits: retried once
with three times the budget, then raised as a timed-out AcpxError, which the
analysis stage records per transcript and retries on the next run. The budget
is injectable (verifyTimeoutMs) so the tests do not wait on real timeouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* no-mistakes(review): Let pinned agents' timed-out acpx errors propagate unchanged

* no-mistakes(review): Print a retry hint for timed-out harness calls

* no-mistakes(review): Give verify timeouts their own accurate CLI hint

* no-mistakes(test): Isolate agents tests from host XDG config ladders

* no-mistakes(document): Strip trailing README whitespace failing format check

* no-mistakes(ci): Fixed Greptile finding ci-1 in AgentResolver.withFallthrough (src/agents.js), as the user instructed. The invariant: a timed-out AcpxError always propagates unchanged. It is never classified, demoted, or retried, for pinned and auto-picked agents alike. This matches the AGENTS.md rule that a timeout is never cached as a negative probe. Before the fix, a timeout whose stderr contained 'AUTH_REQUIRED' was classified as 'unauthenticated'. For a pinned pick, demote() returned false without throwing, so the loop called the same harness again with no end. For an auto-picked pick, the agent was demoted and written to the cache as a negative probe. The fix is one shared check at the top of the catch: `if (isAcpxError && err.timedOut) throw err;`. After that, the pinned conversion is back to plain `if (isAcpxError && pick.pinned)`, with the old `!err.timedOut` guard removed. All non-timeout pinned conversions (classifiable verdicts and 'failed unexpectedly') behave as before. The doc comment now says this. Tests added in test/agents.test.js: 1. A pinned synthesis pick whose fn throws a timed-out AcpxError with stderr 'AUTH_REQUIRED' rejects with that same error, and fn is called exactly once. 2. An auto-picked analysis candidate given the same error rejects with it once and is not demoted: resolve() still returns pi. Verification: - With src/agents.js reverted to the old code, the agents test file never finished inside 60s. That is the endless loop the finding describes. - With the fix, agents + config tests pass 52/52 under an isolated XDG_CONFIG_HOME. Lint, format:check and typecheck all exit 0. - Full `pnpm run check`: 741/743 pass. The 2 config.test.js failures come from this host's user config (~/.config/backpass sets a gpt-6-luna ladder), not from this PR: they fail identically with both changed files stashed and pass with an isolated XDG_CONFIG_HOME. - In a re-run under the isolated config home, the only failing test was gap-domain-cli ('an orchestration gap is counted…'). It exited 143 (SIGTERM after 30s) at host load average about 30, and passes 3/3 when run alone. That is host load, not this change. Changes are left uncommitted in the worktree for the outer executor

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* ci: add restricted workflow_dispatch path to republish npm 0.1.29 (kunchenguid#172)

Allow a one-off trusted-publishing republish of the already-tagged
backpass@0.1.29 release without bumping the version or creating a new
release-please release.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

* chore(main): release backpass 0.1.30 (kunchenguid#171)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(agents): treat "does not support this model" as model-unavailable (kunchenguid#185)

* fix(agents): fall through when the harness is too old for the model

An adapter can advertise a model that its bundled harness cannot call.
The provider then rejects the first prompt with "does not support this
model". Classify it as model-unavailable so withFallthrough demotes the
candidate, caches the negative verdict, and tries the next rung.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(agents): label model-unavailable as "model not available"

The verdict now also covers a listed model that the harness is too old
to call, so "model not advertised" was wrong for that case.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: zxliu <zxliu@scientechresearch.io>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: isolate SQLite session raw transcripts and reclaim expired files (kunchenguid#178)

* fix(analyze): give a SQLite-store session a raw transcript of its own

The distilled trace ends with the raw transcript the analysis agent may
open when a claim needs the full text. For a file-backed store that is
the session's own file, and a session fetched over ssh already reads
from a cached file of its own events. For a local SQLite store (opencode,
hermes, cursor IDE) it was the store's path: one database holding every
session of every repository.

On a real run with an effortful model the analysis agent followed that
pointer and wrote SQL against a 560 MB OpenCode store to find its
session, turning minute-long calls into ones that hit the timeout - and
the database it was handed let it read sessions this repository never
associated.

For the length of the call, a local SQLite session now gets a file of
its own normalized events, one per line, under `.backpass/raw/` (mode
0600), and that is what the trace footer names. The file is removed when
the call returns, whatever the outcome. The new CLI test follows the
footer from inside a fake agent: it finds only that session's events,
never the database or another session, and the file is gone afterwards.

* no-mistakes(review): Fix SQLite raw-file lifecycle and adapter documentation

* no-mistakes(review): Reclaim orphaned raw transcripts without deleting live analysis files

* no-mistakes(review): Reclaim reused-PID raw files while preserving active analysis files

* no-mistakes(document): Clarify raw transcript scope and documentation ownership

* no-mistakes(ci): Fixed ci-1 by removing unsafe PID-based cross-run pruning from all analysis paths. Per-call and catchable-exit cleanup remain intact; SIGKILL leftovers now require manual removal, documented in README.md. Reproduced the same-PID deletion through the CLI before fixing it. All 100 relevant tests pass, along with targeted ESLint, Prettier, TypeScript, and git diff checks

* fix(analyze): reclaim a SQLite raw file once its lease runs out

A raw file left by an uncatchable exit such as SIGKILL was never removed,
leaving an unredacted session on disk. While its call runs, analysis now
renews the file's modification time every minute, and every analysis run
removes raw files untouched for 15 minutes from the root and nested state
directories. Liveness comes from the lease, never from a PID, so a live
analysis in another PID namespace keeps its file.

* no-mistakes(review): Remove redundant worker-level raw transcript reclamation

* no-mistakes(review): Simplify raw-file identity and restore reclamation test coverage

* no-mistakes(ci): Fixed both findings. Raised raw-file reclamation to 24 hours while preserving one-minute renewal. Directory scan failures now emit one warning and skip the affected directory without aborting analysis or healthy sibling cleanup. Updated README and comments. Reproduced failures through the CLI and added regressions covering clock skew, expired leases, and directory failures across root/nested, empty/cached runs. All 47 analysis tests passed, along with targeted ESLint, Prettier, typecheck, and git diff checks

* feat: support explicit per-edit decisions in backpass apply (kunchenguid#182)

* feat(apply): take a decision vector with --decisions

A reviewer who decided somewhere else, or a script someone chose to
trust with their own repo, had no way to hand apply its decisions: the
review surface needs a browser and --no-ui needs a terminal. --decisions
takes the vector the surface sends, e1=accepted e2=rejected:too-narrow,
parsed strictly so a typo writes nothing, and leaves unnamed edits
undecided. It is never a default, and every apply gate still runs.

* no-mistakes(ci): Fixed ci-1 by retaining every --decisions occurrence and validating them together through the existing strict parser. Earlier typos now stop all writes, and duplicate edit decisions across flags are refused. Updated help and README while preserving existing error messages. Added CLI regressions for invalid repeated flags, duplicate decisions, unchanged proposal/rejection state on failure, and successful combined decisions with rejection reasons. Reproduced the reported failure before the fix; afterward, all 144 relevant CLI, review-surface, scope, and writer tests passed. git diff --check passed

* fix(apply): refuse a blank --decisions vector among several

Joining repeated --decisions values let a blank one vanish next to a
valid one, so `--decisions " " --decisions "e1=accepted"` wrote e1 while
a blank vector alone is refused. Each supplied vector must now name an
edit on its own before the vectors are checked together.

* no-mistakes(document): Clarify scripted apply decisions and review defaults

* fix(state): skip unverifiable POSIX mode check for Windows user-profile state dirs (kunchenguid#195)

* fix: skip the POSIX mode read-back of the user state dir on Windows

On Windows, chmod only toggles the read-only attribute and stat always
reports 0o666, so State.ensure() could never verify 0o700 and every
user-scope command failed with "could not secure state directory ...
as mode 700 (got 666)". There, the directory's privacy comes from the
NTFS ACL it inherits from the user profile (SYSTEM, Administrators, the
user), so the read-back is skipped on win32 and kept everywhere else.

test/state-mode.test.js simulates Windows' stat and pins both sides:
the directory is accepted on win32 and still refused on other
platforms; each test goes red under the matching mutation of the guard.

Verified on Windows 11 / Node 26.7: `backpass scan --scope user`,
`status`, `analyze`, and `propose` now run end to end.

Fixes kunchenguid#115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* no-mistakes(review): {"summary": "Narrow win32 mode-check skip to in-profile state dirs, warn otherwise"}

* no-mistakes(document): docs: reflect Windows --scope user state-dir support in README

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat(discovery): support additional OpenCode stores and 2.x transcripts (kunchenguid#181)

* fix(opencode): drop backpass's own OpenCode sessions, and only those

acpx drives opencode, and opencode is on both default ladders, so every
analysis and synthesis call backpass makes through it is filed in the
opencode store under the repo's cwd - a tier-1 exact match on the next
run. Self-session detection only reads transcript files, and an
opencode store is one SQLite database, so three things went wrong:

- The file-head check read the database's first 256 KiB. Its pages hold
  every session's text, so a backpass prompt stored near the start of
  the file marked every session in the store as backpass's own, and a
  prompt stored further in was missed.
- With the head check unable to see them, backpass's own opencode
  sessions were analyzed as corpus - backpass auditing itself, which the
  self-session sentinel exists to prevent.
- Each agent probe (`acpx opencode sessions new`) leaves an empty
  session under the repo's cwd, which was listed and matched at tier 1.

The opencode listing query now reads each session's first user text
part, the part an acpx prompt lands in, and marks the row `self` when it
opens with the sentinel; discovery drops those rows and counts them in
SELF. A session with no user text at all recorded nothing and is not
listed. Discovery never reads a SQLite database as a transcript head.
The new cases in `test/self-session.test.js` put a genuine session, a
self session and a probe's empty session in one small opencode store;
they fail on all three counts before this change.

* no-mistakes(review): Keep OpenCode discovery fail-soft on malformed JSON

* no-mistakes(review): Exclude descendants of OpenCode self sessions locally and remotely

* no-mistakes(test): Preserve attachment-only OpenCode sessions while excluding empty probes

* no-mistakes(document): Clarify OpenCode session exclusions and discovery safety documentation

* no-mistakes(lint): Fix self-session assertion formatting

* no-mistakes(ci): Fixed both findings. OpenCode self detection now checks the first user message, preserving attachment-opening conversations and their descendants when later messages quote backpass prompts. Remote probes respect the adapter's explicit classification. Self ancestry is computed once per discovery instead of querying ancestors per child. Both regressions failed before the fixes and pass afterward. Verification passed: 103 relevant tests, targeted ESLint and Prettier checks, TypeScript checking, and git diff --check. The hosted Greptile check was not rerun in this phase

* feat(opencode): read OpenCode 2 stores (session_v2 and session_message)

OpenCode 2 no longer writes `session`, `message` and `part`. Its store
keeps each session in `session_v2` and the whole history as one typed
row per message in `session_message`. On a 2.x-only store the adapter's
listing query failed with `no such table: session`, so the harness was
skipped with a warning and none of those sessions could be analyzed.

The adapter now reads both layouts from the one database:

- Listing reads `session_v2`, and dates a session by its newest message:
  `session_v2.time_updated` does not move as messages arrive, so a
  session resumed today was otherwise outside every window.
- An in-place upgrade copies each 1.x session into `session_v2` under
  the same id and leaves the 1.x tables behind; a session in both is
  listed once and read from `session_v2`, where it continues. A store
  with neither table is reported as drifted instead of read as empty.
- Reading maps each message type deliberately. User and assistant turns
  keep their text, and tool calls stay in the order the model made
  them, with their text output or error message as the result. Text the
  harness injected - instruction files (the memory file itself),
  continue notices, system notices, and compaction summaries of turns
  still stored above them - never becomes a turn. A background subagent
  or shell reports back in an injected message; that completion becomes
  the result of the call that started the job. A shell command or skill
  the person ran from the prompt is kept as a call.
- A 2.x session follows the same rules as a 1.x one: it is backpass's
  own when its first user message opens with the self-session sentinel
  or it descends from such a session, and it is not listed when it has
  no messages at all.

Golden fixtures pin both layouts: `test/fixtures/opencode-v2-store.json`
and `opencode-v1-store.json` carry the DDL of real 2.0.18 and 1.18.32
stores and rows modeled field-for-field on real ones.

* no-mistakes(review): Simplify OpenCode recording detection and clean temporary test homes

* no-mistakes(ci): Fixed ci-1 in src/tui/render.js by replacing the unmeasured "1 sqlite query" claim with "sqlite store" at the shared OpenCode/Hermes rendering boundary. Reproduced the incorrect rendered output before fixing it. Updated rendering tests to cover both harnesses at three terminal widths while preserving session counts. All 23 rendering tests, targeted ESLint and Prettier checks, and git diff --check pass. Discovery behavior is unchanged

* feat(opencode): read more OpenCode stores named in personal config

A person's OpenCode sessions do not always live in the one store
backpass reads. The Windows OpenCode app, for one, keeps its store on
the Windows side, so a backpass running under WSL beside it never sees
the sessions that did the work in this distro's checkouts.

`discovery.opencodeStores` names more stores to read beside the default
one: an OpenCode data directory (holding `opencode.db`) or a database
file, such as a copy of the Windows app's store.

Why a config list, when Claude, Codex, Hermes and Pi stores are
relocated through the environment (`CLAUDE_CONFIG_DIR`, `CODEX_HOME`,
...): OpenCode's own relocation variables, `XDG_DATA_HOME` and
`OPENCODE_DB`, would reach the OpenCode that backpass runs for analysis
through acpx, which passes backpass's environment on. That OpenCode
must keep its own store and login, or its sessions would land in, and
its credentials be looked up in, the store being read. A list read only
by the adapter changes what backpass reads and nothing else, the way
`cloneRoots` and `skillSearchPaths` add places to look without changing
anything they name.

- Like `discovery.hosts`, the list is personal configuration: a
  checked-in `.backpassrc.json` that sets it is refused by name, since
  it would point every contributor's backpass at a transcript store. In
  user scope it defaults to the global file's top-level list.
- Entries are absolute (`~/` is expanded); a relative entry is refused,
  because a transcript store is not a repository path.
- Each session is read from the store that listed it. A store named
  twice (the default one again, or through a link) is read once, and a
  session id already listed from an earlier store is skipped, so a
  copied session never counts twice toward `minGapEvidence`.
- A configured store that is missing or unreadable is named in a
  warning and skipped, and the rest of the run continues. The default
  store's failure stays the harness's failure, as before.
- Remote hosts are unaffected: the probe reads each host's default
  store.

* no-mistakes(review): Restore test environment and clean up OpenCode store fixtures

* no-mistakes(review): Remove personal-only settings from project configuration example

* no-mistakes(document): Clarify OpenCode store discovery documentation

* no-mistakes(ci): Fixed all four Greptile findings: missing SQLite stores now raise named errors, notice-only 2.x sessions are excluded, attachment-only user turns survive reading and distillation, and bounded discovery filters old sessions in SQLite while preserving resumed sessions and self ancestry. Reproduced nine failing regression cases before fixing. All 113 targeted tests pass, including CLI and remote-probe coverage; ESLint, formatting, TypeScript, and git diff checks also pass

* fix: stop scheduling analysis after a fatal worker error (kunchenguid#180)

* fix(analyze): stop starting model calls once a run has failed

Per-transcript failures are recorded and the run goes on; an error that
fails the run - a pinned agent failing in a way nothing can classify,
say - propagated from one analysis worker and stopped only that one.
`Promise.all` reported the failure at once while the other workers kept
taking transcripts and making model calls in the background, and the
process only exited when the whole queue was done. On a real run with a
pinned OpenCode agent the error was printed within minutes and the
process kept analyzing for over an hour, starting a new max-effort call
every time one finished.

The pool now stops handing out transcripts after the first fatal error.
Calls already in flight finish and keep their evidence, and the first
error is rethrown once every worker has stopped, so nothing is still
running when it surfaces. The new CLI test runs two jobs over five
sessions with a pinned agent whose first call fails: before this change
all five calls ran, now only the two in flight do.

* no-mistakes(document): Document fatal analysis shutdown and evidence retention

* no-mistakes(ci): Addressed ci-1 in test/analyze-stop-on-fatal.test.js. The CLI regression now returns non-empty, trace-backed evidence and verifies after exit that the second session's persisted record has status "ok" and retains the complete evidence payload. Existing assertions still verify fatal error reporting and no queued model calls. No production changes were needed. Verification passed: 6 relevant tests, targeted ESLint and Prettier checks, and git diff --check

* chore(main): release backpass 0.1.31 (kunchenguid#186)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: recognize acpx exit code 3 as a timeout (kunchenguid#177)

* fix(acpx): name acpx's timeout exit (3) as a timeout

acpx 0.19 ends a model turn at its `--timeout` budget itself and exits
with its TIMEOUT code, 3 (`EXIT_CODES.TIMEOUT`), with only a zero-token
accounting line on stderr. backpass named a timeout only from its own
outer kill (`result.timedOut`, budget + 30s), which never fires once
acpx has exited, so the turn fell through to generic exit handling:

  error pinned analysis agent opencode (github-copilot/claude-opus-5.5)
  failed unexpectedly (acpx opencode session prompt failed (exit 3):
  [acpx] tokens: input=0 output=0 total=0)

With a pinned agent that stops the whole run after one long prompt.
Named a timeout, it is what the design already says it is: that
transcript is recorded as failed and retried next run, and the ladder
never falls through because a prompt ran long.

`ACPX_EXIT_TIMEOUT` is checked wherever `result.timedOut` is: the exec
one-shot, the session prompt, session create (so an adapter acpx gave up
starting is not reported as lacking session support), and the probe.

* no-mistakes(review): Distinguish acpx-owned timeout diagnostics from backpass budgets

* no-mistakes(review): Preserve timeout context and filter acpx accounting noise

* no-mistakes(review): Classify setup timeouts and preserve acpx error diagnostics

* no-mistakes(document): Clarify acpx timeout handling and retry documentation

* fix: prevent false session matches from Windows paths on POSIX (kunchenguid#173)

* fix(discovery): never resolve a Windows path against the POSIX cwd

A harness on Windows records `C:\work\repo` or a UNC path such as
`\\server\share\repo` (Windows tools also write `//server/share/repo`).
On macOS or Linux none of these is absolute, so `path.resolve` turned
them into a location under the process cwd - inside the checkout
backpass was started from - and every such session became a tier-1
match for whichever repo ran the scan (kunchenguid#164). The same resolution
also made a dead `C:/work/<repo-name>` a best-effort match, keyed
user-scope projects by the directory backpass ran in, and counted
Windows tool paths as in-repo work for nested memory files.

`src/discovery/paths.js` decides once whether a recorded path names a
place on this machine. Association, user-scope project keys and nested
attribution now refuse a Windows path on a POSIX host instead of
resolving it; a recorded remote still associates the session at tier 2.
On Windows the recorded spelling is already local, so nothing changes
there. The nested attribution cache version is bumped so cached
placements recompute.

Fixes kunchenguid#164

* no-mistakes(document): Clarify foreign-path handling and correct UNC safety rationale

* chore(main): release backpass 0.1.32 (kunchenguid#198)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(discovery): add opt-in OMP session discovery to the Pi adapter (kunchenguid#151)

* feat(discovery): discover omp session transcripts in the pi adapter

omp (Oh My Pi) writes the same version:3 JSONL session format as pi under
~/.omp/agent/sessions/, but prepends a fixed-width {type:"title"} record so
the {type:"session", cwd} entry is line 2, and nests subagent transcripts
one level deeper at <escaped-cwd>/<session-id>/<Name>.jsonl.

- Add ~/.omp/agent/sessions as a default nested store root (omp honors
  PI_CODING_AGENT_DIR, so an env redirect still dedupes against it).
- classify() scans the first head lines for the session entry instead of
  requiring it on line 1.
- enumerate() descends one extra level inside nested roots.
- read() accepts model_change.model as a fallback for modelId.

* fix(discovery): share OMP corroboration across subagents

* no-mistakes(review): Guard ledger id migration, narrow fold overlay, nest OMP subagents

* no-mistakes(review): Drop graft cache files, guard ledger recording aliases

* no-mistakes(review): Make shared OMP domain vote order-independent

* no-mistakes(review): Link OMP subagents by nested path, share ledger prior merge

* no-mistakes(document): Sync OMP interaction and scan-cache doc comments

* chore: ignore local Graft cache

* no-mistakes(document): Sync OMP identity docs and rewrap long comments

* feat(discovery): make OMP session collection opt-in

* no-mistakes(review): Fix OMP observer deduplication, native ownership, and descendant classification

* no-mistakes(review): Correct observer canonicalization, native attribution, and selected provenance migration

* no-mistakes(review): Fix conflicting cross-host descendant family corroboration

* no-mistakes(review): Fix copied-descendant corroboration and historical ledger provenance

* no-mistakes(review): Reconcile copied families and preserve validated evidence provenance

* no-mistakes(document): Correct observer documentation and format changed sources

* no-mistakes(lint): Fix regression fixture types and format affected tests

* no-mistakes(ci): Fixed ci-macos-1 in test/gap-ledger.test.js:52 by realpath-normalizing the temporary root once in harness(), matching production checkoutRoots behavior. This shared correction covers all four sibling routing consumers and keeps State paths, transcript cwd, and checkout roots consistent across macOS symlinked temporary directories. Product code, evidence semantics, and assertions are unchanged. Re-traced the failing and ordinary paths before verification. Ran node --test test/gap-ledger.test.js with TMPDIR set to the value returned by getconf DARWIN_USER_TEMP_DIR: all 49 tests passed, including both reported failures and sibling routing regressions; zero failures or skips. No pipeline-control or publication actions were performed; current-head forge verification remains with the outer executor

* refactor(proposal): leave nested-session root fallback to a separate change

Keep this branch to opt-in OMP discovery: an edit whose evidence lacks a native
session is routed as on main (the unattributed evidence is left out of ownerOf),
instead of falling back to the root memory file. The fallback moves to its own PR.

* no-mistakes(review): Refresh cached proposal interaction classification from discovery

* no-mistakes(document): Clarify OMP observer counting and cache documentation

* no-mistakes(lint): Format interaction regression test

* fix(discovery): confine OMP handling to the opt-in store and leave routing to main

With includeOmp unset, plain Pi stores now list and read exactly as on main:
the two-level walk, subagent tagging, ancestor lookup, and title-header parsing
apply only to the ~/.omp store when discovery.includeOmp is on. scan --json
omits the observer fields unless a transcript shares an observer with a parent.

Fold routing goes back to main's route.ownerOf over cluster sessions; the
incomplete-attribution root fallback and its native-ownership tests move to the
separate routing change.

* no-mistakes(review): Keep plain Pi ledger slots and main routing, drop leftovers

* no-mistakes(review): Revert unrelated acpx and gitignore hunks to main

* no-mistakes(review): Restore main's gapSource body in gap ledger

---------

Co-authored-by: mdc2122 <mdc2122@users.noreply.github.com>

* chore(main): release backpass 0.1.33 (kunchenguid#207)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(discovery): associate sessions in repos with separate git directories (kunchenguid#206)

* fix: associate sessions in repos with separate git directories

listWorktrees() now seeds its candidates with the normalized checkout
root before adding Git's reported paths, retaining the existing
deduplication. Regression tests cover exact and nested tier-1
association, strict-mode acceptance, exclusion of unrelated directories,
ordinary and linked checkout deduplication, and fallback outside a Git
repository.

Fixes kunchenguid#127

* fix: don't count a separate git dir as a worktree

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>

* chore(main): release backpass 0.1.34 (kunchenguid#208)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(memory): stop treating thematic breaks as instruction units (kunchenguid#213)

* fix(memory): skip thematic breaks when parsing instruction units

A break-only line (`---`, `***`, `___` and CommonMark variants) outside a
fence was parsed as its own instruction unit, inflating the status count,
taking an AG id, and matching any skill body break as a 1.00 overlap.
parseMemoryUnits now drops such lines and flushes the current unit. A
dash run directly under a plain paragraph is treated as a setext H2
heading, as in CommonMark; under a list item, quote, or fence it stays a
break.

Positional AG ids shift for unchanged memory text, so cached evidence
would point at the wrong units: bump ANALYSIS_INDEX_VERSION to 4.

Fixes kunchenguid#192

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* no-mistakes(review): Keep setext headings with their content when splitting removals

* no-mistakes(review): Limit split guard to ATX and setext headings

* no-mistakes(review): Skip thematic breaks when matching a heading to its content

* no-mistakes(ci): Fixed Greptile finding ci-1, as you asked. In `parseMemoryUnits` (src/memory.js), indented code was treated as a setext heading title. Because of that, ` npm test\n---\nNext.\n` dropped the command and used it as the section name for `Next.`. Rule that must hold: a line can only be a setext title if it has at most 3 leading spaces (CommonMark). A line indented 4+ spaces or with a tab is indented code; it stays a unit, and the `---` after it is a plain thematic break. Fix: one extra condition on the setext check, `/^ {0,3}\S/.test(buffer[0])`. Checking only `buffer[0]` is enough: indented code cannot interrupt a paragraph, so if the first line is indented, the whole buffer is code. The only other place that decides what a setext title is, `isSetextTitle` in `splitRemovalHunk` (src/workspace.js), already skips any line that belongs to a unit. The indented line is now a unit, so that function picks up the fix without a separate change. I added both the space-indented example from the finding and a tab-indented one to the existing "dash run under a list item, quote, indented code, or fence is a break" test in `test/memory-units.test.js`. That test fails on the original code (7 pass, 1 fail) and passes with the fix. `pnpm run check` (lint, format, typecheck, all tests) passes: 940/940

---------

Co-authored-by: Zexuan Liu <zxliu@scs336.sim>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(apply): refuse a proposal made under a different budget (kunchenguid#210)

* fix(apply): refuse a proposal made under a different budget

Apply gated the accepted subset against the budget in the current config,
not the cap the proposal was measured and gated under. A proposal made with
--budget 30000 and applied without it was judged "already over" a 10,000
cap and every addition refused; the reverse skipped the zero-sum the
proposal was held to.

Apply now compares each file an edit lands in (root and every nested file)
against the cap recorded in the proposal and, on a mismatch, refuses before
the review, naming both numbers and the remedy (re-run apply with
--budget N, or nestedBudgetTokens when it is set, or propose again). The
writer repeats the check for the accepted subset and writes nothing. A
proposal that recorded no cap is gated at the current config, as before.
The writer's nested cap now resolves through nestedBudget(), the same
helper propose uses.

Fixes kunchenguid#188

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* no-mistakes(ci): I added the test Greptile asked for; no source code changed. The bot was right that the writer's own root-budget check had no coverage. The existing root-mismatch tests in `test/apply-cli.test.js` all run the CLI, and `cmdApply` refuses before `applyDecisions` is ever called, so removing the writer's check would have left every test passing. **Invariant:** accepted edits to a file must never be gated or written under a budget different from the one the proposal was made under, and the writer (`applyDecisions`) has to enforce this by itself, not just `cmdApply`. Both files that can mismatch are now tested against the writer directly: nested files already had direct tests in `test/nested.test.js`, and the root file now has one too. **The new test** is "the writer itself refuses accepted root edits made under a different budget", in `test/apply-cli.test.js`. It builds a proposal at a 30,000-token budget, then calls `applyDecisions` directly with one edit accepted, one rejected, and the config set to 10,000. It checks that: - nothing is written, `AGENTS.md` is unchanged, and no skill directory is created; - the single failure message names the file, both numbers, and the `--budget 30000` remedy; - `rejectionsRecorded` is false and `.backpass/rejections.json` holds no entries. **Verification:** I temporarily turned the writer's check off and the new test failed; with the check back in place it passes. `pnpm run check` (lint, format, typecheck and tests) passes: 934 tests, 0 failures

---------

Co-authored-by: Zexuan Liu <zxliu@scs336.sim>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat(status): show each nested memory file's sampled-session reach (kunchenguid#209)

A nested file trains only on sessions whose every in-repo work path stays
under its directory, so in repos where sessions cross directories it may
never reach minGapEvidence, and a run that proposes nothing there looked
the same as a file with no gaps.

Each attribution now records, per nested file, how many sampled sessions
worked only under its directory (.backpass/nested/reach.json). The run
summary and `backpass status` print that count and warn below
minGapEvidence, when no add, rewrite, or remove edit can reach the file.
`status --json` reports it as nestedAttribution, and the proposal's nested
entries carry sampledSessions, minGapEvidence, and belowMinGapEvidence.
The count comes from deterministic attribution and is report-only.

Refs kunchenguid#191

Co-authored-by: Zexuan Liu <zxliu@scs336.sim>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* chore(main): release backpass 0.1.35 (kunchenguid#215)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* docs: clarify apply UI dependency (kunchenguid#216)

* fix(memory): recognize CLAUDE.md symlinks as pointers (kunchenguid#217)

* fix(memory): recognize Claude memory symlinks

* no-mistakes(document): Document canonical memory symlink resolution

* chore(main): release backpass 0.1.36 (kunchenguid#218)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(omp): accept omp as an analysis and synthesis runner

omp (Oh My Pi) is an acpx custom agent. Its model and reasoning level now travel
over acpx: --model at session create, and the ACP `thinking` session option.

- harness-invoke: omp carries model and effort through the session path; a level
  omp does not advertise (off, auto, low, high, max) is refused before any call,
  so a level is never silently downgraded. omp is not a built-in adapter, so the
  agents.<name> replacement guard does not apply to it.
- agents: resolvedEffort gives omp no default that it cannot carry (analysis
  medium). A configured level is kept as written.
- acpx: omp's session effort key is `thinking`, so an exec fallback fails loudly.
- README: one runner line for omp.

Tests cover the transport, the refusal, the loud failure, the configured-agent
acceptance, the effort default, and the probe's openai-codex route mapping.

* no-mistakes(review): Qualify omp README ids, add omp to hints, test routes

* no-mistakes(document): Update stale effort-default comment for omp

* test(agents): use neutral providers in colliding omp ladder test

Replace literal openai/ and openrouter/ ids with neutral provider names.
The test still proves the qualified ladder id resolves to itself when
the same bare model is advertised by other providers.

---------

Co-authored-by: TNTHNGVDYNND <161745519+TNTHNGVDYNND@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andrew Sweet <andrew.sweet@cantab.net>
Co-authored-by: firstmate <firstmate@local>
Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Admin Athletics mind <dev@athleticsmind.com>
Co-authored-by: Rodrigo Díaz Jonguitud <dijongui@gmail.com>
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
Co-authored-by: Kenmege <205099287+Kenmege@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Pantoria <37699442+Pantoria@users.noreply.github.com>
Co-authored-by: zxliu <zxliu@scientechresearch.io>
Co-authored-by: Pawan <pawan161096@gmail.com>
Co-authored-by: Daniel Martinez Morales <dmmdea@hotmail.com>
Co-authored-by: mdc2122 <mdc2122@users.noreply.github.com>
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Zexuan Liu <zxliu@scs336.sim>
Co-authored-by: Som Samantray <92726151+SomSamantray@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.

2 participants