Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs(eval): C4 pinned questions run 2 (appended corrections): pinned beats query+reader on accuracy and freshness with zero leakage; verdict default-on

garrytanc65a398fd224
diff --git a/docs/eval/decisions/c4-pinned-questions/README.md b/docs/eval/decisions/c4-pinned-questions/README.md
index a8804fc0e8..014740b835 100644
--- a/docs/eval/decisions/c4-pinned-questions/README.md
+++ b/docs/eval/decisions/c4-pinned-questions/README.md
@@ -1,15 +1,93 @@
# Pinned questions: B5 verdict
-Pinned questions ship **opt-in**. The B5 safety gate passes with zero leakage on PGLite and Postgres. The
-benefit gate does not pass against query plus a reader: accuracy is at the ceiling for every arm, and pinned
-answers are not cheaper per correct answer until a pin has been read about 240 times. Pinned answers are
-3.3 to 14.5 times cheaper than running `think` on every read. The feature does nothing until the owner pins a
-question, and no pin is created by default.
+Pinned questions ship **on**. On a workload where corrections arrive as new notes and the old notes stay as
+written, pinned answers were right on 98.6% of reads, against 51.4% for query plus a reader and 79.2% for
+`think` on every read. They went stale-wrong on 0% of reads, against 48.6% and 20.8%. The safety gate passes
+with zero leakage, including 48 restricted-grant probes on this workload. The main caveat is retrieval: pinned
+refresh anchors its evidence on the pin's entity, newest first, and the other two arms have no scope to anchor
+on, so part of the gap comes from that.
-Measured build: gbrain a4267eed7 (the `capy/mpw-integration` branch). Stage: dev.
+"On" means the refresh phase, publishing and `context_pack` delivery of fresh pinned answers are on by default.
+Pinning a question is still the consent for its paid refresh (plan C1), so gbrain creates no pin by itself and
+a brain with no pins makes no model call. No shipped default changed between run 1 and run 2; the verdict
+moved from opt-in to default-on.
+
+Measured build: gbrain baadfc04 (the `capy/mpw-integration` branch). Stage: dev.
## Benefit gate
+The decision rule was set before run 2: if pinned beats query plus a reader on accuracy or freshness without
+leakage, it ships default-on; otherwise opt-in stands. Pinned beats it on both.
+
+### Run 2: corrections appended as new evidence (deciding run)
+
+The workload is seeded (seed 42) and has 6 entities and 12 write batches, which is 13 writes per entity. Each
+entity has a widget-factory city, and corrections arrive as dated notes while the older notes stay as written.
+Batch 4 adds two conflicting notes in one week, and the later note corrects the earlier one. Batch 6 delivers
+the update through `remember`. Batch 7 withdraws it with `forget`, and the answer reverts. Batch 10 makes the
+newest note private. After each batch every question is read 1, 10 or 100 times, depending on the frozen
+reads-per-write ratio. The cost counted is total lifecycle dollars: the first answer, every refresh attempt,
+delivered read tokens and every model call.
+
+| Arm | Accuracy | Stale-wrong | Freshness lag (batches) | Correct at change | Lifecycle $ |
+|---|---|---|---|---|---|
+| pinned, default model (Opus 4.7) | 0.986 | 0.000 | 0.017 | 0.983 | 0.649 |
+| pinned, Sonnet 5.5 refresh | 0.958 | 0.014 | 0.050 | 0.950 | 0.415 |
+| query + reader | 0.514 | 0.486 | 0.583 | 0.483 | — |
+| think | 0.792 | 0.208 | 0.250 | 0.783 | — |
+
+Freshness lag is the mean number of write batches before an answer reflects one of the 60 value changes.
+Correct at change is the share of those changes answered correctly in the batch they happened.
+
+Dollars per correct answer:
+
+| Reads per write | Pinned (Opus 4.7) | Pinned (Sonnet 5.5) | Query + reader | Think |
+|---|---|---|---|---|
+| 1 | 0.00961 | 0.00681 | 0.00234 | 0.03061 |
+| 10 | 0.00138 | 0.00141 | 0.00234 | 0.03061 |
+| 100 | 0.00056 | 0.00087 | 0.00234 | 0.03061 |
+
+- Pinned spends more total dollars than query plus a reader until about 147 reads per pin (163 with the Sonnet
+ refresh model). Because it is right twice as often, it is already cheaper per correct answer at 10 reads per
+ write, and at 100 it costs a quarter as much.
+- Pinned is 3.2 times cheaper than `think` per correct answer at 1 read per write, 22 times at 10 and 55 times
+ at 100, and it is also more accurate.
+- The Sonnet refresh model cuts lifecycle cost by 36% ($0.415 against $0.649) for 2.8 points of accuracy.
+ It returned non-JSON on 2 of 72 refreshes; each time the pin kept its previous answer, which counts against
+ it.
+- Withdrawal is the weakest event. After `forget` in batch 7, 1 of 6 default-model answers and 2 of 6 Sonnet
+ answers missed the revert.
+- Leakage: 48 probes through a restricted MCP grant that cannot read private pages, covering search,
+ `get_page`, `context_pack` and `questions_status`, found 0 leaks.
+
+**Retrieval asymmetry.** Pinned refresh anchors retrieval on the pin's scope: the entity page first, then
+pages that link to it or name it, newest first, with question and synthesis pages excluded. Query plus a
+reader uses ordinary keyword retrieval, and `think` uses its own gather. Every arm is keyword-only because the
+harness brain has no embedding key. Query plus a reader fails here the way it does in real use: once notes
+pile up, keyword ranking treats every note that mentions the entity's city alike and often misses the newest.
+
+**Diagnostic attempt before the fix.** The first run-2 attempt, on 183fee7f, found pinned no better than query
+plus a reader (0.528 and 0.542 accuracy against 0.514). Pinned refresh retrieval had the same newest-note
+blind spot. baadfc04 fixed it in `src/core/questions/refresh.ts` with a regression test. The attempt is
+recorded in `verdict.json` as a diagnostic and was not a decision input.
+
+#### Models
+
+- Answer and refresh model: `anthropic:claude-opus-4-7`, gbrain's default for questions
+ (`models.standing_questions`, which resolves to the deep tier). The cost-lever arm refreshes with
+ `anthropic:claude-sonnet-5-5`.
+- `think` arm: the same default model.
+- Reader for the pinned and query arms: `anthropic:claude-sonnet-5-5`, the fixed reader of the B suites.
+
+Metered spend for run 2: $5.92 of the $10 cap ($2.98 for the deciding run and $2.93 for the diagnostic
+attempt).
+
+### Run 1: corrections rewrite the evidence page
+
+Measured build: gbrain a4267eed7. Verdict at the time: opt-in. Run 1 found that the benefit gate did not pass
+against query plus a reader. Accuracy was at the ceiling for every arm, and pinned answers did not cost less
+per correct answer until a pin had been read about 240 times.
+
The cost counted is total lifecycle dollars per correct, fresh answer: the first answer, every refresh
attempt, delivered read tokens and every model call. The workload is seeded and has 6 entities and
4 write batches. Each entity has a widget-factory city, and later batches correct some of those cities.
@@ -36,7 +114,7 @@ After each batch, every question is read 1 or 10 times, depending on the frozen
corrected, so no arm had a superseded value to repeat (stale-wrong is 0 everywhere). This run cannot show an
accuracy or freshness advantage. It decides on cost alone.
-### Models
+#### Models
- Answer and refresh model: `anthropic:claude-opus-4-7`. This is gbrain's default for questions
(`models.standing_questions`, which resolves to the deep tier).
@@ -65,10 +143,23 @@ tree. The suite covers:
## Reproduce
```bash
-bun evals/pinned-questions/benefit-gate.ts --plan --json --entities 6 --batches 4 --reader-model anthropic:claude-sonnet-5-5
+# Run 2 (deciding)
+bun evals/pinned-questions/appended-gate.ts --plan --json --entities 6 --seed 42 \
+ --reader-model anthropic:claude-sonnet-5-5 --refresh-models anthropic:claude-opus-4-7,anthropic:claude-sonnet-5-5
+bun evals/pinned-questions/appended-gate.ts --run --yes --max-usd 7 --entities 6 --seed 42 \
+ --reader-model anthropic:claude-sonnet-5-5 --refresh-models anthropic:claude-opus-4-7,anthropic:claude-sonnet-5-5 --json
+
+# Run 1
bun evals/pinned-questions/benefit-gate.ts --run --yes --max-usd 40 --entities 6 --batches 4 --seed 42 \
--reader-model anthropic:claude-sonnet-5-5 --json
```
-`verdict.json` carries the full run report, and `decision.json` records the arms, models, workload and
-budget.
+`verdict.json` carries both run reports and the diagnostic attempt, and `decision.json` records the arms,
+models, workloads, decision rule and budget.
+
+## Changelog
+
+- 2026-10-05, run 2: appended-corrections workload on baadfc04. Pinned beats query plus a reader on accuracy
+ and freshness with zero leakage, so the verdict moves from opt-in to default-on.
+- 2026-10-05, run 1: rewrite workload on a4267eed7. Every arm hit the accuracy ceiling and pinned did not win
+ on cost against query plus a reader, so pinned questions shipped opt-in.
diff --git a/docs/eval/decisions/c4-pinned-questions/decision.json b/docs/eval/decisions/c4-pinned-questions/decision.json
index bec1f879d5..e0bba0b65b 100644
--- a/docs/eval/decisions/c4-pinned-questions/decision.json
+++ b/docs/eval/decisions/c4-pinned-questions/decision.json
@@ -2,25 +2,29 @@
"schema_version": 1,
"decision_id": "c4-pinned-questions",
"plan": "MEMORY_PROOF_WAVE C4 + B5",
- "title": "Pinned questions: B5 safety gate and benefit gate (lifecycle dollars per correct fresh answer)",
+ "title": "Pinned questions: B5 safety gate and benefit gate (accuracy, freshness and lifecycle dollars per correct fresh answer)",
"verdict_type": "cost_quality",
"stage": "dev",
"candidate": {
- "gbrain": "garrytan/gbrain@a4267eed7bb6f9478df73fef6266b8a111a3891a",
+ "gbrain": "garrytan/gbrain@baadfc04064826e8c60dd8e67e0a55bf96f95c3f",
"arm": "pinned",
"config": {
"models.standing_questions": "anthropic:claude-opus-4-7",
"cycle.standing_questions.cooldown_days": "0"
+ },
+ "cost_lever_arm": {
+ "arm": "pinned",
+ "models.standing_questions": "anthropic:claude-sonnet-5-5"
}
},
"baselines": [
{
- "gbrain": "garrytan/gbrain@a4267eed7bb6f9478df73fef6266b8a111a3891a",
+ "gbrain": "garrytan/gbrain@baadfc04064826e8c60dd8e67e0a55bf96f95c3f",
"arm": "query_reader",
"note": "hybrid query (keyword-only: no embedding key in the harness brain) at the pinned answer's delivered-token budget, then one reader call"
},
{
- "gbrain": "garrytan/gbrain@a4267eed7bb6f9478df73fef6266b8a111a3891a",
+ "gbrain": "garrytan/gbrain@baadfc04064826e8c60dd8e67e0a55bf96f95c3f",
"arm": "think",
"note": "on-demand think per read with the default deep model"
}
@@ -29,9 +33,23 @@
"answer_and_refresh": "anthropic:claude-opus-4-7",
"think": "anthropic:claude-opus-4-7",
"reader": "anthropic:claude-sonnet-5-5",
- "selection": "answer/refresh and think: gbrain's default for questions (models.standing_questions -> deep tier); reader: the B-suite fixed reader"
+ "selection": "answer/refresh and think: gbrain's default for questions (models.standing_questions -> deep tier); reader: the B-suite fixed reader",
+ "refresh_cost_lever": "anthropic:claude-sonnet-5-5"
},
"sources": [
+ {
+ "kind": "seeded-workload",
+ "id": "pinned-questions-appended",
+ "run": "run_2",
+ "generator": "evals/pinned-questions/appended-gate.ts generateAppendedWorkload",
+ "seed": 42,
+ "entities": 6,
+ "write_batches": 12,
+ "writes_per_entity": 13,
+ "workload_hash": "ce95164d25dd0cb8",
+ "engine": "pglite",
+ "events": "corrections appended as dated notes (old pages left as written); conflicting notes in batch 4; remember in batch 6, forget in batch 7; newest note made private in batch 10"
+ },
{
"kind": "seeded-workload",
"id": "pinned-questions-benefit",
@@ -40,18 +58,22 @@
"entities": 6,
"write_batches": 4,
"workload_hash": "9428f19ffe229e66",
- "engine": "pglite"
+ "engine": "pglite",
+ "run": "run_1"
}
],
"frozen_reads_per_write": [
1,
- 10
+ 10,
+ 100
],
"metrics": [
+ "accuracy",
+ "stale_wrong_rate",
+ "freshness_lag_batches",
"usd_per_correct_fresh_answer",
- "correct",
- "stale_wrong",
- "break_even_reads"
+ "break_even_reads_per_pin",
+ "leakage"
],
"safety_gate": {
"suite": "test/helpers/pinned-questions-scenarios.ts",
@@ -62,8 +84,17 @@
"required": "zero stale-sentence or cross-grant leakage on every surface"
},
"budget": {
- "max_usd": 40,
- "metered_spend_usd": 2.3402
+ "run_2": {
+ "max_usd": 10,
+ "metered_spend_usd": 5.9164,
+ "note": "includes the 2.9324 pre-fix diagnostic attempt"
+ },
+ "run_1": {
+ "max_usd": 40,
+ "metered_spend_usd": 2.3402
+ }
},
- "reproduce": "bun evals/pinned-questions/benefit-gate.ts --run --yes --max-usd 40 --entities 6 --batches 4 --seed 42 --reader-model anthropic:claude-sonnet-5-5 --json"
+ "reproduce": "bun evals/pinned-questions/appended-gate.ts --run --yes --max-usd 7 --entities 6 --seed 42 --reader-model anthropic:claude-sonnet-5-5 --refresh-models anthropic:claude-opus-4-7,anthropic:claude-sonnet-5-5 --json",
+ "decision_rule": "Set before run 2: if pinned beats query+reader on accuracy or freshness without leakage, ship default-on (plan C1); otherwise opt-in stands.",
+ "reproduce_run_1": "bun evals/pinned-questions/benefit-gate.ts --run --yes --max-usd 40 --entities 6 --batches 4 --seed 42 --reader-model anthropic:claude-sonnet-5-5 --json"
}
diff --git a/docs/eval/decisions/c4-pinned-questions/verdict.json b/docs/eval/decisions/c4-pinned-questions/verdict.json
index 84c88040ee..4d051e65c8 100644
--- a/docs/eval/decisions/c4-pinned-questions/verdict.json
+++ b/docs/eval/decisions/c4-pinned-questions/verdict.json
@@ -2,8 +2,9 @@
"decision_id": "c4-pinned-questions",
"plan": "MEMORY_PROOF_WAVE C4 + B5",
"stage": "dev",
- "decided_at": "2026-10-05T09:30:00Z",
- "measured_build": "garrytan/gbrain@a4267eed7bb6f9478df73fef6266b8a111a3891a",
+ "decided_at": "2026-10-05T18:00:00Z",
+ "measured_build": "garrytan/gbrain@baadfc04064826e8c60dd8e67e0a55bf96f95c3f",
+ "deciding_run": "run_2",
"safety_gate": {
"status": "pass",
"scenarios": 33,
@@ -11,102 +12,533 @@
"pglite": "33/33",
"postgres": "33/33"
},
- "full_ci": "bun run ci:ubicloud green on garrytan/gbrain@2b1f5b69 (capy/mpw-integration)"
+ "full_ci": "bun run ci:ubicloud: see the pushed integration head in README",
+ "appended_workload_leakage": {
+ "probes": 48,
+ "leaks": 0,
+ "surfaces": [
+ "search",
+ "get_page",
+ "context_pack",
+ "questions_status"
+ ],
+ "grant": "restricted MCP grant that cannot read private pages"
+ }
},
"benefit_gate": {
- "status": "fail",
+ "status": "pass",
"against": {
- "query_reader": "fail",
+ "query_reader": "pass",
"think": "pass"
},
- "reason": "Accuracy is at ceiling for every arm (100% correct, 0 stale-wrong), so the gate is decided on lifecycle cost. Pinned costs 4.4x query+reader per correct answer at 1 read per write and matches it at 10 reads per write ($0.000526 vs $0.000529); break-even is about 240 reads per pin. Pinned is 3.3x (1 read/write) to 14.5x (10 reads/write) cheaper than on-demand think."
+ "reason": "On the appended-corrections workload pinned answers with the default model were correct on 98.6% of reads versus 51.4% for query+reader and 79.2% for think, with 0% stale-wrong versus 48.6% and 20.8%. Mean freshness lag was 0.017 write batches versus 0.583 and 0.25. Zero leaks in 48 restricted-grant probes. Decision rule (set before the run): pinned beating query+reader on accuracy or freshness without leakage means default-on; it beats it on both."
},
- "overall": "opt_in",
- "default_decision": "Pinned questions ship opt-in: the feature does nothing until the owner pins a question, and no pin is created by default. Default-on is withheld because the benefit gate did not pass against query+reader.",
- "ceiling_note": "Every arm answered every read correctly; the workload rewrites the evidence page on correction, so no arm had a superseded value to repeat. The run cannot show an accuracy or freshness difference.",
- "metered_spend_usd": 2.3402,
- "run": {
- "mode": "run",
- "workload_hash": "9428f19ffe229e66",
+ "overall": "default_on",
+ "default_decision": "Pinned questions ship on. The standing_questions phase, publishing and context_pack delivery of fresh pinned answers are on by default (cycle.standing_questions.enabled=true, publish_mode=publish). Pinning a question remains the consent for its paid refresh, as plan C1 specifies, so no pin is created automatically and a brain with no pins makes no model call. Migrated dream.auto_think questions keep their old enabled, budget and auto_commit state. No shipped default changes relative to run 1; the verdict label moves from opt_in to default_on.",
+ "caveats": [
+ "Retrieval asymmetry: the run-2 build anchors pinned refresh retrieval on the pin scope (entity page first, then pages that link to or name it, newest first). query+reader uses ordinary keyword query retrieval and think its own gather, both without that anchoring. The accuracy gap is partly this retrieval difference; a pin has a scope and an ad hoc query does not.",
+ "Keyword-only retrieval for every arm: the harness brain has no embedding key.",
+ "Cost: pinned with the default model costs more total dollars than query+reader until about 147 reads per pin (163 with the Sonnet refresh model). Per correct answer it costs 4.1x query+reader at 1 read per write, 0.59x at 10 and 0.24x at 100.",
+ "Withdrawal is the weakest event: 1 of 6 (default model) and 2 of 6 (Sonnet) pinned answers missed the revert after forget in batch 7.",
+ "Sonnet refresh returned non-JSON twice in 72 attempts (model_output_not_json); the pin kept its previous answer, which counts against it.",
+ "One seed, 6 entities; dev stage."
+ ],
+ "metered_spend_usd": 5.9164,
+ "run_2": {
+ "workload": "appended",
+ "workload_hash": "ce95164d25dd0cb8",
"seed": 42,
"entities": 6,
- "batches": 4,
- "answer_model": "anthropic:claude-opus-4-7",
+ "batches": 12,
+ "states": 72,
"reader_model": "anthropic:claude-sonnet-5-5",
- "metered_spend_usd": 2.3401960000000015,
- "reports": [
+ "think_model": "anthropic:claude-opus-4-7",
+ "refresh_models": [
+ "anthropic:claude-opus-4-7",
+ "anthropic:claude-sonnet-5-5"
+ ],
+ "frozen_reads_per_write": [
+ 1,
+ 10,
+ 100
+ ],
+ "metered_spend_usd": 2.9839,
+ "leakage": {
+ "probes": 48,
+ "leaks": []
+ },
+ "refresh_failures": {
+ "model_output_not_json": 2,
+ "refresh_model": "anthropic:claude-sonnet-5-5"
+ },
+ "summary": [
{
"reads_per_write": 1,
- "arms": [
- {
- "arm": "pinned",
- "reads": 24,
- "correct": 24,
- "stale_wrong": 0,
- "usd": 0.055947,
- "usd_per_correct": 0.002331125
- },
- {
- "arm": "query_reader",
- "reads": 24,
- "correct": 24,
- "stale_wrong": 0,
- "usd": 0.012694,
- "usd_per_correct": 0.0005289166666666667
- },
- {
- "arm": "think",
- "reads": 24,
- "correct": 24,
- "stale_wrong": 0,
- "usd": 0.18278499999999998,
- "usd_per_correct": 0.007616041666666666
- }
- ],
- "pinned_breakdown": {
- "pin_and_refresh_usd": 0.048025,
- "read_usd": 0.007921999999999998,
- "refresh_attempts": 14
- },
- "break_even_reads": 242,
- "plumbing_only": false
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.986111,
+ "stale_wrong_rate": 0,
+ "lifecycle_usd": 0.64916,
+ "usd": 0.68241,
+ "usd_per_correct": 0.009611,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.0167,
+ "correct_at_change": 0.9833
+ }
+ },
+ {
+ "reads_per_write": 1,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 0.086432,
+ "usd_per_correct": 0.002336,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 1,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 1.74488,
+ "usd_per_correct": 0.030612,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 1,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.958333,
+ "stale_wrong_rate": 0.013889,
+ "lifecycle_usd": 0.414458,
+ "usd": 0.470192,
+ "usd_per_correct": 0.006814,
+ "break_even_reads_per_pin": 163,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.05,
+ "correct_at_change": 0.95
+ }
},
{
"reads_per_write": 10,
- "arms": [
- {
- "arm": "pinned",
- "reads": 240,
- "correct": 240,
- "stale_wrong": 0,
- "usd": 0.1262400000000003,
- "usd_per_correct": 0.0005260000000000012
- },
- {
- "arm": "query_reader",
- "reads": 240,
- "correct": 240,
- "stale_wrong": 0,
- "usd": 0.12697999999999998,
- "usd_per_correct": 0.0005290833333333332
- },
- {
- "arm": "think",
- "reads": 240,
- "correct": 240,
- "stale_wrong": 0,
- "usd": 1.835549999999999,
- "usd_per_correct": 0.007648124999999995
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.986111,
+ "stale_wrong_rate": 0,
+ "lifecycle_usd": 0.64916,
+ "usd": 0.98166,
+ "usd_per_correct": 0.001383,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.0167,
+ "correct_at_change": 0.9833
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 0.86432,
+ "usd_per_correct": 0.002336,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 17.4488,
+ "usd_per_correct": 0.030612,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.958333,
+ "stale_wrong_rate": 0.013889,
+ "lifecycle_usd": 0.414458,
+ "usd": 0.971798,
+ "usd_per_correct": 0.001408,
+ "break_even_reads_per_pin": 163,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.05,
+ "correct_at_change": 0.95
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.986111,
+ "stale_wrong_rate": 0,
+ "lifecycle_usd": 0.64916,
+ "usd": 3.97416,
+ "usd_per_correct": 0.00056,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.0167,
+ "correct_at_change": 0.9833
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 8.6432,
+ "usd_per_correct": 0.002336,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 174.488,
+ "usd_per_correct": 0.030612,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.958333,
+ "stale_wrong_rate": 0.013889,
+ "lifecycle_usd": 0.414458,
+ "usd": 5.987858,
+ "usd_per_correct": 0.000868,
+ "break_even_reads_per_pin": 163,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.05,
+ "correct_at_change": 0.95
+ }
+ }
+ ],
+ "diagnostic_pre_fix_attempt": {
+ "measured_build": "garrytan/gbrain@183fee7f (refresh retrieval without scope anchoring)",
+ "metered_spend_usd": 2.9324,
+ "finding": "Pinned refresh retrieval ranked every note sharing the question words alike and missed each entity newest note once notes accumulated, so pinned matched query+reader (0.528/0.542 vs 0.514 accuracy). Fixed in baadfc04 (src/core/questions/refresh.ts anchoredSlugs) with a regression test; not a decision input.",
+ "summary": [
+ {
+ "reads_per_write": 1,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.527778,
+ "stale_wrong_rate": 0.458333,
+ "lifecycle_usd": 0.622705,
+ "usd": 0.658259,
+ "usd_per_correct": 0.017323,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5667,
+ "correct_at_change": 0.5
}
- ],
- "pinned_breakdown": {
- "pin_and_refresh_usd": 0.047859999999999986,
- "read_usd": 0.07838000000000032,
- "refresh_attempts": 14
},
- "break_even_reads": 237,
- "plumbing_only": false
- }
- ]
+ {
+ "reads_per_write": 1,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 0.086568,
+ "usd_per_correct": 0.00234,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 1,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 1.74198,
+ "usd_per_correct": 0.030561,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 1,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.541667,
+ "stale_wrong_rate": 0.444444,
+ "lifecycle_usd": 0.389088,
+ "usd": 0.445642,
+ "usd_per_correct": 0.011427,
+ "break_even_reads_per_pin": 156,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.55,
+ "correct_at_change": 0.5
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.527778,
+ "stale_wrong_rate": 0.458333,
+ "lifecycle_usd": 0.622705,
+ "usd": 0.978245,
+ "usd_per_correct": 0.002574,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5667,
+ "correct_at_change": 0.5
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 0.86568,
+ "usd_per_correct": 0.00234,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 17.4198,
+ "usd_per_correct": 0.030561,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 10,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.541667,
+ "stale_wrong_rate": 0.444444,
+ "lifecycle_usd": 0.389088,
+ "usd": 0.954628,
+ "usd_per_correct": 0.002448,
+ "break_even_reads_per_pin": 156,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.55,
+ "correct_at_change": 0.5
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-opus-4-7",
+ "accuracy": 0.527778,
+ "stale_wrong_rate": 0.458333,
+ "lifecycle_usd": 0.622705,
+ "usd": 4.178105,
+ "usd_per_correct": 0.0011,
+ "break_even_reads_per_pin": 147,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5667,
+ "correct_at_change": 0.5
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "query_reader",
+ "accuracy": 0.513889,
+ "stale_wrong_rate": 0.486111,
+ "lifecycle_usd": 0,
+ "usd": 8.6568,
+ "usd_per_correct": 0.00234,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.5833,
+ "correct_at_change": 0.4833
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "think",
+ "accuracy": 0.791667,
+ "stale_wrong_rate": 0.208333,
+ "lifecycle_usd": 0,
+ "usd": 174.198,
+ "usd_per_correct": 0.030561,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.25,
+ "correct_at_change": 0.7833
+ }
+ },
+ {
+ "reads_per_write": 100,
+ "arm": "pinned",
+ "refresh_model": "anthropic:claude-sonnet-5-5",
+ "accuracy": 0.541667,
+ "stale_wrong_rate": 0.444444,
+ "lifecycle_usd": 0.389088,
+ "usd": 6.044488,
+ "usd_per_correct": 0.00155,
+ "break_even_reads_per_pin": 156,
+ "freshness": {
+ "changes": 60,
+ "mean_lag_batches": 0.55,
+ "correct_at_change": 0.5
+ }
+ }
+ ]
+ }
+ },
+ "run_1": {
+ "measured_build": "garrytan/gbrain@a4267eed7bb6f9478df73fef6266b8a111a3891a",
+ "benefit_gate": {
+ "status": "fail",
+ "against": {
+ "query_reader": "fail",
+ "think": "pass"
+ },
+ "reason": "Accuracy is at ceiling for every arm (100% correct, 0 stale-wrong), so the gate is decided on lifecycle cost. Pinned costs 4.4x query+reader per correct answer at 1 read per write and matches it at 10 reads per write ($0.000526 vs $0.000529); break-even is about 240 reads per pin. Pinned is 3.3x (1 read/write) to 14.5x (10 reads/write) cheaper than on-demand think."
+ },
+ "overall": "opt_in",
+ "default_decision": "Pinned questions ship opt-in: the feature does nothing until the owner pins a question, and no pin is created by default. Default-on is withheld because the benefit gate did not pass against query+reader.",
+ "ceiling_note": "Every arm answered every read correctly; the workload rewrites the evidence page on correction, so no arm had a superseded value to repeat. The run cannot show an accuracy or freshness difference.",
+ "metered_spend_usd": 2.3402,
+ "run": {
+ "mode": "run",
+ "workload_hash": "9428f19ffe229e66",
+ "seed": 42,
+ "entities": 6,
+ "batches": 4,
+ "answer_model": "anthropic:claude-opus-4-7",
+ "reader_model": "anthropic:claude-sonnet-5-5",
+ "metered_spend_usd": 2.3401960000000015,
+ "reports": [
+ {
+ "reads_per_write": 1,
+ "arms": [
+ {
+ "arm": "pinned",
+ "reads": 24,
+ "correct": 24,
+ "stale_wrong": 0,
+ "usd": 0.055947,
+ "usd_per_correct": 0.002331125
+ },
+ {
+ "arm": "query_reader",
+ "reads": 24,
+ "correct": 24,
+ "stale_wrong": 0,
+ "usd": 0.012694,
+ "usd_per_correct": 0.0005289166666666667
+ },
+ {
+ "arm": "think",
+ "reads": 24,
+ "correct": 24,
+ "stale_wrong": 0,
+ "usd": 0.18278499999999998,
+ "usd_per_correct": 0.007616041666666666
+ }
+ ],
+ "pinned_breakdown": {
+ "pin_and_refresh_usd": 0.048025,
+ "read_usd": 0.007921999999999998,
+ "refresh_attempts": 14
+ },
+ "break_even_reads": 242,
+ "plumbing_only": false
+ },
+ {
+ "reads_per_write": 10,
+ "arms": [
+ {
+ "arm": "pinned",
+ "reads": 240,
+ "correct": 240,
+ "stale_wrong": 0,
+ "usd": 0.1262400000000003,
+ "usd_per_correct": 0.0005260000000000012
+ },
+ {
+ "arm": "query_reader",
+ "reads": 240,
+ "correct": 240,
+ "stale_wrong": 0,
+ "usd": 0.12697999999999998,
+ "usd_per_correct": 0.0005290833333333332
+ },
+ {
+ "arm": "think",
+ "reads": 240,
+ "correct": 240,
+ "stale_wrong": 0,
+ "usd": 1.835549999999999,
+ "usd_per_correct": 0.007648124999999995
+ }
+ ],
+ "pinned_breakdown": {
+ "pin_and_refresh_usd": 0.047859999999999986,
+ "read_usd": 0.07838000000000032,
+ "refresh_attempts": 14
+ },
+ "break_even_reads": 237,
+ "plumbing_only": false
+ }
+ ]
+ },
+ "decided_at": "2026-10-05T09:30:00Z"
}
}
diff --git a/test/pinned-questions-appended-gate.test.ts b/test/pinned-questions-appended-gate.test.ts
index d9dce46aa8..b3d87e6ce1 100644
--- a/test/pinned-questions-appended-gate.test.ts
+++ b/test/pinned-questions-appended-gate.test.ts
@@ -6,7 +6,8 @@
* does find the private note once the operator exposes private pages (so a
* zero is not vacuous); ratio weighting keeps lifecycle cost fixed. No network.
*/
-import { describe, expect, test } from 'bun:test';
+import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { resetPgliteState } from './helpers/reset-pglite.ts';
import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { submitPageMutation } from '../src/core/persistence/page-mutations.ts';
import { __resetPrivateVisibilityCacheForTests } from '../src/core/search/private-visibility.ts';
@@ -26,9 +27,9 @@ describe('appended-corrections benefit gate (offline plumbing)', () => {
const g = w.gold[e.slug]!;
const ev = w.batches.map(b => b.filter(x => x.entity === e.slug));
expect(g).toHaveLength(12);
- expect(g[4]).toBe(ev[4]!.find(x => x.kind === 'conflict_b')!.city);
+ expect(g[4]).toBe(ev[4]!.find(x => x.kind === 'conflict_b')!.city!);
expect(ev[4]!.find(x => x.kind === 'conflict_a')!.city).not.toBe(g[4]);
- expect(g[6]).toBe(ev[6]!.find(x => x.kind === 'remember')!.city);
+ expect(g[6]).toBe(ev[6]!.find(x => x.kind === 'remember')!.city!);
expect(g[7]).toBe(g[5]);
expect(g[6]).not.toBe(g[5]);
expect(g[10]).toBe(g[9]);
@@ -53,41 +54,46 @@ describe('appended-corrections benefit gate (offline plumbing)', () => {
expect(at1.freshness.changes).toBeGreaterThan(0);
}, 180_000);
- test('the leakage probe catches a private note once private pages are exposed to remote readers', async () => {
- const engine = new PGLiteEngine();
- await engine.connect({});
- await engine.initSchema();
- try {
- const w = generateAppendedWorkload(3, 1);
- const ctx = { engine, config: { engine: 'pglite', embedding_disabled: true } as never, remote: false, sourceId: 'default', dryRun: false, logger: { info() {}, warn() {}, error() {} } };
- await submitPageMutation(ctx, { operation: 'put_page', params: { slug: 'notes/example-1-update-9', content: '---\ntype: note\ntitle: secret\nvisibility: private\n---\nAs of 2026-05-10, example-1 builds widgets in Ghent.\n' } });
- expect((await leakageProbe(engine, w, [])).leaks).toEqual([]);
- await engine.setConfig('search.remote_private_pages', 'visible');
- __resetPrivateVisibilityCacheForTests();
- expect((await leakageProbe(engine, w, [])).leaks.length).toBeGreaterThan(0);
- } finally {
- __resetPrivateVisibilityCacheForTests();
- await engine.disconnect();
- }
- }, 120_000);
+ describe('on a PGLite brain', () => {
+ let engine: PGLiteEngine;
+ beforeAll(async () => {
+ engine = new PGLiteEngine();
+ await engine.connect({});
+ await engine.initSchema();
+ });
+ afterAll(async () => { await engine.disconnect(); });
+ beforeEach(async () => { await resetPgliteState(engine); });
- test('refresh retrieval keeps each entity\'s newest note in evidence once notes accumulate', async () => {
- const engine = new PGLiteEngine();
- await engine.connect({});
- await engine.initSchema();
- try {
- const w = generateAppendedWorkload(42, 6);
- const remembered = new Map<string, string>();
- for (const batch of w.batches) await applyEventsForTest(engine, batch, remembered);
- for (const e of w.entities) {
- const question = `Which city does ${e.name} build widgets in now?`;
- const scope = { source: 'default', entity: e.slug };
- const { row } = await insertPin(engine, { sourceId: 'default', slug: questionSlug(question, scope), question, scope, state: 'active', inactiveReason: null, publishMode: 'publish', createdBy: 'cli' });
- const pages = (await retrieveEvidence(engine, row)).filter(i => i.kind === 'page').map(i => i.page_slug);
- expect(pages.slice(0, 2)).toEqual([e.slug, `notes/${e.name}-update-11`]);
+ test('the leakage probe catches a private note once private pages are exposed to remote readers', async () => {
+ try {
+ const w = generateAppendedWorkload(3, 1);
+ const ctx = { engine, config: { engine: 'pglite', embedding_disabled: true } as never, remote: false, sourceId: 'default', dryRun: false, logger: { info() {}, warn() {}, error() {} } };
+ await submitPageMutation(ctx, { operation: 'put_page', params: { slug: 'notes/example-1-update-9', content: '---\ntype: note\ntitle: secret\nvisibility: private\n---\nAs of 2026-05-10, example-1 builds widgets in Ghent.\n' } });
+ expect((await leakageProbe(engine, w, [])).leaks).toEqual([]);
+ await engine.setConfig('search.remote_private_pages', 'visible');
+ __resetPrivateVisibilityCacheForTests();
+ expect((await leakageProbe(engine, w, [])).leaks.length).toBeGreaterThan(0);
+ } finally {
+ await engine.setConfig('search.remote_private_pages', 'hidden');
+ __resetPrivateVisibilityCacheForTests();
}
- } finally {
- await engine.disconnect();
- }
- }, 120_000);
+ }, 120_000);
+
+ test('refresh retrieval keeps each entity\'s newest note in evidence once notes accumulate', async () => {
+ try {
+ const w = generateAppendedWorkload(42, 6);
+ const remembered = new Map<string, string>();
+ for (const batch of w.batches) await applyEventsForTest(engine, batch, remembered);
+ for (const e of w.entities) {
+ const question = `Which city does ${e.name} build widgets in now?`;
+ const scope = { source: 'default', entity: e.slug };
+ const { row } = await insertPin(engine, { sourceId: 'default', slug: questionSlug(question, scope), question, scope, state: 'active', inactiveReason: null, publishMode: 'publish', createdBy: 'cli' });
+ const pages = (await retrieveEvidence(engine, row)).filter(i => i.kind === 'page').map(i => i.page_slug);
+ expect(pages.slice(0, 2)).toEqual([e.slug, `notes/${e.name}-update-11`]);
+ }
+ } finally {
+ __resetPrivateVisibilityCacheForTests();
+ }
+ }, 120_000);
+ });
});