Repository navigation
fix(security): date-shaped evidence reads, ownership-checked merges, redact-before-crop capture (#130 #131 #132) - #135
Conversation
|
Follow-up review of this PR at
The stack also retains #128's acknowledged evidence-read gap: a bound A session calling Validation on Windows / Bun 1.3.10 at this combined head: Please commit regressions based on these probes, make them pass, and rerun the existing suite. Probe 5 first confirms the current partial mutation as diagnostic evidence; if the fix chooses rollback instead, update that setup assertion to the intended rollback contract. Reproducible five-probe file for the combined PR #135 headSave this as import { afterEach, beforeEach, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join, resolve } from "node:path";
import { loadPlugin, type LoadedPlugin } from "./test/harness.ts";
import { appendMemory, isActive, loadAll } from "./src/memory.ts";
import { rememberSessionDir, resetSessionScopes, resolveRepo, setRepoScope } from "./src/repokey.ts";
import { resetState } from "./src/state.ts";
import { dateStr, evidenceDir, memoryRoot } from "./src/config.ts";
import { redactSecrets } from "./src/secrets.ts";
let root: string, a: string, b: string;
let plugins: LoadedPlugin[];
beforeEach(() => {
root = mkdtempSync(join(tmpdir(), "osi-review-proof-"));
a = join(root, "repo-a"); b = join(root, "repo-b");
mkdirSync(a); mkdirSync(b);
process.env.OPENCODE_MEMORY_DIR = join(root, "memory");
process.env.OPENCODE_COMMANDS_DIR = join(root, "commands");
resetState(); resetSessionScopes(); setRepoScope(null); plugins = [];
});
afterEach(async () => {
for (const p of plugins) await p.cleanup();
resetState(); resetSessionScopes(); setRepoScope(null);
delete process.env.OPENCODE_MEMORY_DIR; delete process.env.OPENCODE_COMMANDS_DIR;
if (dirname(resolve(root)) !== resolve(tmpdir()) || !basename(root).startsWith("osi-review-proof-")) {
throw new Error("Unexpected fixture cleanup path");
}
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 });
});
async function plugin(dir: string | null) {
const p = await loadPlugin(dir); plugins.push(p); return p;
}
async function seed(dir: string, content: string) {
const scope = resolveRepo(dir);
return appendMemory({ type: "context", scope: "planning", content, status: "open", repo: scope.key, repoPath: scope.path });
}
test("review #127: an unbound A session must not inherit the later B setup", async () => {
const pa = await plugin(a);
await plugin(b);
await seed(b, "B_PRIVATE_UNBOUND_SETUP_MARKER");
const event = { sessionID: "ses-a-unbound", system: [] as Array<{ type: string; text: string }> };
await pa.sessionHooks.context(event);
expect(event.system.map(p => p.text).join("\n")).not.toContain("B_PRIVATE_UNBOUND_SETUP_MARKER");
});
test("review #131: an unbound A caller must not retire B rows through the fallback Reader", async () => {
const pa = await plugin(a);
await plugin(b);
const loser = await seed(b, "B_FOREIGN_LOSER");
const survivor = await seed(b, "B_FOREIGN_SURVIVOR");
const result = await pa.tools.memory_merge_review.execute(
{ loser, survivor, reason: "unbound ownership check" }, { sessionID: "ses-a-unbound", id: "merge-a" });
expect(isActive((await loadAll()).find(m => m.ts === loser)!)).toBe(true);
expect(result.content).not.toContain("is canonical");
});
test("review #128: A must not read B's ordinary tool output through evidence", async () => {
const p = await plugin(a);
rememberSessionDir("ses-a", a); rememberSessionDir("ses-b", b);
await p.toolHooks["execute.after"]({ sessionID: "ses-b", id: "read-b", tool: "read", input: {},
result: { content: "B_CONFIDENTIAL_CUSTOMER_MIGRATION_MARKER" } });
const result = await p.tools.memory_evidence.execute({ ev: "tool_result" }, { sessionID: "ses-a", id: "evidence-a" });
expect(result.content).not.toContain("B_CONFIDENTIAL_CUSTOMER_MIGRATION_MARKER");
});
test("review #128: merge reasons must not persist recognized credentials in daily rows", async () => {
const p = await plugin(a); rememberSessionDir("ses-a", a);
const loser = await seed(a, "A_LOSER"); const survivor = await seed(a, "A_SURVIVOR");
const token = "ghp_" + "AbCdEfGhIjKlMnOpQrStUvWxYz0123456789";
expect(redactSecrets(token)).toBe("[redacted]");
const result = await p.tools.memory_merge_review.execute({ loser, survivor, reason: `rotated ${token}` }, { sessionID: "ses-a" });
expect(result.content).toContain("is canonical");
expect(readFileSync(join(evidenceDir(), `${dateStr()}.logfmt`), "utf8")).not.toContain(token);
expect(readFileSync(join(memoryRoot(), `${dateStr()}.logfmt`), "utf8")).not.toContain(token);
});
test("review PR135: an audit write failure must not claim nothing changed after a successful mutation", async () => {
const p = await plugin(a); rememberSessionDir("ses-a", a);
const loser = await seed(a, "A_LOSER"); const survivor = await seed(a, "A_SURVIVOR");
// Synthetic filesystem fault: evidence cannot be created as a directory.
writeFileSync(evidenceDir(), "fixture blocks evidence directory");
const result = await p.tools.memory_merge_review.execute({ loser, survivor, reason: "same repo" }, { sessionID: "ses-a" });
expect(isActive((await loadAll()).find(m => m.ts === loser)!)).toBe(false);
expect(result.content).not.toContain("nothing was done");
}); |
c9791ed to
b2f7ac2
Compare
abogartz
left a comment
There was a problem hiding this comment.
Review — verified empirically; approve (one body correction)
Method: detached worktrees of this branch, #133, and cf9b73c; claims re-run, not read.
Verified against the tree:
- Stacking exact: this branch = #133 +
c9791edand nothing else. - Full suite: 0 fail (530 pass / 12 skip here; total 542 = your 537 + 5).
tsc --noEmitclean;biome lint0 errors; no new unused-import warnings beyond #133's. - #130 held up under a direct probe battery against
evidenceFileFor: traversal,../<dayfile>(raw-store read),2026-02-30, month-13, fullwidth unicode digits, newline-suffix, null byte, double-slash, and a symlinked day file — all refused; legit dates resolve insideevidence/. (JS$is strict end-of-string — no Perl-style trailing-newline hole.) - #131: both seats authorize through the entry-resolved
Reader; the lock-order claim checks out — update-order → file-locks everywhere (prune/undo/decay/viewer take file locks only, never update-order, so no inversion exists);onTimeout:"fail"genuinely throws (src/lock.ts:251), so the fail-closed contract is real. - #132: redact-then-crop in place;
buildCapturePrompt's own scrub retained as defense in depth (src/capture.ts:73); the crop tests drive the real compaction hook and were red on base with the exact markers quoted.
Body correction (under-claim, not over-claim): the red-on-base list says 6 of 10; I measured 7 — "a day file symlinked out of the evidence dir is not followed" is also red on cf9b73c (it returned SYMLINKED_DAYFILE_MARKER verbatim). The "6 + 4 controls = 10" arithmetic misclassifies it as a green control. Worth fixing the evidence section so the pin list matches the tree.
Nit: the outer catch {} in merge_review maps any error (disk full, latent bug) to "the store was busy past the lock budget — retry". Fail-closed, but diagnostically misleading; consider narrowing or recording the error.
LGTM otherwise. Not merging per maintainer.
|
Investigated both failed checks for head
CI checks out merge commit A small fixture fix is to install the intentionally invalid evidence path before loading the plugin. The heartbeat failure is guarded, and the merge can then reach the intended post-mutation evidence-write failure. I tested the following change locally against the CI merge commit: the previously failing test passes (1 pass, 0 fail; 4 other tests filtered out). This is a suggested patch, not a pushed change or a claim that the full CI suite has been rerun. diff --git a/test/security-unbound-identity.test.ts b/test/security-unbound-identity.test.ts
index 5873cfe..3b9692b 100644
--- a/test/security-unbound-identity.test.ts
+++ b/test/security-unbound-identity.test.ts
@@ -200,11 +200,12 @@ test("an unbound session cannot retire another repository's rows through merge",
// response must describe what actually happened — "nothing was done" is true
// only for the lock-acquisition failure it was written for.
test("a merge whose evidence write fails reports the retirement it actually made", async () => {
- const p = await loadPlugin(a);
- plugins = [p];
- // Poison the evidence path: the merge's mutation runs, its record() throws.
+ // Install the fault before setup: the startup heartbeat now creates evidence/.
+ // Its guarded write may fail too; the merge must still report its mutation.
mkdirSync(memoryRoot(), { recursive: true });
writeFileSync(join(memoryRoot(), "evidence"), "not a directory");
+ const p = await loadPlugin(a);
+ plugins = [p];
await appendMemory({
type: "decision",
scope: "design/probe5",Progress on the review findings: all five original review probes now pass on Please fix the fixture, rerun both checks on the merged tree, and carry forward the unresolved-session evidence fix from #133 before treating the stack as ready. The PR body's statement that nothing remains deferred does not account for these new-write isolation cases. |
|
Follow-up round pushed. The branch is rebased onto #133's 1 — merge authorization for unbound callers (#127/#131). Fixed at the shared root: 2 — merge reason in the daily row (#128 follow-up). Fixed on the #133 side: 3 — the catch reporting a completed mutation as a no-op. Fixed in Evidence-read gap and closure claims. Resolved in #133 rather than split: Validation. Rebased stack: 552 pass / 5 skip / 0 fail ( |
|
@abogartz Thanks for checking the symlink case on Linux. The original ten-test accounting should distinguish 7 vulnerability regressions and 3 behavior-preservation tests on a platform that executes the symlink test. Its current Windows early return must not be counted as evidence that the old behavior was safe. Please correct that section of the PR body. A revision clarification before this approval is used as a readiness signal: the review is attached to Two remaining items are documented in the CI investigation and verified fixture-fix suggestion:
The review was submitted before those follow-up comments landed. Please include the merged-tree checks and the two new isolation cases in the final re-check. My recommendation remains to keep the stack in draft until they are resolved. |
|
Rechecked The security blocker is unchanged: I reran The fixture fix addresses the prior CI setup failure. It does not change the evidence writer/filter, so I still recommend keeping the stack in draft until the two isolation cases are fixed. Local recheck: Windows / Bun 1.3.10, 5 committed follow-up tests passed and 2 additional evidence probes failed. |
abogartz
left a comment
There was a problem hiding this comment.
Dismissing my approval of c9791ed — the branch has been rebased to 70abfec and the stack carries an open blocker:
- The two unresolved-session evidence probes (see #133's re-review) fail on this head too — inherited via
d56956e. - The rebased stack also fails
bun test ./test/on macOS/Bun 1.4.3: the twonegative-eval.test.ts"scope crossing" tests, from theinjection-framingre-bind leakingrememberSessionDir("fr-cap")+ unreset ambient state into the next test file. Minimal repro:bun test ./test/injection-framing.test.ts ./test/negative-eval.test.ts. CI (Linux/Windows) is green — order-dependent, still a gate-command failure on a supported host.
Your own two new commits here (b2f7ac2 partial-failure reporting on merge_review — which also addresses my catch {} nit's misleading-message half, and 70abfec platform-deterministic poison fixture) reviewed clean; 533 pass / 12 skip here apart from the inherited two. Will re-review the whole stack once #133's isolation fix lands.
70abfec to
b5962ae
Compare
|
Checked
Please carry the verified event-specific assertion correction from #133 into this stack, preserving the check that B cannot read A's marker, then rerun CI. Locally at unmodified The previously reported security probes are now green on the branch; final sign-off still awaits the test correction and green CI on the merged tree. |
|
Rebased onto #133's One adaptation was required and is the only content change: Test accounting corrected as requested: 7 vulnerability regressions + 3 behavior-preservation controls, with the note that the symlink case early-returns on Windows so only six of the seven execute red on this platform. The body's stacked-diff paragraph now reflects the rebased head. Full suite 554 pass / 5 skip ( |
b5962ae to
4beccfa
Compare
|
Rebased again onto #133's Why the new push: both jobs went red on the previous heads at the foreign-stamp probe only, because CI tests the merge commit and |
|
@abogartz Final recheck at
One non-blocking test-harness observation: the local crop tests emitted background The unresolved-session evidence isolation, merge ownership and post-mutation reporting, evidence-path restrictions, and redact-before-crop regressions are now green. Together with the #133 sign-off, this clears my reported blockers across the stack. Please complete the maintainer re-review/update the outstanding changes-requested reviews and draft status when satisfied. Normal stack order is #133, then #135; keep #127–#132 open until their fixes are merged. |
|
@abogartz Your changes-requested review (attached to
As offered, this is ready for the whole-stack re-review; the changes-requested state on both PRs is the only remaining blocker, and both stay draft until you sign off. #130–#132 stay open until merge. |
|
@abogartz Confirmed the new conflict at I posted the exact combined imports and verification on #133. Please update #133 first, then replay this PR's five commits on that updated base, preserving both the containment checks and the session-scoped reader. The locally resolved full stack type-checks. Its full Windows/Bun 1.3.10 run reports 576 pass / 10 skip / 16 fail; all 16 failure names also reproduce on unmodified main in the affected files (export EINVAL / host symlink permissions), with no security-suite failures in the resolved stack. No branch changes were pushed. The earlier green checks cover the old integration. Fresh Linux and Windows CI are needed after the branch update before merging. |
…redact-before-crop capture The three mediums from the 2026-10-26 security review (abogartz#130, abogartz#131, abogartz#132), each pinned by regression tests that are red on the reviewed revision (cf9b73c, 0.14.9) and green on this commit. - memory_evidence (abogartz#130): `date` is a date, not a path. A regex at the schema boundary plus evidenceFileFor() — real calendar dates only, resolved INSIDE the evidence dir, impossible dates refused rather than rolled, symlinked day files not followed — so neither `../../outside` nor `../YYYY-MM-DD` (the raw daily store, visibility filters and all) can be read. The wire pin in boundaries.test.ts records the (intentional) date pattern; the `~standard` key in that diff is a non-enumerable zod annotation present on every tool, as before. - memory_merge_review (abogartz#131): a row id is a pointer, not authority. Both seats resolve through the caller's Reader — captured at entry, never re-read after an await (abogartz#127) — and the resolve/check/mutate runs under the update-order lock memory_update serializes on (abogartz#125), so authorization is revalidated under the mutation lock. A foreign repo's row is refused in either seat (including superseded-survivor revival) with nothing mutated and no evidence written; global rows stay mergeable from anywhere, stated in the tool description instead of granted implicitly by store-wide reach. Success now also records the session the merge ran FOR. - auto-capture (abogartz#132): redact the COMPLETE transcript, THEN crop to the 8,000-char budget. Cropping first could start the window inside a credential — a PEM body whose BEGIN marker fell off, a token whose prefix fell off — and buildCapturePrompt's own scrub (kept, defense in depth) cannot recognize a fragment. The tests drive the real compaction hook and assert on the prompt actually handed to the capture model. Full suite: 537 pass / 5 skip / 0 fail; typecheck clean; `biome lint` 0 errors.
Probe 2 (unbound session retiring another repository's rows through memory_merge_review) is GREEN already at this head: the identity fix from the abogartz#133 side (entry binding, readerForSession without the module-scope fallback) resolves the caller to its own instance's repository, and the abogartz#131 ownership check then refuses both seats. Committed as the pinned acceptance case. Probe 5 is RED here: with the evidence directory poisoned, the merge retires the loser, its record() throws, and the catch — written for the lock-acquisition case — reports "nothing was done" while the row IS superseded on disk. The next commit makes the catch tell the truth about where the failure landed.
The single catch at the bottom of memory_merge_review was written for one
thrower — the fail-closed lock-budget timeout, where nothing is written
and "nothing was done" is exactly true. The evidence write below the
mutation reaches that same catch: when record() fails AFTER markSuperseded
succeeded the loser is retired on disk, yet the tool told the caller
nothing happened (review probe 5).
Track the mutation and split the report: no mutation keeps the documented
no-op contract verbatim; a mutation followed by a failed follow-up
(evidence, survivor revive) is reported PARTIAL, names the retirement
that stands, carries the failure reason, and points at memory_undo. The
rows on disk stay the source of truth either way; re-running is
idempotent ("already superseded").
CI (Bun 1.4.4, linux) reached the fixture with the evidence path under a fresh store root already occupied by a DIRECTORY, so the file-write poison threw EISDIR before the scenario ran; locally (Bun 1.3.10, windows) the path was absent at that instant and the test passed. The poison now clears whatever occupies the path inside the same synchronous block before writing, so nothing that created it earlier — host timing differs per platform — can win the race. Verified the fixture still demonstrates the bug: with the pre-fix merge handler restored (ea6cad7 src/index.ts) the probe fails on the exact dishonest "nothing was done" message and the other four pass.
…w private rule abogartz#133's a909685 made a NAMED-but-unresolved session's fresh evidence private to that session (the re-review's isolation contract). The readability control here wrote its line for an unbound ses-130 and read it context-less, so the private branch — working as designed — hid it. The control now binds ses-130 to the workspace, the shape every session that reaches a plugin instance has; the traversal, calendar and symlink doors are untouched. Full suite 554 pass / 1 fail (the known service-host e2e sandbox case, green in CI).
4beccfa to
152d613
Compare
|
Conflicted with Verification at |
|
@abogartz Rechecked
The conflict is resolved and fresh CI is green. Together with the renewed #133 sign-off, no blocker remains from my review of this stack. Both PRs remain draft pending the maintainer's final review/state update. |
|
Consolidated record, keyed to the current head: the 00:30 changes-requested review (attached to pre-rebase State: MERGEABLE on main 0.14.11, CI green (run 40574894053: test, test-windows, lint, smoke), |
|
Erratum to the local-test notes above — same three root-caused reasons a Windows full-suite run shows reds unrelated to this stack (now filed upstream as #147/#148 rather than waved at as "environment"), plus the invocation distinction that made the numbers confusing:
Invocation note: the "17 local reds" quoted here was a bare Posting the fuller breakdown on #133 for the stack-level record. |
abogartz
left a comment
There was a problem hiding this comment.
Final pass — APPROVED (supersedes my CHANGES_REQUESTED, which was purely inherited)
My blocker on this branch was the stack, not your code: the two unresolved-session evidence probes and the macOS order-dependent negative-eval break, both inherited from #133. Both are closed on #133's head, which this branch carries. Re-verified here on 152d613, macOS / Bun 1.4.3.
Stack structure matches the body exactly
git merge-base --is-ancestor pr133 pr135 → yes. git log pr133..pr135 returns precisely the five commits you list: bc9eebd, 9802cf0, 156e887, aab5537, 152d613. No undeclared commits.
Red-on-base reproduced independently
Copying this PR's three new suites onto pristine cf9b73c src: 7 fail / 3 pass — the 7 vulnerability regressions (path traversal, impossible date, symlink-not-followed, cross-repo loser, cross-repo survivor, token-straddle, PEM-straddle) red, the 3 behavior-preservation controls green on both revisions. Exactly as claimed, including the caveat about the symlink case.
#130 — the date is a date
evidenceFileFor() (src/evidence.ts:20-42) is wired as the single read path (src/index.ts:723) with the schema pattern as the first door. I ran my own bypass set against the primitive (19 hostile inputs): refused — ../../outside, ..\..\outside, ../2026-01-01, 2026-02-30, 2026-13-01, 2026-00-10, 2026-10-32, 2026-10-00, 0000-01-01 (the Date.UTC 2-digit-year folding to 1900 is caught by the round-trip check), 2026-10-28\n ($ without /m), 2026-10-28.logfmt, 2026-10-28\0.evil, full-width digits, non-padded, empty. Accepted: 2026-10-28, 2024-02-29, 1999-12-31. A day file symlinked out of the evidence dir is refused via realpath containment.
#131 — a row id is not authority
Both seats authorize through the entry-captured Reader (readerFromSid(sid) before any await, src/index.ts:762) and the whole resolve/check/mutate runs inside the update-order lock. Lock ordering verified independently: update-order is acquired at exactly two sites, both top-level tool handlers (src/index.ts:582 memory_update, :782 merge_review); store-file locks are only ever taken deeper (markManySuperseded, stampRow). Nothing inside a file-locked region reaches for update-order, so the order is strictly one-way and cannot deadlock against a plain writer. onTimeout: "fail" throws before the callback runs (src/lock.ts:251), so the timeout really is a no-op.
Probe 5's contract is right: mutated flips only after markSuperseded returns true, so pre-mutation throws keep the verbatim "nothing was done" wording and post-mutation throws report PARTIAL naming the retirement that stands.
#132 — redact then crop
buildCapturePrompt(redactSecrets(transcript).slice(-8000), …) (src/index.ts:1462) — ordering correct, window scrub retained as defense in depth.
Independent probes
I added 30 throwaway adversarial cases against the two fixed primitives (not committed): all pass. Notable edge confirmations — repo: "" with a named sid falls to the private branch rather than global-by-stamp; an unstamped line naming ? or "" keeps legacy-global; admin still sees private lines; unparseable evidence lines are dropped, not passed.
Gates
bun run gate on this head: 590 pass / 12 skip / 0 fail + e2e 11 pass / 0 fail, tsc clean, biome 0 errors, exit 0. I also simulated the landing order: origin/main → merge #133 → merge #135 is conflict-free and the merged result gates green (590 pass / 12 skip / 0 fail, e2e 11/0).
Non-blocking
The same record() field-spread note I left on #133 applies here for the new merge_resolved line (unreachable today — no call site passes a reserved key). aab5537's platform-deterministic poison fixture and 152d613's session binding under #133's private-evidence rule are both correct adaptations, not assertion weakenings; test/boundaries.test.ts is a wire-pin update recording the new pattern deliberately.
Approving — merging #133 first, then this.
|
#133 landed (main is 0.14.12), which unwinds this stack on its own: the merge-base of this branch against I am deliberately not force-pushing the final rebase promised in the PR description: it existed to collapse the review diff, which has now collapsed naturally via the merge-base, and a cosmetic re-land right after your final-pass approval could only perturb that approval or the green runs. If linear history matters more than that, say the word and I'll rebase onto 0.14.12 on request. Merged, this closes #130, #131 and #132 — completing the #127–#132 batch (the first three auto-closed with #133). Thanks for the final pass and the precise framing of the inherited blocker; the whole stack's audit trail — regression-first SHAs, the rebase records, and the #147/#148 environment errata — is on these two threads if anyone greps this later. |
|
@abogartz The new Linux failure on Failed job 122916024088: 588 pass / 12 skip / 2 fail, both in CI runs Deterministic reproducer, also red locally on Windows/Bun 1.3.10 at this exact head: bun test ./test/update-targeting.test.ts ./test/repokey-path.test.tsBefore: 19 pass / 2 fail, matching both CI failures. With the test-only reset patch below: 21 pass / 0 fail, and type-checking passes. Resetting the producer's session map before each test also stops the reused diff --git a/test/repokey-path.test.ts b/test/repokey-path.test.ts
index c856c70..c9dd123 100644
--- a/test/repokey-path.test.ts
+++ b/test/repokey-path.test.ts
@@ -10,7 +10,8 @@ import { createHash } from "node:crypto";
import { mkdtempSync, readFileSync, rmSync, symlinkSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { normalizeDirPath, resolveRepo, setRepoScope } from "../src/repokey.ts";
+import { normalizeDirPath, resetSessionScopes, resolveRepo, setRepoScope } from "../src/repokey.ts";
+import { resetState } from "../src/state.ts";
import { appendMemory } from "../src/memory.ts";
import { relevantKnowledge } from "../src/inject.ts";
@@ -29,12 +30,16 @@ const sha1 = (s: string) => createHash("sha1").update(s).digest("hex").slice(0,
let root: string;
let memDir: string;
beforeEach(() => {
+ resetState();
+ resetSessionScopes();
root = mkdtempSync(join(tmpdir(), "osi-repokey-"));
memDir = join(root, "memory");
process.env.OPENCODE_MEMORY_DIR = memDir;
setRepoScope(null);
});
afterEach(() => {
+ resetState();
+ resetSessionScopes();
setRepoScope(null);
delete process.env.OPENCODE_MEMORY_DIR;
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 });
diff --git a/test/update-targeting.test.ts b/test/update-targeting.test.ts
index e156a9f..c3a1b8f 100644
--- a/test/update-targeting.test.ts
+++ b/test/update-targeting.test.ts
@@ -24,13 +24,14 @@ import {
type Memory,
} from "../src/memory.ts";
import { resetState, setCurrent } from "../src/state.ts";
-import { setRepoScope } from "../src/repokey.ts";
+import { resetSessionScopes, setRepoScope } from "../src/repokey.ts";
import { loadPlugin } from "./harness.ts";
let root: string;
let liveRoot: string;
beforeEach(() => {
+ resetSessionScopes();
root = mkdtempSync(join(tmpdir(), "osi-upd-"));
// Tests seed rows via appendMemory BEFORE loading the plugin; null scope
// keeps those seeds unstamped (legacy = global visibility) so each test's
@@ -44,6 +45,9 @@ beforeEach(() => {
});
afterEach(() => {
+ resetState();
+ resetSessionScopes();
+ setRepoScope(null);
delete process.env.OPENCODE_MEMORY_DIR;
delete process.env.OPENCODE_COMMANDS_DIR;
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 });No product-code change or assertion weakening is needed. Please apply the cleanup (or equivalent hermetic setup/teardown) and rerun CI before merging. This is separate from the Windows/Bun export and symlink issues already tracked elsewhere. Verification was local only; the review worktree's tracked files were restored afterward, and I have not pushed to the PR. |
Holding the merge — your head is red, but the defect is inherited from
|
|
That red
I'm deliberately not pushing anything — a no-op commit to re-trigger would perturb your approval on |
|
@abogartz Recheck requested after #149: the blocker is cleared at The branch now includes main's #151 fix ( Independent local verification on Windows/Bun 1.3.10:
CI run 40725811231 is fully green: test, test-windows, lint, smoke. GitHub reports the PR mergeable/clean. My review sign-off carries forward to this head. #133 is already merged; #135 is ready for your final landing decision. |
|
Green board, State after your hygiene fix landed:
And a correction I owe the thread: my #150 described this as a timing lottery — that was wrong, your Nothing to push from here. Ready to land on your approval. |
|
🎉 This PR is included in version 0.14.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Stacked on #133
The three mediums sit on top of #133's branch (semantically, too: the #131 fix authorizes rows against #127's entry-resolved
Reader, and its tests use #133'stoolIds/harness seams). Until #133 merges, this PR's diff includes its commits — this PR's own commits arebc9eebd(the three fixes),9802cf0+156e887(follow-up review round),aab5537(platform-hardening of the probe-5 fixture),152d613(binding the evidence-path control's session under #133's private-evidence rule), on top of #133's9a7c674. The whole stack rebased ontomain0.14.11 (#145+#146) on 2026-10-27; earlier commit SHAs quoted below are the pre-rebase history preserved in the review threads. After #133 merges I will rebase this branch ontomainand force-push, at which point the diff becomes exactly these commits; the checks below run on the full branch either way.Closes #130, closes #131, closes #132.
What changed
#130 —
memory_evidencedateis a date, not a pathTwo doors, per the issue:
EvidenceArgs.date(schema boundary):^\d{4}-\d{2}-\d{2}$, so../../outside,..\..\outsideand../YYYY-MM-DDare refused asinvalid arguments … nothing was donebefore any filesystem call.evidenceFileFor()(second door, src/evidence.ts): impossible dates (2026-02-30) refused rather than rolled byDateonto another day; containment checked afterresolve(); a day file symlinked out of the evidence dir is not followed. The forced.logfmtsuffix remains the primitive's residual bound either way.boundaries.test.ts's wire pin records the (intentional, now host-visible)datepattern. The~standardkey visible in that pin's failure diff is a non-enumerable zod standard-schema annotation present on every tool's wire output (verified againstMergeReviewArgs), unrelated to this change.#131 — a row id is a pointer, not authority
memory_merge_reviewresolves and authorizes BOTH seats through the caller'sReader(captured at entry, never re-read after an await, #127), and the whole resolve/check/mutate runs under the sameupdate-orderlockmemory_updateserializes on (#125) — acquisition order is always update-order then store-file locks, never the reverse, so it cannot deadlock against a plain writer; on timeout it fails closed with nothing written.The contract, now in the tool description: a session may merge exactly the rows it may read. Global rows (explicit or legacy-unstamped) are mergeable from anywhere; a row belonging to another repository is refused in either seat — retiring it as loser or promoting/reviving it as survivor — before any mutation, no partial apply, no evidence line. Success now records
merge_resolvednaming the session the merge ran FOR.The follow-up review's probe 2 (an UNBOUND session merging under the last setup's module scope, defeating the ownership check) is closed by #133's entry binding at this head: the caller resolves to its own instance's workspace before the seats are authorized. Pinned by a committed regression (
284166a; red atc9791ed, green here).#132 — redact the COMPLETE transcript, THEN crop
captureSessionminedtranscript.slice(-8000)and letbuildCapturePrompt's scrub handle the WINDOW. The PEM regex needs both BEGIN and END markers, and the prefix families (ghp_,sk-, …) need the prefix — a credential the crop cut in half matched nothing and rode to the configured capture model as a fragment (the issue's proof: key-body fragments +ENDmarker verbatim in the prompt). Now:redactSecrets(transcript).slice(-8000); the window scrub stays as defense in depth.Review probe 5 — merge_review reports a post-mutation failure as PARTIAL (
8490534)The catch at the bottom of
memory_merge_reviewwas written for the lock-timeout contract ("nothing was done"), but the evidencerecord()sits inside the sametry: when it failed AFTERmarkSupersededsucceeded, the loser was retired on disk while the tool told the caller nothing happened. The catch now tracks the mutation: pre-mutation throws keep the documented no-op contract verbatim; post-mutation throws return aPARTIALreport naming the retirement that stands, carrying the failure reason, and pointing atmemory_undo(re-running is idempotent).Test evidence
Ten new regression tests (4 + 4 + 2) plus the two follow-up probes. The ten split into 7 vulnerability regressions (path traversal, impossible date, symlink-not-followed, cross-repo loser, cross-repo survivor, token-straddle, PEM-straddle) and 3 behavior-preservation controls (today's evidence readable; global rows mergeable from anywhere; same-repo merge resolves with evidence). The seven are red on
cf9b73c(upstream main, 0.14.9 — verified by running these exact files in a throwaway checkout of that revision) and green here; the three controls are green on BOTH revisions. Caveat: the symlink case early-returns on Windows, so only six of the seven execute red there — on a platform that runs it, all seven do. Probe 2 is red atc9791ed/ green here; probe 5 red at03d009f/ green at8490534.Here: 554 pass / 5 skip (
bun test, Bun 1.3.10),tsc --noEmitclean,biome lint0 errors. (This machine additionally shows the service-host stamp e2e failing for a sandbox reason — no git for the spawned service — identical on the reviewed base; green in CI.) The crop tests drive the realsession.compactionhook and assert on the prompt actually handed to the capture model; their straddle guards derive from the sameflattenTranscriptoutput the capture path mines, so the guards hold on any revision and only the behavior assertions flip.The second re-review round's two unresolved-server-session probes (
test/security-evidence-unbound-server.test.ts, #133's65812bc→a909685) pass on this head too — 7/7 probes across the stack. One adaptation here was required: the evidence-path readability control wrote its marker for an UNBOUNDses-130, which #133's new private-to-session rule correctly hides; it now binds that session to the workspace (4beccfa) instead of exploiting the missing-stamp path. And #133's203240fscopes the foreign-stamp probe assertion to A's own evidence line: main's 0.14.10 (#142)plugin_loadboot record legitimately stamps B's repository in the shared day file, which a whole-file scan mistook for the leak — A's line was correctly unstamped on CI too.Not in this PR
Nothing deferred: #128's evidence-READ repo scoping, previously noted here as a possible follow-up, landed on the #133 side (
d56956e, completed bya909685) — evidence lines stamp their repository, a missing stamp is not the global marker, andmemory_evidencefilters by the caller's reader and sid.