From 039f4a4048314d8d49ef3023cab7b7e227dccad6 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Wed, 9 Sep 2026 10:10:44 +0800 Subject: [PATCH] Use VCC compiler for bounded worker supervision overviews --- package-lock.json | 10 ++ package.json | 1 + slop/reviews/vcc-view/compare.mjs | 56 +++++++ slop/reviews/vcc-view/comparison.json | 46 ++++++ .../vcc-view/flow-implementation-old.md | 67 ++++++++ .../vcc-view/flow-implementation-vcc.md | 39 +++++ .../reviews/vcc-view/pilot-preparation-old.md | 144 ++++++++++++++++++ .../reviews/vcc-view/pilot-preparation-vcc.md | 82 ++++++++++ slop/reviews/vcc-view/plan.md | 7 + slop/reviews/vcc-view/review.md | 62 ++++++++ .../vcc-view/settled-checkpoint-old.md | 44 ++++++ .../vcc-view/settled-checkpoint-vcc.md | 33 ++++ slop/reviews/vcc-view/validation.txt | 73 +++++++++ src/index.ts | 1 + src/vcc-package.d.ts | 10 ++ src/worker-view.ts | 49 ++++-- test/goals-flow.test.ts | 1 + test/worker-view.test.ts | 84 ++++++++++ tsconfig.json | 5 +- 19 files changed, 804 insertions(+), 10 deletions(-) create mode 100644 slop/reviews/vcc-view/compare.mjs create mode 100644 slop/reviews/vcc-view/comparison.json create mode 100644 slop/reviews/vcc-view/flow-implementation-old.md create mode 100644 slop/reviews/vcc-view/flow-implementation-vcc.md create mode 100644 slop/reviews/vcc-view/pilot-preparation-old.md create mode 100644 slop/reviews/vcc-view/pilot-preparation-vcc.md create mode 100644 slop/reviews/vcc-view/plan.md create mode 100644 slop/reviews/vcc-view/review.md create mode 100644 slop/reviews/vcc-view/settled-checkpoint-old.md create mode 100644 slop/reviews/vcc-view/settled-checkpoint-vcc.md create mode 100644 slop/reviews/vcc-view/validation.txt create mode 100644 src/vcc-package.d.ts diff --git a/package-lock.json b/package-lock.json index 15c7e77..a238b73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.2.2", "license": "MIT", "dependencies": { + "@sting8k/pi-vcc": "0.5.0", "pi-intercom": "^0.13.0" }, "devDependencies": { @@ -3574,6 +3575,15 @@ "dev": true, "license": "MIT" }, + "node_modules/@sting8k/pi-vcc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@sting8k/pi-vcc/-/pi-vcc-0.5.0.tgz", + "integrity": "sha512-KJbOVUFbyghn6h+RD9bDXFNWkKNqpxaCpPQWceOuxMPe9ySpbEfaYnqO9CZUiCP3AFmQ5Ghnsg2B8pdKgY+0Hg==", + "peerDependencies": { + "@earendil-works/pi-coding-agent": ">=0.74.0 <1.0.0", + "typebox": ">=1.1.24 <2.0.0" + } + }, "node_modules/@tybys/wasm-util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", diff --git a/package.json b/package.json index 9649009..dc0917a 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "lint:fix": "biome check --fix src/ test/" }, "dependencies": { + "@sting8k/pi-vcc": "0.5.0", "pi-intercom": "^0.13.0" }, "devDependencies": { diff --git a/slop/reviews/vcc-view/compare.mjs b/slop/reviews/vcc-view/compare.mjs new file mode 100644 index 0000000..e77a15c --- /dev/null +++ b/slop/reviews/vcc-view/compare.mjs @@ -0,0 +1,56 @@ +// Read-only replay of recorded research branches. Run from the pi-goals root after npm run build. +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { readFileSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import { resolve } from "node:path"; +import ts from "typescript"; + +const output = "slop/reviews/vcc-view"; +const root = "/home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/"; +const workerPath = `${root}2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl`; +const supervisorPath = `${root}2026-09-08T22-43-35-654Z_01a08330-e866-7004-9b7f-5efdceb2488e.jsonl`; +const load = path => readFileSync(path, "utf8").trim().split("\n").map(line => JSON.parse(line)); +const entries = load(workerPath); +const byId = new Map(entries.map(entry => [entry.id, entry])); +const records = load(supervisorPath); +const oldSource = execFileSync("git", ["show", "8953dce:src/worker-view.ts"], { encoding: "utf8" }); +const oldCode = ts.transpileModule(oldSource, { compilerOptions: { module: ts.ModuleKind.ES2022 } }).outputText; +const { workerView: oldView } = await import(`data:text/javascript;base64,${Buffer.from(oldCode).toString("base64")}`); +const piRequire = createRequire(import.meta.resolve("@earendil-works/pi-coding-agent")); +const { createJiti } = piRequire("jiti"); +const jiti = createJiti(import.meta.url, { moduleCache: false, fsCache: false }); +const { workerView: newView } = await jiti.import(resolve("src/worker-view.ts")); +const { workerView: builtView } = await jiti.import(resolve("dist/worker-view.js")); +const results = []; +for (const [name, through] of [["pilot-preparation", "3cb9b26f"], ["flow-implementation", "69943231"], ["settled-checkpoint", "e266d41e"]]) { + const record = records.find(entry => entry.customType === "pi-goals-intercom" && entry.data.message.kind === "view" && entry.data.message.through === through); + assert(record, `recorded view ${through}`); + const message = record.data.message; + const branch = []; + for (let entry = byId.get(through); entry; entry = byId.get(entry.parentId)) branch.unshift(entry); + assert(branch.length, "nonempty live branch"); + const ack = branch.filter(entry => entry.customType === "pi-goals-intercom" && entry.data.direction === "ack" && entry.data.message.through).at(-1); + const context = { + sourceSession: workerPath, + model: message.text.match(/^worker model: (.*)$/m)[1], + latestDirection: message.text.match(/latest human direction:\n([\s\S]*?)\ntool calls with no result:/)[1], + background: message.text.match(/^tracked background work: (.*)$/m)[1], + since: ack?.data.message.through, + }; + const args = [branch, message.reason, message.text.startsWith("The worker stopped."), context]; + const before = oldView(...args); + const after = newView(...args); + assert.equal(builtView(...args), after, "built/source real compiler parity"); + const envelope = { binding: message.binding, role: "worker", kind: "view", id: message.id, text: after, reason: message.reason, through, backgroundQuiet: message.backgroundQuiet }; + assert(Buffer.byteLength(JSON.stringify(envelope)) < 16_000, "serialized transport bound"); + // Normalize only the saved files' trailing blank lines; byte metrics use the exact rendered strings. + writeFileSync(`${output}/${name}-old.md`, before.trimEnd() + "\n"); + writeFileSync(`${output}/${name}-vcc.md`, after.trimEnd() + "\n"); + results.push({ name, timestamp: record.timestamp, through, since: context.since, branchEntries: branch.length, branchSha256: createHash("sha256").update(JSON.stringify(branch)).digest("hex"), oldBytes: Buffer.byteLength(before), vccBytes: Buffer.byteLength(after), oldSerializedTextBytes: Buffer.byteLength(JSON.stringify(before)), vccSerializedTextBytes: Buffer.byteLength(JSON.stringify(after)), envelopeBytes: Buffer.byteLength(JSON.stringify(envelope)) }); +} +const manifest = { baseline: "8953dce", workerPath, supervisorPath, compiler: "@sting8k/pi-vcc@0.5.0", results }; +writeFileSync(`${output}/comparison.json`, JSON.stringify(manifest, null, 2) + "\n"); +console.log(JSON.stringify(manifest, null, 2)); +console.log("PASS: three identical historical branch/ack windows, serialized bounds, source and built compiler execution agree."); diff --git a/slop/reviews/vcc-view/comparison.json b/slop/reviews/vcc-view/comparison.json new file mode 100644 index 0000000..856332d --- /dev/null +++ b/slop/reviews/vcc-view/comparison.json @@ -0,0 +1,46 @@ +{ + "baseline": "8953dce", + "workerPath": "/home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl", + "supervisorPath": "/home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T22-43-35-654Z_01a08330-e866-7004-9b7f-5efdceb2488e.jsonl", + "compiler": "@sting8k/pi-vcc@0.5.0", + "results": [ + { + "name": "pilot-preparation", + "timestamp": "2026-09-08T22:59:31.347Z", + "through": "3cb9b26f", + "branchEntries": 597, + "branchSha256": "f0da668db6266780aa3ba803e5260d4009732c74ab3276f4db55910b8d74af5a", + "oldBytes": 4961, + "vccBytes": 5356, + "oldSerializedTextBytes": 5324, + "vccSerializedTextBytes": 5462, + "envelopeBytes": 5655 + }, + { + "name": "flow-implementation", + "timestamp": "2026-09-08T23:17:08.542Z", + "through": "69943231", + "since": "54648ab4", + "branchEntries": 715, + "branchSha256": "2293e2e7158c051c3571cd50befb14900cea39314640421a5735633775af427b", + "oldBytes": 4897, + "vccBytes": 2396, + "oldSerializedTextBytes": 5109, + "vccSerializedTextBytes": 2452, + "envelopeBytes": 2646 + }, + { + "name": "settled-checkpoint", + "timestamp": "2026-09-09T00:11:07.924Z", + "through": "e266d41e", + "since": "18c6af89", + "branchEntries": 981, + "branchSha256": "3460caf8d1a093309ad2639decbc181151f27871c42ffa62ca98803aae726ce7", + "oldBytes": 1676, + "vccBytes": 1840, + "oldSerializedTextBytes": 1721, + "vccSerializedTextBytes": 1882, + "envelopeBytes": 2078 + } + ] +} diff --git a/slop/reviews/vcc-view/flow-implementation-old.md b/slop/reviews/vcc-view/flow-implementation-old.md new file mode 100644 index 0000000..e5eadb8 --- /dev/null +++ b/slop/reviews/vcc-view/flow-implementation-old.md @@ -0,0 +1,67 @@ +The worker is still working. + +review trigger: turns +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 1 (e55-fine-job802-follower); subagents: 0; unregistered detached work is not tracked + +new worker transcript since the last acknowledged view: +[truncated; inspect source session] +: answer_reached={} reason={} E={:.3f}", setting.name, task.name, r["scorable"], r["reason"], r["E"]) + if setting.method == "base": + if r["scorable"]: + base_scorable.add(task.name) + if task.name in {"s_add", "l_moral_lie"}: + ref_ids = ids[:, :n_prompt + cfg.kl_tokens] + base_logp = model(ref_ids, use_cache=False).logits[:, n_prompt - 1:-1].float().log_softmax(-1) + references.append((ref_ids, n_prompt - 1, base_logp)) + report = evaluate_with_vector(model, tok, vignettes=vignettes, max_think_tokens=cfg.think_tokens, + batch_size=2, log_demo=False, verbose=0) + kl = shared_prefix_kl(model, references) + if setting.method == "logit_diff": + dump(outdir / f"{setting.name}_adapter.json", stats) + dump(outdir / f"{setting.name}_behavior.json", report["per_row"]) + if setting.method == "base": + base_report = report + delta = dclr_per_foundation(base_report, report) + care, auth = delta["Care"]["mean"], delta["Authority"]["mean"] + other = [delta[f]["mean"] for f in FOUNDATION_ORDER if f not in {"Care", "Authority"}] + off = sum(abs(x) for x in other) / len(other) + scorable = [r for r in generated if r["scorable"]] + subset = [r for r in generated if r["task"] in base_scorable] + direction = random_v if setting.random_direction else v0 + along = setting.c * float(direction @ v0) + point = dict(name=setting.name, method=setting.method, internal_c=setting.c, + logit_alpha=setting.alpha if setting.method == "logit_diff" else 1.0, + frac_scorable=len(scorable) / len(tasks), n_base_scorable=len(subset), + frac_on_base_scorable=sum(r["scorable"] for r in subset) / len(subset) if subset else float("nan"), + mean_nonforced_E=sum(r["E"] for r in generated) / len(tasks), + care=care, auth=auth, dlog_on_target=-auth, dlog_off_target=off, + net_behavior_nats=care - auth, score=float("nan"), + pmass_coherence=report["mean_pmass_allowed"], base_pmass=base_report["mean_pmass_allowed"], + pmass_floor=0.99 * base_report["mean_pmass_allowed"], + passes_pmass=report["mean_pmass_allowed"] >= 0.99 * base_report["mean_pmass_allowed"], + steering_strength_v0=along, total_strength=setting.c, + off_axis_strength=setting.c * float((direction - (direction @ v0) * v0).norm()), + shared_prefix_kl_nats=kl, behavior_pairs=delta["Authority"]["n"], + behavior_pairs_total=delta["Authority"]["n_total"], elapsed_s=time.monotonic() - stage_start) + points.append(point) + pl.DataFrame([{k: v for k, v in r.items() if k not in {"completion", "prefix", "generated_ids"}} for r in records]).write_csv(outdir / "tasks.csv") + pl.DataFrame([{"name": r["name"], "prompt": r["task"], "task": r["task"], + "scenario": choice_metadata[r["task"]]["scenario"] if r["task"] in choice_metadata else None, + "rating_1_to_5": None, "coherent": None, "passes_demo_gate": None, + "premise_preserved": None, "post_answer_repetition": None, "evidence_quote": None, + "care_choice_verified": None, "failure_reason": "pending_manual"} for r in records]).write_csv(outdir / "demo_audit.tsv", separator="\t") + table = write_report(outdir, points, records, cfg) + logger.info("{}: {:.1f}s, ΔCare={:+.3f}, ΔAuth={:+.3f}, KL={:.4f}", setting.name, point["elapsed_s"], care, auth, kl) + assert {(r["name"], r["task"]) for r in records} == {(s.name, t.name) for s in settings for t in tasks} + assert len(records) == len(settings) * len(tasks), "duplicate or missing generation" + logger.info("SHOULD every treatment/prompt cell retained: {} records PASS", len(records)) + logger.info("RESULT_DEMO: NO_RESULT (pending manual audit)\n{}\nreport={}\nelapsed_s={:.1f}", table, outdir / "report.md", time.monotonic() - start) + + +if __name__ == "__main__": + main(tyro.cli(Cfg)) diff --git a/slop/reviews/vcc-view/flow-implementation-vcc.md b/slop/reviews/vcc-view/flow-implementation-vcc.md new file mode 100644 index 0000000..2e514cd --- /dev/null +++ b/slop/reviews/vcc-view/flow-implementation-vcc.md @@ -0,0 +1,39 @@ +The worker is still working. + +review trigger: turns +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 1 (e55-fine-job802-follower); subagents: 0; unregistered detached work is not tracked + +new worker overview since the last acknowledged view (VCC algorithmic compression; local # refs index new messages; tool-result bodies omitted; inspect source for evidence): +[Files And Changes] +- Modified: experiments/e56_flow_repair/flow.py, experiments/e56_flow_repair/test_flow.py, + slop/reviews/e56_flow_matching_source.md, slop/reviews/e56_flow_discussion_brief.md, + experiments/e56_flow_repair/intervention.py, src/manifold_steer/autoencoder.py +- Read: slop/reviews/2026-09-09_glm-5.3-flash_e56_flow_scientist.md, + /workspace/2026/lite/steering-lite/src/steering_lite/variants/mean_diff.py, + slop/audits/steering_tradeoff/flow_synthetic.log, slop/reviews/2026-09-09_deepseek-v4-pro-0813_e56_flow_scientist.md, + /home/code/.pi/agent/skills/arxiv/SKILL.md, /workspace/2026/lite/steering-lite/src/steering_lite/config.py, + experiments/e55_logit_diff_amplification/logit_diff.py, /workspace/2026/lite/steering-lite/src/steering_lite/vector.py + , slop/reviews/2026-09-09_deepseek-v4-pro-0813_e56_flow_discussion.md, + slop/reviews/2026-09-09_glm-5.3-flash_e56_flow_discussion.md + +[assistant] +* (15 earlier tool-call entries omitted) +* read "experiments/e55_logit_diff_amplification/logit_diff.py" (#30) +* read "/workspace/2026/lite/steering-lite/src/steering_lite/vector.py" (#30) +* write "experiments/e56_flow_repair/intervention.py" (#34) +* edit "experiments/e56_flow_repair/test_flow.py" (#36) +* read "slop/reviews/2026-09-09_deepseek-v4-pro-0813_e56_flow_discussion.md" (#38) +* read "slop/reviews/2026-09-09_glm-5.3-flash_e56_flow_discussion.md" (#40) +* edit "src/manifold_steer/autoencoder.py" (#42, #44, #46) x3 +(thinking) Thinking: **Preparing evaluation configuration** + +**Refactoring evaluation context** (#48) +(thinking) Thinking: **Preparing token geometry logging** + +**Implementing token geometry logging** (#48) +* bash "sed -n '255,370p' experiments/e55_logit_diff_amplification/run.py" (#48) diff --git a/slop/reviews/vcc-view/pilot-preparation-old.md b/slop/reviews/vcc-view/pilot-preparation-old.md new file mode 100644 index 0000000..c19b42a --- /dev/null +++ b/slop/reviews/vcc-view/pilot-preparation-old.md @@ -0,0 +1,144 @@ +The worker is still working. + +review trigger: turns +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 0; subagents: 0; unregistered detached work is not tracked + +compaction summary (worker account, not independent evidence): +[OpenAI native compaction checkpoint] + +new worker transcript (initial or reset view): +[truncated; inspect source session] +"enqueued_at": "2026-09-08T13:38:57.301057325+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on dog legs; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 769, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:38:57.518018760+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on dog name; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 770, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:38:57.740040876+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on dog property; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 771, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:38:57.987386109+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on ant legs; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 772, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:38:58.231236887+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on ant name; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 773, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:38:58.435527993+08:00" + } + }, + "priority": 0, + "label": "why: validate common L22-24 C2 on ant property; resolve: correct clean controls and consistent transfer on plain questions", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 775, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:41:03.538541658+08:00" + } + }, + "priority": 0, + "label": "why: selected dog band may just cause generic changes; resolve: eight random spans matched per-token edit magnitude", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 776, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T13:41:04.114346905+08:00" + } + }, + "priority": 0, + "label": "why: selected ant band may just cause generic changes; resolve: eight random spans matched per-token edit magnitude", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 778, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T15:16:24.724372591+08:00" + } + }, + "priority": 0, + "label": "why: dog clean controls may fail from assistant-prefilled questions; resolve: user-role and generation-boundary repair must give correct clean answers before assessing fixed L22-24 C2 transfer", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 779, + "status": { + "Queued": { + "enqueued_at": "2026-09-08T15:16:24.923827832+08:00" + } + }, + "priority": 0, + "label": "why: ant clean controls may fail from assistant-prefilled questions; resolve: user-role and generation-boundary repair must give correct clean answers before assessing fixed L22-24 C2 transfer", + "path": "/workspace/2026/suppressed-activations" + }, + { + "id": 801, + "status": { + "Running": { + "enqueued_at": "2026-09-09T06:50:35.856041965+08:00", + "start": "2026-09-09T06:50:48.080797309+08:00" + } + }, + "priority": 0, + "label": "why: larger paired MLP reader/writer needs a fitting check; resolve: batch-eight memory and complete local readouts before held-out training; args --steps 4 --eval-every 2", + "path": "/workspace/2026/LUCID3_wikit" + } + ] +} + + +tool: edit + +Successfully replaced 3 block(s) in experiments/e55_logit_diff_amplification/run_fine_s43/run_card.md. + +tool: bash + +(no output) diff --git a/slop/reviews/vcc-view/pilot-preparation-vcc.md b/slop/reviews/vcc-view/pilot-preparation-vcc.md new file mode 100644 index 0000000..23f9dbb --- /dev/null +++ b/slop/reviews/vcc-view/pilot-preparation-vcc.md @@ -0,0 +1,82 @@ +The worker is still working. + +review trigger: turns +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 0; subagents: 0; unregistered detached work is not tracked + +compaction summary (worker account, not independent evidence): +[OpenAI native compaction checkpoint] + +new worker overview (initial or reset view) (VCC algorithmic compression; local # refs index new messages; tool-result bodies omitted; inspect source for evidence): +[Session Goal] +- was your job killed? +- [Scope change] +- maybe read it your self ml-debug + +[Files And Changes] +- Modified: slop/audits/e55/job798_parent_read.md, /workspace/2026/mfv/manifold-steer/.pi/plan/01a0809b-a528-7724-a514-5 + 9f3c61116a6-v1.md, experiments/e55_logit_diff_amplification/LAB.md, experiments/ACTIVE.md, + experiments/e55_logit_diff_amplification/choice_tasks.py, experiments/e55_logit_diff_amplification/run.py, + experiments/e55_logit_diff_amplification/choice_summary.py, + experiments/e55_logit_diff_amplification/test_choice_summary.py, justfile, + experiments/e55_logit_diff_amplification/run_fine_s43/run_card.md (+2 more) +- Read: experiments/e55_logit_diff_amplification/LAB.md, /home/code/.pi/agent/skills/ml-debug/SKILL.md, + experiments/e55_logit_diff_amplification/run_s43/run.log, experiments/e55_logit_diff_amplification/run_s43/run_card.md + , /home/code/.pi/agent/skills/plan-format/SKILL.md, experiments/e55_logit_diff_amplification/run.py, + /home/code/.pi/agent/skills/pueue/SKILL.md, /home/code/.pi/agent/skills/machine-map/SKILL.md, + /home/code/.pi/agent/skills/ponytailplus/SKILL.md, /workspace/2026/lite/steering-lite/src/steering_lite/eval/tinymfv.p + y (+11 more) + +[Commits] +- dff95a9: Record E55 independent demo audit and parent caveats + +[User Preferences] +- Style: Make it easy for a busy and forgetfull user to review. Use ASD-STE100 Simplified Technical English. Use active + voice, one idea per sentence, common words, + +[truncated; inspect source session] +te the stale E55 LAB/ACTIVE claims ('Not run'/'queued798') from existing evidence. +Then implement and run the smallest finer-dose comparison resolving matched achieved behavior versus coherence, with a +reviewed run card and saved just smoke output before queueing on the existing default group. Specify behavior +measurement and uncertainty before collecting new results: forced 32-token CLR and answer-span E alone cannot establish +the tradeoff; retain full 512-token generations, premise/repetition audits and missing completions rather than selecting +survivors. Compare only overlapping measured effects and keep confirmation prompts separate. Diagnose unexpected results +with ml-debug. Goal2 is authorized next: inspect existing AE repair and prepare independent-reviewed corruption-to-clean +flow pseudocode during safe CPU work if goal1 is queued; no sign-off dependency forbids that preparation. Deliver the +single linked report with both plots, full demos, independent reviews and saved verification/job receipts. Continue +autonomously within scope; no approval claim until real evidence is ready. + +[assistant] +* (40 earlier tool-call entries omitted) +* edit "experiments/e55_logit_diff_amplification/run.py" (#161, #163) x2 +* process (#165) +* bash "cp /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/subagent-artifacts/outputs/7a33c86b-5383- + 4752-8ecb-d5912c2583bd/slop/reviews/tradeoff_measurement.md slop/reviews/tradeoff_prequeue.md; cp + /home/code/.pi/agent/sessio..." (#167) +The review found an important measurement issue: moralmaps deliberately prevents `` and EOS during its probe. +Its `emitted_close=0` therefore was not evidence of natural nontermination. + +The follow-up keeps that probe diagnostic only. It adds freely generated care-versus-authority choices, finer doses, +paired option orders, and explicit uncertainty for missing answers. I’m fixing the review’s parser and analysis issues +before queueing. + +Flow preparation also confirms a distinct test: the previous online AE used one learned map; flow repair would integrate +a time-conditioned recovery field. (#169) +* edit ".pi/plan/01a0809b-a528-7724-a514-59f3c61116a6-v1.md" (#169) +* bash "grep -E 'Ran |OK|PASS|elapsed_s=' slop/audits/steering_tradeoff/reviewed_smoke.log; cat + slop/audits/steering_tradeoff/saved_vector_check.log; git diff --check; pueue add --help | head -65; pueue status + --json | jq '[.tasks[] | select(.gr..." (#171) +* bash "pueue status --json | jq '{groups:.groups,tasks:[.tasks[] | select(.group=="default" and (.status.Done == null)) + | {id,status,priority,label,path}]}'" (#173) +(thinking) Thinking: **Refining run-card wording** (#175) +* edit "experiments/e55_logit_diff_amplification/run_fine_s43/run_card.md" (#175) +(thinking) Thinking: **Checking saved-vector comment** + +**Extracting old-run report blocks** (#177) +* bash "UV_NO_SYNC=1 uv run python -c 'from pathlib import Path; + p=Path("experiments/e55_logit_diff_amplification/LAB.md"); report=Path("experiments/e55_logit_diff_amplification/run_s + 43/report.md").read_text(); blocks=report.split("\n## ")[1:]; ..." (#177) diff --git a/slop/reviews/vcc-view/plan.md b/slop/reviews/vcc-view/plan.md new file mode 100644 index 0000000..9510744 --- /dev/null +++ b/slop/reviews/vcc-view/plan.md @@ -0,0 +1,7 @@ +# VCC worker-view change / UAT plan + +Goal: improve supervisor judgment per context token by replacing raw transcript-tail extraction with the existing deterministic VCC compiler. Keep acknowledged-entry slicing, plan changes, tracked background work, and missing tool results. Preserve two recent thinking tails next to their actions. No transport or supervision lifecycle redesign. + +Acceptance: pin and inspect the compiler dependency; test new-turn slicing, compaction/rewind resets, thinking/action ordering, tool arguments, extracted files/context, output omission notices and serialized byte bounds. Run full tests, typecheck, lint and build. Render old and new views from identical recorded maniworker windows, saving reproducible comparison and honest information-loss notes. The parent must perform real isolated Herdr acceptance after this handoff; no research pane interaction here. + +Baseline: HEAD 8953dce, src/worker-view.ts 69 lines. Pre-existing dirty native worker/supervisor event logs and untracked docs/human_journal.md are outside scope and remain untouched/unstaged. No dependency lifecycle scripts will run. diff --git a/slop/reviews/vcc-view/review.md b/slop/reviews/vcc-view/review.md new file mode 100644 index 0000000..16b8c01 --- /dev/null +++ b/slop/reviews/vcc-view/review.md @@ -0,0 +1,62 @@ +# VCC worker overview: implementation and replay review + +## Decision and scope + +Use the deterministic compiler from `@sting8k/pi-vcc@0.5.0` inside the existing worker view. No model call, copied compiler, transport/lifecycle change, new monitoring framework, or change to approval rules. Keep acknowledged-entry boundaries, compaction reset, missing-result matching, plan diff/status claims and existing managed process/subagent tracking. Add context percentage from `ctx.getContextUsage().percent`; unknown remains omitted. + +`src/worker-view.ts`: **69 -> 100 lines (+31)**. Compiler declaration: **10 lines**. Caller: **+1 line**. Not fewer lines than the previous raw-tail implementation, but much smaller than transplanting the 302-line pi-supervise view plus its lifecycle. VCC itself remains an external dependency, not free code complexity. + +## Dependency provenance and security + +- Inspected `../pi-supervise/src/view.ts`, package manifest/lock, installed compiler and normalization/brief/extractor path. Custom last-two-thinking support is in pi-supervise's adapter, not a patched installed VCC package. +- Downloaded exact registry tarball using `npm pack @sting8k/pi-vcc@0.5.0 --ignore-scripts --pack-destination /tmp/pi-goals-vcc-package --json`. +- `diff -qr /tmp/pi-goals-vcc-package/package ../pi-supervise/node_modules/@sting8k/pi-vcc` produced no differences. This includes all installed package files, not just version strings. +- Pinned exact `0.5.0` in dependencies and lockfile. Registry: `https://registry.npmjs.org/@sting8k/pi-vcc/-/pi-vcc-0.5.0.tgz`; SHA512 integrity: `KJbOVUFbyghn6h+RD9bDXFNWkKNqpxaCpPQWceOuxMPe9ySpbEfaYnqO9CZUiCP3AFmQ5Ghnsg2B8pdKgY+0Hg==`. +- Tarball SHA1: `090e5c7cacec00b1083bf423bc08aa2d3eb9cb3a`; size 16,206,703 bytes compressed, 16,712,402 unpacked. It ships more than just the compiler. Added one package; no new transitive packages beyond already installed peers. +- Read cybersec-situational-awareness skill before fetching/installing. Used `npm install --save-exact @sting8k/pi-vcc@0.5.0 --ignore-scripts --no-audit --no-fund`. No lifecycle scripts run. Mise is installed but has no configured/installed Node version; used current project Node v22.23.2/npm rather than install another toolchain. This was not a sandboxed install. +- Runtime imports only compiler source, not the VCC extension entrypoint. The compiler pipeline is algorithmic: no network, shell, or model call. +- Local upstream clone is newer (09c4a74, 0.6.0 work); deliberately did not switch versions. This reproduces the installed reference dependency. + +### Source-only package type boundary + +Direct tsc traversal exposed three upstream 0.5.0 errors: `brief.ts:61,77` passes Intl SegmentData with optional `isWordLike` to a required-boolean shape, and `normalize.ts:21` compares Pi Message role with `bashExecution`, outside that union. Supervisor approved a narrow declaration for the exact compile input/output, with tsconfig path mapping just as this repo handles pi-intercom. No runtime fallback or node_modules patch. Source and built JS imports execute the real compiler in replay; tests likewise execute the real package. This declaration must be reviewed if the pinned compiler version changes. + +## Replay method and result + +`node slop/reviews/vcc-view/compare.mjs` loads the actual maniworker branch terminating at each recorded manisuper view's `through` ID, follows parent links (not dead branches), and recovers its last acknowledged view boundary. Both renderers receive identical entries, context, trigger and idle state. Old renderer comes from HEAD 8953dce; new source and built renderer outputs must agree. Paths, timestamps, IDs and branch SHA256 hashes are in `comparison.json`. No sessions were messaged, reloaded or edited. The source sessions remain local prerequisites to reproduce the replay; saved rendered views are reviewable without them. + +| Recorded window | Old UTF-8 bytes | VCC UTF-8 bytes | Observation | +|---|---:|---:|---| +| Pilot preparation, 22:59:31 | 4,961 | 5,356 | Slightly larger, much better task signal | +| Flow implementation, 23:17:08 | 4,897 | 2,396 | About half the bytes; restores action context | +| Settled checkpoint, 00:11:07 | 1,676 | 1,840 | Slightly larger; direct test output lost | + +These are bytes, **not measured token counts or realized supervisor cost savings**. Each complete serialized transport envelope is below 16KB (largest 5,655 bytes). The raw transcript and VCC brief keep the same total 5.5KB serialized content allowance; VCC splits extracted headers (1.5KB) from newest brief (4KB) when headers exist, so one cannot evict the other. + +### What improves + +- Pilot old view is dominated by unrelated queue-job JSON. VCC retains the decision that moralmaps deliberately suppresses think closure/EOS, so `emitted_close=0` is not evidence of natural nontermination; the narrower choice pilot/uncertainty approach; edited files/commit; recent thinking about run-card wording and saved-vector checks; actual shell commands rather than `tool: bash`. +- Flow old view is almost entirely a raw Python source tail with no useful explanation of the current action. VCC gives changed file paths, reviewed source paths, edit/read/bash arguments and the two recent thinking tails about evaluation configuration and token geometry. Existing E55 follower tracking remains unchanged. +- Checkpoint retains the claim `Test passed. Committed as c41e0f2`, extracted commit title, changed files, verification-log path, and thinking about byte identity/rubric migration. The old view had no tool arguments or thinking. + +### Honest limits / evidence lost + +- The checkpoint's actual `Ran 1 test ... OK` tool result is absent in VCC. Supervisor must read the retained log path before treating the worker's pass claim as evidence. The view explicitly says tool-result bodies are omitted and provides the source session path. +- VCC file lists/commits are extracted activity, not independent proof that a write or commit succeeded. Some file classifications are heuristic (`write` is reported as Modified). Full source/artifact inspection still matters. +- VCC's initial Session Goal extraction includes weak historical phrases such as `was your job killed?`, not the actual agreed research discriminator. It is an overview, not a replacement for the plan or latest human direction. Existing plan review remains separate. +- Generic `process` calls appear by name only in VCC's installed compiler; their detailed command/state is not reconstructed here. Existing live background summary still names tracked processes/subagents. Unregistered detached work remains untracked, as before. +- Older brief/tool entries can still be cut. Long paths/commands can wrap or truncate. Local `#` references index fresh messages, not session entry IDs; the label now explains this. The compiler's unavailable `vcc_recall` instruction is removed. +- Two recent thinking tails are limited to 400 characters before the compiler's own shortening; hidden/redacted thinking cannot be recovered. Large views may still cut earlier retained thinking. +- First/reset views can repeat older instructions. No new deduplication or lifecycle machinery was introduced in this scoped change. + +## Validation + +Final output: `validation.txt`. `npm test`: **94/94**, 18 files including RPC. Typecheck, lint, build and diff check pass. Six focused worker-view tests added to the previous three: thinking/action order and immutability; extracted paths/blockers/arguments with omitted output notices and metadata; partial pending calls across acknowledgements; rewind/compaction reset and unknown context; oversized headers/brief preserving newest activity; omitted-result versus empty-update distinction and commit extraction. Existing flow fixture supplies the new standard context-usage API. + +During implementation, full tests caught a partial `edit` call with no arguments: the adapter now supplies an empty argument object for that incomplete call while preserving missing-result status. Two added assertions initially assumed VCC classified `write` as Created and could extract a commit from a result without its call; corrected tests to the inspected compiler semantics, not patched dependency behavior. Upstream type errors are isolated as described above. All final checks pass. + +## Remaining acceptance + +The replay supports a **better overview**, especially when raw output crowds out decisions, but not a claim that this produces better outcomes or lower total token cost. Parent-owned isolated real Herdr acceptance and independent reviewer gate remain required. Suggested UAT: trivial artifact and saved verification log; inspect the supervisor's new overview and actual artifact read; exercise a manual plan tick/edit and full ApproveGoal -> CompleteGoal sequence. Do not use the user's research panes. + +No Herdr panes, GPU jobs, supervisor sessions, user research files, old native evidence logs or human journal were modified by this task. No push performed. diff --git a/slop/reviews/vcc-view/settled-checkpoint-old.md b/slop/reviews/vcc-view/settled-checkpoint-old.md new file mode 100644 index 0000000..131b9f6 --- /dev/null +++ b/slop/reviews/vcc-view/settled-checkpoint-old.md @@ -0,0 +1,44 @@ +The worker stopped. + +review trigger: settled +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 2 (e55-fine-job802-follower, e56-recovery-job805-follower); subagents: 0; unregistered detached work is not tracked + +new worker transcript since the last acknowledged view: +tool: edit + +Successfully replaced 1 block(s) in experiments/e55_logit_diff_amplification/audit_choices.py. + +tool: edit + +Successfully replaced 1 block(s) in experiments/e55_logit_diff_amplification/test_audit_choices.py. + +tool: process + +Started process audit-rubric-template-test (proc_43e4) with pid 3380015. + +Moved the unchanged rubric to [audit_instructions.md](experiments/e55_logit_diff_amplification/audit_instructions.md). The file-roundtrip test is running; queued code is untouched. + +tool: read + +test_prepare_and_summary_file_paths (experiments.e55_logit_diff_amplification.test_audit_choices.AuditTests.test_prepare_and_summary_file_paths) ... ok + +---------------------------------------------------------------------- +Ran 1 test in 0.018s + +OK + + +tool: bash + +[main c41e0f2] Move generated audit rubric out of Python source + 4 files changed, 19 insertions(+), 12 deletions(-) + create mode 100644 experiments/e55_logit_diff_amplification/audit_instructions.md + create mode 100644 slop/audits/steering_tradeoff/audit_rubric_template_test.log + + +Test passed. Committed as `c41e0f2`; rubric wording is unchanged. diff --git a/slop/reviews/vcc-view/settled-checkpoint-vcc.md b/slop/reviews/vcc-view/settled-checkpoint-vcc.md new file mode 100644 index 0000000..bbfeca0 --- /dev/null +++ b/slop/reviews/vcc-view/settled-checkpoint-vcc.md @@ -0,0 +1,33 @@ +The worker stopped. + +review trigger: settled +source session: /home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl +worker model: openai-codex/gpt-6-astra +latest human direction: +but also try the flow healing one as a next goal on the list +tool calls with no result: none +tracked background work: processes: 2 (e55-fine-job802-follower, e56-recovery-job805-follower); subagents: 0; unregistered detached work is not tracked + +new worker overview since the last acknowledged view (VCC algorithmic compression; local # refs index new messages; tool-result bodies omitted; inspect source for evidence): +[Files And Changes] +- Modified: experiments/e55_logit_diff_amplification/audit_choices.py, + experiments/e55_logit_diff_amplification/test_audit_choices.py +- Read: slop/audits/steering_tradeoff/audit_rubric_template_test.log + +[Commits] +- c41e0f2: Move generated audit rubric out of Python source + +[assistant] +* edit "experiments/e55_logit_diff_amplification/audit_choices.py" (#0) +* edit "experiments/e55_logit_diff_amplification/test_audit_choices.py" (#2) +* process (#4) +(thinking) Thinking: **Checking baseline byte identity** + +**Testing the rubric migration** (#6) +Moved the unchanged rubric to [audit_instructions.md](experiments/e55_logit_diff_amplification/audit_instructions.md). +The file-roundtrip test is running; queued code is untouched. (#6) +* read "slop/audits/steering_tradeoff/audit_rubric_template_test.log" (#7) +* bash "git add experiments/e55_logit_diff_amplification/audit_choices.py + experiments/e55_logit_diff_amplification/audit_instructions.md + experiments/e55_logit_diff_amplification/test_audit_choices.py && git add -f slop/audits/steering_tradeoff/a..." (#9) +Test passed. Committed as `c41e0f2`; rubric wording is unchanged. (#11) diff --git a/slop/reviews/vcc-view/validation.txt b/slop/reviews/vcc-view/validation.txt new file mode 100644 index 0000000..aee5006 --- /dev/null +++ b/slop/reviews/vcc-view/validation.txt @@ -0,0 +1,73 @@ + +> @wassname2/pi-goals@0.2.2 test +> vitest run + + + RUN v4.1.9 /home/code/.pi/agent/git/github.com/wassname/pi-goals + + + Test Files 18 passed (18) + Tests 94 passed (94) + Start at 10:10:30 + Duration 3.11s (transform 3.98s, setup 0ms, import 8.30s, tests 7.14s, environment 2ms) + + +> @wassname2/pi-goals@0.2.2 typecheck +> tsc --noEmit + + +> @wassname2/pi-goals@0.2.2 lint +> biome check src/ test/ + +Checked 34 files in 45ms. No fixes applied. + +> @wassname2/pi-goals@0.2.2 build +> tsc + +{ + "baseline": "8953dce", + "workerPath": "/home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T10-41-19-145Z_01a0809b-a528-7724-a514-59f3c61116a6.jsonl", + "supervisorPath": "/home/code/.pi/agent/sessions/--workspace-2026-mfv-manifold-steer--/2026-09-08T22-43-35-654Z_01a08330-e866-7004-9b7f-5efdceb2488e.jsonl", + "compiler": "@sting8k/pi-vcc@0.5.0", + "results": [ + { + "name": "pilot-preparation", + "timestamp": "2026-09-08T22:59:31.347Z", + "through": "3cb9b26f", + "branchEntries": 597, + "branchSha256": "f0da668db6266780aa3ba803e5260d4009732c74ab3276f4db55910b8d74af5a", + "oldBytes": 4961, + "vccBytes": 5356, + "oldSerializedTextBytes": 5324, + "vccSerializedTextBytes": 5462, + "envelopeBytes": 5655 + }, + { + "name": "flow-implementation", + "timestamp": "2026-09-08T23:17:08.542Z", + "through": "69943231", + "since": "54648ab4", + "branchEntries": 715, + "branchSha256": "2293e2e7158c051c3571cd50befb14900cea39314640421a5735633775af427b", + "oldBytes": 4897, + "vccBytes": 2396, + "oldSerializedTextBytes": 5109, + "vccSerializedTextBytes": 2452, + "envelopeBytes": 2646 + }, + { + "name": "settled-checkpoint", + "timestamp": "2026-09-09T00:11:07.924Z", + "through": "e266d41e", + "since": "18c6af89", + "branchEntries": 981, + "branchSha256": "3460caf8d1a093309ad2639decbc181151f27871c42ffa62ca98803aae726ce7", + "oldBytes": 1676, + "vccBytes": 1840, + "oldSerializedTextBytes": 1721, + "vccSerializedTextBytes": 1882, + "envelopeBytes": 2078 + } + ] +} +PASS: three identical historical branch/ack windows, serialized bounds, source and built compiler execution agree. diff --git a/src/index.ts b/src/index.ts index 112edc4..ad302e4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -260,6 +260,7 @@ export default function piGoalsExtension(pi: ExtensionAPI): void { const view = workerView(entries, reason, reason !== "started" && ctx.isIdle(), { sourceSession: ctx.sessionManager.getSessionFile()!, latestDirection: state.latestDirection, model: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : "not selected", + contextPercent: ctx.getContextUsage()?.percent, since: intercom.acknowledgedEntry, background: background.description, planReview: `Plan: ${planRel(ctx)}\n${planReview(plan)}`, }); diff --git a/src/vcc-package.d.ts b/src/vcc-package.d.ts new file mode 100644 index 0000000..64dbd13 --- /dev/null +++ b/src/vcc-package.d.ts @@ -0,0 +1,10 @@ +// VCC 0.5.0 ships source only; describe its compiler boundary without typechecking upstream internals. +declare module "@sting8k/pi-vcc/src/core/summarize" { + import type { Message } from "@earendil-works/pi-ai"; + export interface CompileInput { + messages: Message[]; + previousSummary?: string; + fileOps?: { readFiles?: string[]; modifiedFiles?: string[]; createdFiles?: string[] }; + } + export function compile(input: CompileInput): string; +} diff --git a/src/worker-view.ts b/src/worker-view.ts index 8d6b38b..32812d9 100644 --- a/src/worker-view.ts +++ b/src/worker-view.ts @@ -1,14 +1,19 @@ +import { compile } from "@sting8k/pi-vcc/src/core/summarize"; + export interface SessionBlock { type?: string; id?: string; name?: string; text?: string; + thinking?: string; + arguments?: Record; } export interface SessionMessage { role?: string; content?: string | SessionBlock[]; toolCallId?: string; + toolName?: string; } export interface SessionEntry { @@ -18,13 +23,38 @@ export interface SessionEntry { message?: SessionMessage; } -function text(message: SessionMessage): string { - if (typeof message.content === "string") return message.content; - return (message.content ?? []).flatMap((block) => { - if (block.type === "text" && block.text) return [block.text]; - if (block.type === "toolCall") return [`tool: ${block.name ?? "unknown"}`]; - return []; - }).join("\n"); +// VCC drops reasoning. Preserve only two recent tails, in place beside the actions they inform. +function recentThinking(messages: SessionMessage[]): SessionMessage[] { + let remaining = 2; + return messages.map(message => ({ + ...message, + // Unanswered/partial calls may have no arguments yet; VCC expects an argument object. + content: Array.isArray(message.content) ? message.content.map(block => block.type === "toolCall" ? { ...block, arguments: block.arguments ?? {} } : { ...block }) : message.content, + })).reverse().map(message => { + if (Array.isArray(message.content)) { + for (const block of [...message.content].reverse()) { + if (block.type === "thinking" && block.thinking && remaining > 0) { + block.type = "text"; + block.text = `(thinking) ${block.thinking.slice(-400)}`; + remaining--; + } + } + } + return message; + }).reverse(); +} + +function compiledView(messages: SessionMessage[]): string { + // Only role/content/tool fields are read by normalize; Pi usage/provider metadata is irrelevant. + const compiled = compile({ messages: recentThinking(messages) as Parameters[0]["messages"] }) + .replace(/\n*-*\n*Use `vcc_recall`[\s\S]*$/, "").trim(); + const separator = compiled.indexOf("\n\n---\n\n"); + // Keep extracted context and newest actions separately: a long brief must not evict all headers. + if (/^\[(Session Goal|Files And Changes|Commits|Outstanding Context|User Preferences)\]/.test(compiled)) { + if (separator < 0) return bounded(compiled, 1500); + return `${bounded(compiled.slice(0, separator), 1500)}\n\n${bounded(compiled.slice(separator + 7), 4000, true)}`; + } + return bounded(compiled || (messages.length ? "No overview text retained from these messages." : "No new messages."), 5500, true); } function outstandingTools(entries: SessionEntry[]): string[] { @@ -51,6 +81,7 @@ export interface ViewContext { sourceSession: string; latestDirection: string; model: string; + contextPercent?: number | null; since?: string; background: string; planReview?: string; @@ -61,9 +92,9 @@ export function workerView(entries: SessionEntry[], reason: "ready" | "settled" const since = context.since ? entries.findIndex(entry => entry.id === context.since) : -1; const from = since >= compactAt ? since + 1 : compactAt + 1; const fresh = entries.slice(from); - const recent = fresh.flatMap(entry => entry.type === "message" && entry.message ? [text(entry.message)] : []).filter(Boolean).join("\n\n"); + const recent = compiledView(fresh.flatMap(entry => entry.type === "message" && entry.message ? [entry.message] : [])); const summary = since < compactAt ? entries[compactAt]?.summary : undefined; const outstanding = outstandingTools(entries.slice(compactAt + 1)); const state = reason === "ready" ? "is ready to begin" : idle ? "stopped" : "is still working"; - return `The worker ${state}.\n\nreview trigger: ${reason}\nsource session: ${bounded(context.sourceSession, 800)}\nworker model: ${bounded(context.model, 300)}\nlatest human direction:\n${bounded(context.latestDirection || "not recorded", 1800)}\ntool calls with no result: ${bounded(outstanding.join(", ") || "none", 500)}\ntracked background work: ${bounded(context.background, 800)}\n\n${context.planReview ? `Plan review:\n${bounded(context.planReview, 1800)}\n\n` : ""}${summary ? `compaction summary (worker account, not independent evidence):\n${bounded(summary, 2500)}\n\n` : ""}new worker transcript${since === -1 ? " (initial or reset view)" : " since the last acknowledged view"}:\n${bounded(recent || "No new messages.", 5500, true)}`; + return `The worker ${state}.\n\nreview trigger: ${reason}\nsource session: ${bounded(context.sourceSession, 800)}\nworker model: ${bounded(context.model, 300)}${context.contextPercent == null ? "" : `; context used: ${context.contextPercent}%`}\nlatest human direction:\n${bounded(context.latestDirection || "not recorded", 1800)}\ntool calls with no result: ${bounded(outstanding.join(", ") || "none", 500)}\ntracked background work: ${bounded(context.background, 800)}\n\n${context.planReview ? `Plan review:\n${bounded(context.planReview, 1800)}\n\n` : ""}${summary ? `compaction summary (worker account, not independent evidence):\n${bounded(summary, 2500)}\n\n` : ""}new worker overview${since === -1 ? " (initial or reset view)" : " since the last acknowledged view"} (VCC algorithmic compression; local # refs index new messages; tool-result bodies omitted; inspect source for evidence):\n${recent}`; } diff --git a/test/goals-flow.test.ts b/test/goals-flow.test.ts index d116b19..0dc3911 100644 --- a/test/goals-flow.test.ts +++ b/test/goals-flow.test.ts @@ -34,6 +34,7 @@ function setup(selectChoices: Array, editorChoices: Array true), getSystemPrompt: () => "base prompt", + getContextUsage: () => ({ percent: 25 }), model: { provider: "test", id: "tiny" }, modelRegistry: { find: (provider: string, id: string) => ({ provider, id }) }, sessionManager: { diff --git a/test/worker-view.test.ts b/test/worker-view.test.ts index 562fc72..abddb7e 100644 --- a/test/worker-view.test.ts +++ b/test/worker-view.test.ts @@ -35,3 +35,87 @@ it("bounds serialized Unicode and quoted logs while marking omissions", () => { expect(view).toContain("[truncated; inspect source session]"); expect(view).toContain(context.sourceSession); }); + +it("keeps two recent thinking tails beside their actions without mutating the branch", () => { + const entries = ["old", "middle", "new"].map(id => ({ id, type: "message", message: { role: "assistant", content: [ + { type: "thinking", thinking: `${id} discarded head ${"padding ".repeat(100)}${id} decisive tail` }, + { type: "toolCall", id, name: "bash", arguments: { command: `verify-${id}` } }, + ] } })); + const before = structuredClone(entries); + const view = workerView(entries, "turns", false, context); + expect(view).not.toContain("old decisive tail"); + expect(view).not.toContain("discarded head"); + expect(view).toContain("middle decisive tail"); + expect(view).toContain("new decisive tail"); + expect(view.indexOf("middle decisive tail")).toBeLessThan(view.indexOf("verify-middle")); + expect(view.indexOf("verify-middle")).toBeLessThan(view.indexOf("new decisive tail")); + expect(view.indexOf("new decisive tail")).toBeLessThan(view.indexOf("verify-new")); + expect(entries).toEqual(before); +}); + +it("extracts files and blockers, retaining tool arguments instead of verbose result bodies", () => { + const entries = [ + entry("claim", "Cannot finish because the fixture is broken."), + { id: "write", type: "message", message: { role: "assistant", content: [{ type: "toolCall", id: "call", name: "write", arguments: { path: "result.txt", content: "artifact" } }] } }, + { id: "result", type: "message", message: { role: "toolResult", toolName: "write", toolCallId: "call", content: "verbose-result-body".repeat(1000) } }, + ]; + const view = workerView(entries, "settled", true, { ...context, contextPercent: 42, planReview: "goal: [/] -> [x], manual claim" }); + expect(view).toContain("[Files And Changes]"); + expect(view).toContain("Modified: result.txt"); + expect(view).toContain("[Outstanding Context]"); + expect(view).toContain("fixture is broken"); + expect(view).toContain('write "result.txt"'); + expect(view).toContain("tool calls with no result: none"); + expect(view).toContain(context.background); + expect(view).toContain("context used: 42%"); + expect(view).toContain("goal: [/] -> [x], manual claim"); + expect(view).not.toContain("verbose-result-body"); + expect(view).toContain("tool-result bodies omitted; inspect source for evidence"); + expect(view).not.toContain("vcc_recall"); +}); + +it("preserves unanswered partial calls across the acknowledged boundary", () => { + const entries = [{ id: "call", type: "message", message: { role: "assistant", content: [{ type: "toolCall", id: "pending", name: "edit" }] } }]; + expect(workerView(entries, "turns", false, context)).toContain("tool calls with no result: edit"); + const view = workerView(entries, "turns", false, { ...context, since: "call" }); + expect(view).toContain("tool calls with no result: edit"); + expect(view).toContain("No new messages."); +}); + +it("restarts a rewound branch and keeps fresh headerless text after compaction", () => { + const view = workerView([ + { id: "compaction", type: "compaction", summary: "Prior worker account." }, entry("fresh", "Fresh decisive result."), + ], "settled", true, { ...context, since: "entry-on-discarded-branch", contextPercent: null }); + expect(view).toContain("initial or reset view"); + expect(view).toContain("Prior worker account."); + expect(view).toContain("Fresh decisive result."); + expect(view).not.toContain("context used:"); +}); + +it("protects VCC headers and newest actions when the compacted brief exceeds its budget", () => { + const entries = [ + { id: "write", type: "message", message: { role: "assistant", content: [{ type: "toolCall", id: "call", name: "write", arguments: { path: "important.txt", content: "artifact" } }] } }, + ...Array.from({ length: 150 }, (_, i) => entry(`entry-${i}`, `Action ${i}: ${"details ".repeat(80)}`)), + entry("last", "Newest decisive observation."), + ]; + const view = workerView(entries, "turns", false, context); + expect(view).toContain("[Files And Changes]"); + expect(view).toContain("important.txt"); + expect(view).toContain("Newest decisive observation."); + expect(view).toContain("[truncated; inspect source session]"); + expect(Buffer.byteLength(JSON.stringify({ text: view }))).toBeLessThan(16_000); +}); + +it("distinguishes omitted result-only updates from no messages and extracts paired commit evidence", () => { + const result = (content: string) => [{ id: "result", type: "message", message: { role: "toolResult", toolName: "bash", toolCallId: "done", content } }]; + const omitted = workerView(result("large diagnostic output"), "settled", true, context); + expect(omitted).toContain("No overview text retained from these messages."); + expect(omitted).not.toContain("No new messages."); + const commit = workerView([ + { id: "commit", type: "message", message: { role: "assistant", content: [{ type: "toolCall", id: "done", name: "bash", arguments: { command: 'git commit -m "Save verified artifact"' } }] } }, + ...result("[main abc1234] Save verified artifact"), + ], "settled", true, context); + expect(commit).toContain("[Commits]"); + expect(commit).toContain("abc1234"); + expect(commit).not.toContain("vcc_recall"); +}); diff --git a/tsconfig.json b/tsconfig.json index 0cea2c0..b6e00ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,10 @@ "target": "ES2022", "module": "ES2022", "moduleResolution": "bundler", - "paths": { "pi-intercom": ["./src/intercom-package.d.ts"] }, + "paths": { + "pi-intercom": ["./src/intercom-package.d.ts"], + "@sting8k/pi-vcc/src/core/summarize": ["./src/vcc-package.d.ts"] + }, "strict": true, "esModuleInterop": true, "skipLibCheck": true,