Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
W6: counted result — GRADE_TAKES_MEASURED_MODELS = gpt-6.1-sol for prompt hybrid-evidence-v2
garrytanae48f8b84ff6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bb5c70da81..b8d5a524ca 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,7 +28,7 @@ Nothing. Verdicts are cached per prompt version, so the next cycles grade each e### For contributors-`evals/take-grading/` holds the eval (908 seeded synthetic takes, dev and counted splits, `--check` at $0) and its preregistration. `GRADE_TAKES_MEASURED_MODELS` (`src/core/cycle/grade-takes-measured.ts`) stays empty until the counted run.+`evals/take-grading/` holds the eval (908 seeded synthetic takes, dev and counted splits, `--check` at $0) and its preregistration. On the counted split (790 takes, $9.25), `gpt-6.1-sol` qualified: 496 applied verdicts, none wrong (95% upper bound 0.6%, bar 1%), so `GRADE_TAKES_MEASURED_MODELS` (`src/core/cycle/grade-takes-measured.ts`) lists it. `claude-sonnet-5-5` (121 applied, 1 wrong) and `claude-opus-5-5` (2 applied: right verdicts, confidence below 0.95) did not. Results are mirrored in gbrain-evals.## [0.60.274.0] - 2026-10-17diff --git a/docs/architecture/key-files/hindsight.md b/docs/architecture/key-files/hindsight.mdindex da213cf493..287141dd0d 100644--- a/docs/architecture/key-files/hindsight.md+++ b/docs/architecture/key-files/hindsight.md@@ -24,7 +24,7 @@ unresolvable+true|false, pre-v80 NULL/NULL rows survive).- `src/core/cycle/base-phase.ts` — abstract `BaseCyclePhase` class. Enforces `sourceScopeOpts(ctx)` threading at the type level; rules out the source-isolation leak class structurally for every new phase. Inherits source-scope, budget meter, error envelope, progress reporter. propose_takes / grade_takes / calibration_profile all extend it. `run()` honors dry-run for every subclass at once: when `opts.dryRun` or `ctx.dryRun === true`, it returns `status: 'skipped'` / `reason: 'no_dry_run_support'` before `process()` (no LLM calls, no take_proposals / take_grade_cache / calibration_profiles writes) — the same skip shape extract and resolve_symbol_edges use; runCycle threads `dryRun` into all three call sites. The ONE home of `CYCLE_DEADLINE_RESERVE_MS` (60s carved out of the enclosing job's remaining wall-clock — wait-poll + worker force-evict grace + cleanup headroom; patterns.ts re-exports it) and of `BasePhaseOpts.deadlineAtMs` (the enclosing minion job's absolute deadline, threaded via runCycle; null/unset for direct `gbrain dream` callers — phases then fall back to their derived defaults).- `src/core/cycle/propose-takes.ts` — LLM scans markdown prose, proposes gradeable claims to the `take_proposals` queue. Candidate discovery excludes `extract_receipt` pages before the LLM call so the phase never re-ingests its own operational receipts; nullable legacy page types remain eligible. `cycle.propose_takes.types` (#5213; `proposeTakesTypes`, a JSON array of page types in the `cycle.enrich_thin.types` shape) narrows the candidate query to those types with `type = ANY(...)` on top of the source scope; unset keeps every type eligible and a malformed value is ignored with one stderr line. Idempotency cache on `(source_id, page_slug, content_hash, prompt_version)` composite unique index. Fence-dedup: existing canonical takes passed to the extractor as context. Opt-in `dream.propose_takes.attribution_rules=true` adds `EXTRACT_TAKES_ATTRIBUTION_RULES` (withdrawn claims, assistant-authored judgments not attributed to the user) under prompt version suffix `+attribution5425`; off by default because it measured lower cat15 recall. Ships a stub prompt; tuned prompt arrives via the synthetic corpus build. Per-page extractor failures log a warning and continue, but a whole-run condition (per `classifyGlobalLlmError` in `src/core/ai/errors.ts`) breaks the page loop with a single combined warning line, sets `aborted_global_error`, and records a halt in the rollup — auth/billing on the first hit, bare rate_limit only after `RATE_LIMIT_HALT_STREAK` (3) consecutive hits (a successful call resets the streak). Status: `fail` when the halt happened with ZERO successful extractor calls (the whole LLM lane is down), otherwise any warnings fold into `warn` + ` (N warning(s))` summary suffix, so swallowed failures can't read as a clean `ok`. `llm_calls_succeeded`/`llm_calls_failed`/`halted` land in details. The phase wall-clock deadline is DERIVED, never a literal (a literal equal to the autopilot-cycle handler anchor, with non-co-started clocks, would make the clean `deadline_hit` partial-completion path structurally unreachable): explicit `opts.deadlineMs` wins (test seam), else `resolveProposeTakesDeadlineMs(deadlineAtMs, now)` = `PHASE_DEADLINE_FRACTION_OF_JOB` (0.8, headroom for grade_takes + calibration_profile which run after it with no deadline of their own) × (remaining job budget − `CYCLE_DEADLINE_RESERVE_MS`), clamped to the fallback (0.8 × the `autopilot-cycle` entry in `HANDLER_DEFAULT_TIMEOUT_MS` — a missing anchor throws at module LOAD, failing the whole cycle visibly). A fractioned value under `MIN_PROPOSE_TAKES_BUDGET_MS` (2 min) resolves to null and the phase returns an honest `skipped` with `reason: 'insufficient_cycle_budget'` (after the cheap provider probe, before any rollup/DB write — records neither a halt nor a completed round; next cycle retries with a fresh budget). Pinned by `test/propose-takes.test.ts` + `test/propose-takes-per-claim.test.ts` + `test/cycle-phase-deadline-drift.test.ts`. The kind vocabulary is `TAKE_KIND_VALUES` imported from `src/core/takes-fence.ts` (the fence enum — no hand-copied set); an unknown kind maps through the legacy-kind table, else `take`. `dream.propose_takes.call_timeout_ms` (whole ms 1000..300000; `config set` refuses others, a stored out-of-range value is clamped and a non-number ignored, each with a named-key phase warning) replaces the output-cap scaling for every extractor call, held to the phase time left (never below 90 s); a call its own bound stops fails per page with an error naming the key. Pinned by `test/propose-takes-config-max-tokens.test.ts` + `test/propose-takes-truncation.test.ts`. #5212: `listCandidatePages` also skips the dream cycle's own output by its writer stamps (`dream_generated = true`, `extracted_by LIKE 'extract_atoms%'`, `synthesized_by LIKE 'synthesize_concepts%'`), pinned on PGLite (`test/propose-takes-per-claim.test.ts`) and Postgres (`test/e2e/propose-takes-jsonb-postgres.test.ts`). The mechanical holder check of #5425 [UC4] (`cycle/propose-takes-attribution.ts`, one call after the extractor returns, behind `dream.attribution_checks`, default off) is separate from the prompt rule and documented with that module.- `src/core/cycle/grade-takes.ts` — walks unresolved takes older than 6 months, retrieves evidence, asks judge model, caches verdict. Auto-resolve DISABLED by default. Conservative thresholds: >=0.95 single OR >=0.85 ensemble 3/3 unanimous. `aggregateEnsemble` reuses the cross-modal substrate; fires on the borderline 0.6-0.95 band. Writes to `take_grade_cache`. Same global-error posture as propose-takes: a judge failure that classifies as a whole-run condition breaks the take loop with `aborted_global_error` (auth/billing first hit; rate_limit after 3 consecutive takes; `fail` status when zero judge calls succeeded, else `warn` + warning count; `judge_calls_succeeded`/`judge_calls_failed`/`halted` in details). Rejected ensemble judges are classified the same way — `Promise.allSettled` never flattens a revoked key or exhausted spend limit into a silent null verdict. Per-take auto-apply failures stay per-take.-- `src/core/cycle/grade-takes-measured.ts` — `GRADE_TAKES_MEASURED_MODELS` (the judges that met the W6 take-grading eval's preregistered rule, `evals/take-grading/PREREGISTRATION.md`; empty until the counted run) and `gradeJudgeMeasured()`, which `gbrain takes grades` (`cmdGrades` in `src/commands/takes.ts`, trusted local, no MCP op) uses to mark cached verdicts no measurement backs. Auto-resolve stays unwired.+- `src/core/cycle/grade-takes-measured.ts` — `GRADE_TAKES_MEASURED_MODELS` (the judges that met the W6 take-grading eval's preregistered rule, `evals/take-grading/PREREGISTRATION.md`; `openai:gpt-6.1-sol` since the 2026-10-16 counted run) and `gradeJudgeMeasured()`, which `gbrain takes grades` (`cmdGrades` in `src/commands/takes.ts`, trusted local, no MCP op) uses to mark cached verdicts no measurement backs. Auto-resolve stays unwired.- `src/core/cycle/calibration-profile.ts` — aggregates resolved takes into 2-4 narrative pattern statements + active bias tags. Voice-gated via `gateVoice()`. Cold-brain skip when <5 resolved. Writes to `calibration_profiles` with audit columns (`voice_gate_passed`, `voice_gate_attempts`, `grade_completion`).- `src/core/calibration/voice-gate.ts` — single `gateVoice()` function, mode parameter (`pattern_statement` | `nudge` | `forecast_blurb` | `dashboard_caption` | `morning_pulse`). 2 regens then template fallback from `src/core/calibration/templates.ts`. Haiku judge with mode-specific rubrics; all rubrics structurally forbid clinical/preachy voice.- `src/core/calibration/gstack-coupling.ts` — outcome-driven learnings coupling. `writeIncorrectResolution(opts)` shells out to the `gstack-learnings-log` binary. Config gate `cycle.grade_takes.write_gstack_learnings` (default false for external users). Namespace prefix `gbrain:calibration:v0.36.1.0:` so `--undo-wave` can scrub.diff --git a/evals/take-grading/README.md b/evals/take-grading/README.mdindex d38fdf5ac9..b1e2683cfc 100644--- a/evals/take-grading/README.md+++ b/evals/take-grading/README.md@@ -4,7 +4,19 @@ Measures which chat models may grade a forecasting take: when the `grade_takes`## Current result-Not yet measured on the counted split; `GRADE_TAKES_MEASURED_MODELS` is empty. The dev rounds that shaped prompt `hybrid-evidence-v2` and the parser are summarized in the preregistration.+Measured 2026-10-16 at gbrain `d99b84694` (branch `capy/w6-take-grading`, prompt `hybrid-evidence-v2`, threshold 0.95), the commit that froze the preregistration; one run per model over the 790 counted takes, $9.25 in all. Only gpt-6.1-sol qualifies.++| Model | Applied | Wrong applied | Upper 95% | Coverage | Abstention | No answer | USD per verdict | Latency p50 / p95 | Qualifies |+|---|---|---|---|---|---|---|---|---|---|+| `openai:gpt-6.1-sol` | 496 | 0 | 0.6% | 99.2% | 100% | 1 | $0.0016 | 2.4 s / 3.2 s | yes |+| `anthropic:claude-sonnet-5-5` | 121 | 1 | 3.9% | 24.0% | 99.6% | 14 | $0.0032 | 1.7 s / 4.5 s | no |+| `anthropic:claude-opus-5-5` | 2 | 0 | 77.6% | 0.4% | 100% | 3 | $0.0069 | 2.7 s / 4.9 s | no |++So `GRADE_TAKES_MEASURED_MODELS` is `openai:gpt-6.1-sol`, for verdicts asked with prompt `hybrid-evidence-v2` (`GRADE_TAKES_MEASURED_PROMPT_VERSION`). gpt-6.1-sol gave the gold verdict on every one of the 750 takes in the rule and held back on every unresolvable one; it sits near the ceiling of these synthetic fixtures, so the result says the judge reads clean evidence correctly, not how it does on a real brain's messier evidence. Opus 5.5 gave the gold verdict on all 500 resolvable takes but at confidence below 0.95 on all but two, so the rule applies almost none of its verdicts; it called 5 pre-horizon takes `incorrect` below the threshold. Sonnet 5.5's one wrong applied verdict (`counted-world_no_evidence-013`) graded a real-world proposition with no evidence from its own knowledge; it also called 13 pre-horizon takes `incorrect` below the threshold.++Exploratory sets, outside the rule: on `partial` (a stated target missed by a margin), all three models answer `incorrect` (gpt-6.1-sol 18 of 20, applied at 0.96 or more), so whether a shortfall is `partial` or `incorrect` is a grading policy to settle before auto-resolve. On `world_counterfactual`, gpt-6.1-sol applied all 20 verdicts on the brain's evidence over the real outcome; Sonnet 5.5 and Opus 5.5 applied none.++Of the 18 answers with no verdict, 12 (Sonnet 5.5 9, Opus 5.5 3) used the judge's whole 600-token output ceiling and left a short or empty visible answer, so the Anthropic models spend the ceiling on thinking; the judge call passes no thinking setting. Four were Sonnet 5.5 JSON with a stray trailing `,"}`, one was gpt-6.1-sol JSON missing its closing brace, and one was a Sonnet 5.5 answer that corrected itself from `incorrect` to `correct`, which the parser rejects by design. A thinking setting or a larger ceiling for the judge, and a tolerant parse of the trailing comma, are proposed for a later dated preregistration and not changed here; each costs coverage, never correctness. Raw rows, `summary.json`, `summary.md` and `verdict.json` live in gbrain-evals (`docs/benchmarks/2026-10-16-take-grading/`); nothing is committed under `results/` here.## What's herediff --git a/src/commands/takes.ts b/src/commands/takes.tsindex 65b7257b94..ed568d0607 100644--- a/src/commands/takes.ts+++ b/src/commands/takes.ts@@ -312,7 +312,8 @@ async function cmdScorecard(engine: BrainEngine, args: string[]): Promise<void>* W6: the review surface for grade_takes. The cycle caches a verdict per take* (`take_grade_cache`) and, with auto-resolve off, applies none; this lists* the newest verdict per take so the owner can review them, marking verdicts- * whose judge model the W6 eval did not measure (`GRADE_TAKES_MEASURED_MODELS`).+ * whose judge model and prompt the W6 eval did not measure+ * (`GRADE_TAKES_MEASURED_MODELS`, `GRADE_TAKES_MEASURED_PROMPT_VERSION`).* Trusted local only: there is no MCP op, so a thin client refuses it.*/async function cmdGrades(engine: BrainEngine, args: string[]): Promise<void> {@@ -367,7 +368,7 @@ async function cmdGrades(engine: BrainEngine, args: string[]): Promise<void> {...r,confidence: Number(r.confidence),graded_at: r.graded_at instanceof Date ? r.graded_at.toISOString() : String(r.graded_at),- judge_measured: gradeJudgeMeasured(r.judge_model_id),+ judge_measured: gradeJudgeMeasured(r.judge_model_id, r.prompt_version),}));if (json) {diff --git a/src/core/cycle/grade-takes-measured.ts b/src/core/cycle/grade-takes-measured.tsindex 095e1fd0fc..f9a39fa789 100644--- a/src/core/cycle/grade-takes-measured.ts+++ b/src/core/cycle/grade-takes-measured.ts@@ -6,7 +6,10 @@* rule on the counted split (evals/take-grading/PREREGISTRATION.md): among* verdicts the auto-resolve rule would apply (not `unresolvable`, confidence* at or above `GRADE_TAKES_AUTO_RESOLVE_THRESHOLD`), the one-sided 95% upper- * bound on the wrong share is at most 1%. Empty until the counted run.+ * bound on the wrong share is at most 1%. Measured 2026-10-16 at gbrain+ * d99b84694 (prompt `hybrid-evidence-v2`): gpt-6.1-sol applied 496 of 750+ * verdicts with none wrong (upper bound 0.6%); Sonnet 5.5 (121 applied, 1+ * wrong, 3.9%) and Opus 5.5 (2 applied) did not qualify.** Nothing auto-resolves today: the cycle runs grade_takes with auto-resolve* off. `gbrain takes grades` marks each cached verdict whose judge is not on@@ -14,10 +17,14 @@*/import { splitProviderModelId } from '../model-id.ts';-export const GRADE_TAKES_MEASURED_MODELS: readonly string[] = [];+export const GRADE_TAKES_MEASURED_MODELS: readonly string[] = ['openai:gpt-6.1-sol'];-/** True when a stored `judge_model_id` (a bare model id, as grade_takes stores it) is on the measured list. */-export function gradeJudgeMeasured(judgeModelId: string): boolean {+/** The prompt version the measurement used; a verdict asked with another prompt is not measured. */+export const GRADE_TAKES_MEASURED_PROMPT_VERSION = 'hybrid-evidence-v2';++/** True when a cached verdict's judge (a bare model id, as grade_takes stores it) is on the measured list and it was asked with the measured prompt. */+export function gradeJudgeMeasured(judgeModelId: string, promptVersion: string): boolean {+ if (promptVersion !== GRADE_TAKES_MEASURED_PROMPT_VERSION) return false;const bare = splitProviderModelId(judgeModelId).model || judgeModelId;return GRADE_TAKES_MEASURED_MODELS.some(m => (splitProviderModelId(m).model || m) === bare);}diff --git a/test/takes-grades-cli.test.ts b/test/takes-grades-cli.test.tsindex 016610f7cc..2953677fce 100644--- a/test/takes-grades-cli.test.ts+++ b/test/takes-grades-cli.test.ts@@ -13,7 +13,7 @@import { afterAll, beforeAll, describe, expect, test } from 'bun:test';import { PGLiteEngine } from '../src/core/pglite-engine.ts';import { runTakes } from '../src/commands/takes.ts';-import { GRADE_TAKES_MEASURED_MODELS, gradeJudgeMeasured } from '../src/core/cycle/grade-takes-measured.ts';+import { GRADE_TAKES_MEASURED_MODELS, GRADE_TAKES_MEASURED_PROMPT_VERSION, gradeJudgeMeasured } from '../src/core/cycle/grade-takes-measured.ts';let engine: PGLiteEngine;const takeIds: Record<string, number> = {};@@ -34,11 +34,11 @@ async function pageWithTake(slug: string, claim: string): Promise<number> {return take!.id;}-async function grade(takeId: number, verdict: string, confidence: number, gradedAt: string, applied = false, judge = 'claude-sonnet-4-6'): Promise<void> {+async function grade(takeId: number, verdict: string, confidence: number, gradedAt: string, applied = false, judge = 'claude-sonnet-4-6', prompt = 'hybrid-evidence-v1'): Promise<void> {await engine.executeRaw(`INSERT INTO take_grade_cache (take_id, prompt_version, judge_model_id, evidence_signature, graded_at, verdict, confidence, applied)- VALUES ($1, 'hybrid-evidence-v1', $2, $3, $4::timestamptz, $5, $6, $7)`,- [takeId, judge, `sig-${takeId}-${gradedAt}`, gradedAt, verdict, confidence, applied],+ VALUES ($1, $8, $2, $3, $4::timestamptz, $5, $6, $7)`,+ [takeId, judge, `sig-${takeId}-${gradedAt}`, gradedAt, verdict, confidence, applied, prompt],);}@@ -51,7 +51,8 @@ beforeAll(async () => {takeIds.gone = await pageWithTake('companies/gone-example', 'Gone-example will be acquired before 2025');await grade(takeIds.acme!, 'unresolvable', 0.4, '2026-01-01T00:00:00Z');await grade(takeIds.acme!, 'correct', 0.97, '2026-03-01T00:00:00Z', true, 'gpt-6.1-sol');- await grade(takeIds.bluefin!, 'incorrect', 0.8, '2026-02-01T00:00:00Z');+ await grade(takeIds.bluefin!, 'unresolvable', 0.5, '2026-01-15T00:00:00Z', false, 'gpt-6.1-sol', 'hybrid-evidence-v2');+ await grade(takeIds.bluefin!, 'incorrect', 0.8, '2026-02-01T00:00:00Z', false, 'openai:gpt-6.1-sol', 'hybrid-evidence-v2');await grade(takeIds.gone!, 'correct', 0.99, '2026-02-15T00:00:00Z');await engine.executeRaw(`UPDATE pages SET deleted_at = now() WHERE slug = 'companies/gone-example'`);});@@ -79,11 +80,18 @@ describe('gbrain takes grades', () => {expect(await ids('--limit', '1')).toEqual([takeIds.acme]);});- test('marks every judge the W6 eval did not measure', async () => {- expect(GRADE_TAKES_MEASURED_MODELS).toEqual([]);- expect(gradeJudgeMeasured('claude-sonnet-4-6')).toBe(false);+ test('marks a verdict measured only for a measured judge asked with the measured prompt', async () => {+ expect(GRADE_TAKES_MEASURED_MODELS).toEqual(['openai:gpt-6.1-sol']);+ expect(gradeJudgeMeasured('gpt-6.1-sol', GRADE_TAKES_MEASURED_PROMPT_VERSION)).toBe(true);+ expect(gradeJudgeMeasured('openai:gpt-6.1-sol', 'hybrid-evidence-v2')).toBe(true);+ expect(gradeJudgeMeasured('gpt-6.1-sol', 'hybrid-evidence-v1')).toBe(false);+ expect(gradeJudgeMeasured('claude-sonnet-5-5', 'hybrid-evidence-v2')).toBe(false);+ expect(gradeJudgeMeasured('claude-sonnet-4-6', 'hybrid-evidence-v2')).toBe(false);+ const rows = JSON.parse(await capture(() => runTakes(engine, ['grades', '--json'])));+ expect(rows.map((r: { take_id: number; judge_measured: boolean }) => [r.take_id, r.judge_measured])).toEqual([[takeIds.acme, false], [takeIds.bluefin, true]]);const out = await capture(() => runTakes(engine, ['grades']));expect(out).toContain('companies/acme-example#1 [alice-example] correct @ 0.97 applied judge gpt-6.1-sol (not measured by W6)');+ expect(out).toContain('companies/bluefin-example#1 [alice-example] incorrect @ 0.80 judge openai:gpt-6.1-sol 2026-02-01');expect(out).toContain('Acme-example will reach $5M ARR by the end of 2024 (made 2023-02-01)');expect(out).not.toContain('Gone-example');});