Repository navigation
Conversation
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.
…cally and remotely
…xcluding empty probes
…ery safety documentation
|
…cks 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
|
Speaking as Kun's firstmate: Closing as subsumed by #181 (squash-merged as Main's OpenCode adapter already detects self from the first user text in SQLite ( Thank you @PawanAIT — really appreciate you taking the time on the safe self-exclusion path. |
Intent
Make backpass never analyze its own OpenCode sessions, and never drop a genuine one. acpx drives opencode (on both default ladders), so backpass analysis and synthesis calls land in the opencode SQLite store under the repo cwd; the file-head self check cannot see them and instead reads the database head, where one backpass prompt marks every session in the store as self. Mark self sessions from the store (first user text opens with the sentinel), never read a SQLite database as a transcript head, and do not list the empty sessions each agent probe leaves behind.
What Changed
--since.Risk Assessment
✅ Low: The change is limited to OpenCode self-session detection and the SQLite head-read bypass. Both earlier fix rounds are verified correct, the logic fails soft on corrupt rows, and behavioral tests cover the local and remote paths.
Testing
Focused self-session and probe tests passed, followed by six live scenarios using isolated CLI scans and locally executed shipped probes. Captured product outputs confirm self exclusion, genuine-session retention, and the attachment fix. Disposable data was removed; no source changes were needed.
Evidence: CLI and shipped-probe responses for all six scenarios
Evidence: Human-readable scan retaining attachment conversations
Evidence: Image-only conversation fetched through the shipped probe
Evidence: Focused regression-test output
Evidence: Reproducible isolated live-test driver
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
src/discovery/adapters/opencode.js:60- The new listing subquery usesjson_extract(m.data, '$.role')(line 60) andjson_extract(pt.data, '$.type')(line 61). In SQLite,json_extracton text that is not valid JSON throwsmalformed JSONinstead of returning NULL. I checked this with node:sqlite: the error comes through a correlated scalar subquery too. So a single corruptmessage.dataorpart.datarow in any session inside the cutoff window, including a session belonging to a different repo, makesdiscover()throw.discoverTranscriptsthen catches the error, logsopencode: transcript store unreadable ... - harness skippedand drops every genuine opencode session. The remote probe does the same through its per-harness catch. Before this change the listing never parsed JSON, andread()still parses safely withsafeJsonParse. This breaks the AGENTS.md rule that adapters stay fail-soft, and the intent's 'never drop a genuine one'. Fix: guard both calls so a bad row only drops itself, for exampleCASE WHEN json_valid(m.data) THEN json_extract(m.data, '$.role') END = 'user'and the same forpt.data. Use CASE rather than a separatejson_valid(...) ANDterm, because SQLite does not guarantee the order in which WHERE terms are evaluated.🔧 Fix applied.
2 warnings still open:
src/discovery/adapters/opencode.js:60- The new listing subquery usesjson_extract(m.data, '$.role')(line 60) andjson_extract(pt.data, '$.type')(line 61). In SQLite,json_extracton text that is not valid JSON throwsmalformed JSONinstead of returning NULL. I checked this with node:sqlite: the error comes through a correlated scalar subquery too. So a single corruptmessage.dataorpart.datarow in any session inside the cutoff window, including a session belonging to a different repo, makesdiscover()throw.discoverTranscriptsthen catches the error, logsopencode: transcript store unreadable ... - harness skippedand drops every genuine opencode session. The remote probe does the same through its per-harness catch. Before this change the listing never parsed JSON, andread()still parses safely withsafeJsonParse. This breaks the AGENTS.md rule that adapters stay fail-soft, and the intent's 'never drop a genuine one'. Fix: guard both calls so a bad row only drops itself, for exampleCASE WHEN json_valid(m.data) THEN json_extract(m.data, '$.role') END = 'user'and the same forpt.data. Use CASE rather than a separatejson_valid(...) ANDterm, because SQLite does not guarantee the order in which WHERE terms are evaluated.src/discovery/adapters/opencode.js:102- A session is markedselfonly when its own first user text part starts with the sentinel. OpenCode'stasktool creates a child session. That child hasparent_idset to the calling session and the samedirectory, and its first user text is the task prompt the model wrote, which does not carry the sentinel. Concrete sequence: backpass analysis or consolidation runsacpx opencodewith cwd set to the repo root (src/analyze.js:207,src/consolidate.js:85). The model delegates a read or exploration step to a subagent. The child session is then listed under the repo root withself: false.discoverDirect(src/discovery/index.js:300) finds no self match, becausereadHeadis false and the cwd is not under stateDir, so the child is classified non-interactive throughparent_idand analyzed. That breaks the intent's requirement "never analyze its own OpenCode sessions". Synthesis children are still caught, because their cwd sits under the stateDir staging copy. The query already selectsparent_id, so the fix stays insidediscover: carryselfdown to every descendant of a self row (for example with an id-to-self map resolved throughparent_id, or a recursive CTE, so a parent outside the cutoff window still counts). One sibling site must hold the same rule: the remote probe callsdescriptorFrom(src/discovery/remote/probe.js:72-74), which works outselfseparately from each session's ownread()events and ignoresrow.self. It should also honorrow.selffrom the adapter so remote child sessions are dropped too.🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Test** - 2 issues found → auto-fixed ✅
src/discovery/adapters/opencode.js:98- The empty-session filter silently drops genuine OpenCode sessions whose user message contains only an attachment. Reproduced with an image-only user message followed by a substantive assistant reply: the base CLI retains the session, but the changed CLI and shipped remote probe both return zero scanned sessions. The real probe fetch confirms that the session contains a nonempty assistant event. Absence of a user text part is not equivalent to an unused probe session. Separate empty-session detection from sentinel detection, preserve recorded attachment conversations, and add a behavioral regression test.TMPDIR="$PWD/.test-opencode-live/tmp" node --import ./test/helpers/hermetic-config.js --test test/self-session.test.js test/remote-bundle.test.jspassed.git archive ddf8a7b06a9d191ee696d2ae9a10683c8b1ca872 bin src package.jsonextracted a disposable base version for before/after CLI comparisons.node .test-opencode-live/drive.mjsran the realbackpass scan --harness opencode --since all --strict --jsonCLI against isolated SQLite stores, including repeated scans and--since 1dancestry checks.The same driver executed actualbuildProbeProgramdiscovery payloads throughnode -, checking mixed stores, sentinel boundaries, ancestry, corrupt JSON, and attachment-only sessions.Ranbackpass scanwithout--jsonand captured its end-user table and SELF explanation.node .test-opencode-live/verify-attachment.mjsexecuted the shipped probe fetch protocol and verified that the omitted attachment session contains a substantive assistant event.Corrected the clean-store baseline setup with SQLiteVACUUMto remove residual sentinel bytes, then reran the complete driver.Removed.test-opencode-live/after evidence collection; the worktree is unchanged.🔧 Fix applied.
✅ Re-checked - no issues remain.
node --import ./test/helpers/hermetic-config.js --test test/self-session.test.js test/remote-bundle.test.jswith isolated HOME, config, and temporary directories.node ~/.no-mistakes/evidence/01M3P941F9VZ62N5WCGSNVDGGW/round2-live-driver.mjscreated disposable OpenCode SQLite stores and exercised six scenarios.node bin/backpass.js scan --harness opencode --since all --strict --jsontwice per applicable scenario, plus--since 1dfor ancestry and cutoff validation.Executed the actual shipped probe throughnode -for discovery in every scenario and fetched the image-only conversation through its framed protocol.Captured and inspected human-readable CLI scan output, JSON responses, and the attachment conversation's fetched assistant reply.Corrected the disposable database padding setup, reran all live scenarios successfully, removed test data, and confirmed a clean worktree.✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
test/self-session.test.js:354- Prettier requires multiline formatting for assert.deepEqual. Left unchanged because this phase explicitly prohibits test edits. ESLint and TypeScript checks pass; all other checked files pass formatting.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.