Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(graph): declared single-value closures default to propose (sealed E5 failed: advisory lines typed works_at); record E5
garrytanb7efc2164ccc
diff --git a/docs/architecture/key-files/graph-and-facts.md b/docs/architecture/key-files/graph-and-facts.mdindex 7e2e38865e..0641da9fe5 100644--- a/docs/architecture/key-files/graph-and-facts.md+++ b/docs/architecture/key-files/graph-and-facts.md@@ -111,4 +111,4 @@ rejection of serve-only flags before a brain opens.- `src/core/link-validity.ts` + `src/core/link-relationships.ts` + `src/core/link-temporal-evidence.ts` + `src/core/link-temporal-apply.ts` + `src/core/ops/edge-temporal.ts` — temporal typed edges ([guide](../../guides/temporal-edges.md)). Relation semantics (state / event / reference), `buildRelationshipState` (order-invariant stints from `links` assertions with `assertion_tense` plus dated `link_transitions`; dated beats undated, same-page present beats past), `closeContradiction` (pure date arithmetic, relationship-specific starts only), and `relationshipFilterSql` / `annotateTemporalRow` / `edgeMatchesTemporal` (one liveness rule: a relationship with no `link_relationships` row reads live). `refreshRelationships` recomputes per-scope state (`all`, `world` ignores private-origin evidence) inside the writer's transaction; `replaceDerivedLinks` calls `applyTemporalEvidence`, and the engine link writers refresh touched temporal keys; the extract phase sweeps lagging or orphaned state. Graph ops read live relationships by default; default reads keep the established row shape, history reads (`status`, `as_of`, `during`) return `status`/`stints`/`recorded_at`/`retired_at`; hidden rows emit `former_relationships_hidden` + `gbrain.temporal` meta. `graph.edge_validity off` is a read policy only. `src/core/link-semantics-pack.ts` installs pack-declared `link_types[].temporal` semantics (union of the active and per-source packs, `state` wins) over the built-in table; `replaceDerivedLinks`, `add_link`/`remove_link` and the extract sweep prime it before deriving or refreshing state (lint rule `link_types_temporal`; `test/link-semantics-pack.test.ts`). `src/core/link-relationship-notes.ts` renders the shared relationship note (`now: … ; ended: … ; summary may be stale`) with one batched read for entity cards, `context_pack`, ambient turn-context synopses and compiled context entries. Pinned by `test/link-validity.test.ts`, `test/link-temporal-evidence.test.ts`, `test/link-relationships.test.ts` (+ Postgres twin), `test/link-temporal-put-page.test.ts`, `test/link-temporal-reads.test.ts`.- `src/core/cycle/edge-contradictions.ts` + `src/commands/edge-proposals.ts` — the `edge_contradictions` dream phase and `gbrain edge-proposals`. Candidates are subjects with ≥2 live same-type state relationships whose pair evidence hash has no proposal; one judge call per subject returns only conflict flags; `closeContradiction` picks the ending relationship and date (undated → `undated_unresolved`). Modes propose (default) / apply (certified models in `CERTIFIED_APPLY_MODELS`) / off; applying appends a `gbrain-dream (inferred)` "Ended <type> [[target]]" timeline line through the coordinated `add_timeline_entry` path and re-derives the page; a hand-deleted line becomes `reverted_by_user`. Budget through the cycle `BudgetMeter`. Pinned by `test/cycle-edge-contradictions.test.ts` and the managed phase matrix.-- `src/core/link-single-value.ts` — declared single-value relations ([guide](../../guides/temporal-edges.md#declared-single-value-relations)). A pack's `cardinality: one_per_from` on a state relation, built in or declared `temporal: state` (manifest-v1 `LinkTypeSchema`; lint rule `link_types_cardinality` rejects it elsewhere) makes `edge_contradictions` close that type's competing live relationships without a model: `planSingleValueClosures` orders members by latest dated start and applies `closeContradiction` to each consecutive pair (undated and same-date members stay open as proposals). `declaredSingleValueTypes` reads the source's resolved pack; `previewSingleValue` backs the read-only `gbrain schema cardinality-preview`. `dream.single_value.mode` apply (default) / propose / off. Pinned by `test/link-single-value.test.ts`.+- `src/core/link-single-value.ts` — declared single-value relations ([guide](../../guides/temporal-edges.md#declared-single-value-relations)). A pack's `cardinality: one_per_from` on a state relation, built in or declared `temporal: state` (manifest-v1 `LinkTypeSchema`; lint rule `link_types_cardinality` rejects it elsewhere) makes `edge_contradictions` close that type's competing live relationships without a model: `planSingleValueClosures` orders members by latest dated start and applies `closeContradiction` to each consecutive pair (undated and same-date members stay open as proposals). `declaredSingleValueTypes` reads the source's resolved pack; `previewSingleValue` backs the read-only `gbrain schema cardinality-preview`. `dream.single_value.mode` propose (default) / apply / off. Pinned by `test/link-single-value.test.ts`.diff --git a/docs/eval/decisions/p3-retrieval-feedback/PREREGISTRATION.md b/docs/eval/decisions/p3-retrieval-feedback/PREREGISTRATION.mdindex bd5c753dda..bbf07e62fc 100644--- a/docs/eval/decisions/p3-retrieval-feedback/PREREGISTRATION.md+++ b/docs/eval/decisions/p3-retrieval-feedback/PREREGISTRATION.md@@ -174,3 +174,6 @@ higher λ. That is why E1 is judged per corpus above. Raw summaries: [`dev/`](de---Custodian edits (dated, with reason) go below this line.++2026-10-05: E5 ran (decision `p3-e5-heldout-2026-10-05`) and failed; per the rule above, `dream.single_value.mode`+defaults to `propose`. Results and cause: [`VERDICTS.md`](VERDICTS.md#e5-declared-single-value-relations--fail).diff --git a/docs/eval/decisions/p3-retrieval-feedback/VERDICTS.md b/docs/eval/decisions/p3-retrieval-feedback/VERDICTS.mdindex 26b1c5b029..24bb668bed 100644--- a/docs/eval/decisions/p3-retrieval-feedback/VERDICTS.md+++ b/docs/eval/decisions/p3-retrieval-feedback/VERDICTS.md@@ -73,9 +73,33 @@ templates miss most rewordings. Any ranking change that acts on the relational acapped by how often the parser recognizes the question. Measuring the parser's recall on held-out phrasings, andwidening it, is a prerequisite for re-testing relational ranking ideas.-## E5: declared single-value relations — pending+## E5: declared single-value relations — fail-Preregistered on 2026-10-05 before any cell ran (see the E5 entry in [`PREREGISTRATION.md`](PREREGISTRATION.md)):-P1's temporal-edges set C with a test pack declaring `works_at` single-valued; 0 wrong closures, every undated or-same-date conflict left open, no as-of regression. Until the verdict is recorded, `dream.single_value.mode` acts only-on packs that declare `cardinality`, and no bundled pack does.+Custodian decision `p3-e5-heldout-2026-10-05`, build `bd700323e`, P1's temporal-edges phrasing set C, seeds 11, 13 and+17, with a test pack declaring `works_at` `cardinality: one_per_from`; no model calls ($0).++| Gate | Off → on | Bar | Result |+|---|---|---|---|+| Wrong closures | 3 of 3 applied closures wrong (seed 11: 0, seed 13: 2, seed 17: 1) | 0 | fail |+| Now-precision | 0.943 → 0.913, Δ −0.029, CI [−0.086, 0] | lower bound ≥ −0.01 | fail |+| Undated / same-date conflicts left open | none closed | all open | pass |+| As-of exact rate | 0.678 → 0.678 | no lower | pass |+| During-F1 | 0.653 → 0.653 | no lower | pass |+| Traps | 115/115 | ≥ 0.99 | pass |+| Order invariance | 240/240 | 1 | pass |++Reported only: current-employer recall 0.612 → 0.577, live-edge recall 0.603 → 0.589.++Cause: every wrong closure ended the person's actual current employer (one stint since 2009). The extractor types a+later advisory line ("Took an advisory role with [X]") as `works_at`, so the chain rule read it as a newer job and+closed the real one at its date. The rule did what it specifies; the upstream link typing is wrong for that phrasing.++Decision, as preregistered: `dream.single_value.mode` defaults to `propose`. Closures for declared types are recorded+as proposals (`gbrain edge-proposals list`) and nothing is written to pages until a user accepts one or sets the mode+to `apply`.++Follow-ups (not in this pull request; each needs a fresh held-out run):++1. Stop advisory phrasing ("took an advisory role with", "advises", "board advisor to") from typing as `works_at` in+ link extraction.+2. In the chain rule, skip a successor relationship whose target also has an `advises` edge from the same page.diff --git a/docs/guides/temporal-edges.md b/docs/guides/temporal-edges.mdindex 09adc9905a..e6ec2de815 100644--- a/docs/guides/temporal-edges.md+++ b/docs/guides/temporal-edges.md@@ -186,8 +186,9 @@ relationships by their latest dated start and ends each one on the date the nextstarted, so an out-of-order import (Acme from January, Widget from March, then Gadgetfrom February) ends Acme in February and Gadget in March. Relationships without a datedstart, and two that start on the same date, stay open and appear in-`gbrain edge-proposals list`. Closures land as the same reversible timeline lines,-recorded with model `schema-pack:cardinality`.+`gbrain edge-proposals list`. Closures are recorded as proposals with model+`schema-pack:cardinality`; `gbrain edge-proposals accept <id>` writes one as the same+reversible timeline line.- Only state relations take `cardinality`: the built-in ones (`works_at`, `advises`, `yc_partner`) and any type thepack declares `temporal: state`. `gbrain schema lint` rejects it elsewhere, because only state relations end.@@ -197,9 +198,11 @@ recorded with model `schema-pack:cardinality`.more than one live relationship of a declared type and what the next dream cyclecloses or leaves open. It writes nothing; run it before activating a pack that adds adeclaration.-- `gbrain config set dream.single_value.mode propose` records closures for review- instead of applying them; `off` hands declared types back to the model judge. The- default is `apply`.+- `dream.single_value.mode` is `propose` by default: closures wait for review in+ `gbrain edge-proposals list`. `gbrain config set dream.single_value.mode apply` writes them+ automatically; `off` hands declared types back to the model judge. Held-out testing found+ wrong closures when an advisory line ("Took an advisory role with X") was typed as+ `works_at` and read as a newer job, so review proposals before accepting them.- To stop further closures, remove the declaration. `gbrain edge-proposals undo <id>`(or deleting the line) reopens a relationship it closed.diff --git a/src/core/cycle/edge-contradictions.ts b/src/core/cycle/edge-contradictions.tsindex fad1b9d481..da3ddd648d 100644--- a/src/core/cycle/edge-contradictions.ts+++ b/src/core/cycle/edge-contradictions.ts@@ -331,7 +331,7 @@ export const SINGLE_VALUE_MODEL = 'schema-pack:cardinality';async function loadSingleValueMode(engine: BrainEngine): Promise<SingleValueMode> {const raw = (await engine.getConfig('dream.single_value.mode'))?.trim().toLowerCase();- return raw === 'propose' || raw === 'off' ? raw : 'apply';+ return raw === 'apply' || raw === 'off' ? raw : 'propose';}/**diff --git a/test/link-single-value.test.ts b/test/link-single-value.test.tsindex 812bac2e07..890f26046a 100644--- a/test/link-single-value.test.ts+++ b/test/link-single-value.test.ts@@ -137,7 +137,17 @@ describe('declared single-value closures in edge_contradictions', () => {expect(await liveWorksAt()).toEqual(['companies/acme-example', 'companies/gadget-co', 'companies/widget-co']);});+ test('by default closures are proposals: nothing is written and the relationships stay live', async () => {+ await engine.executeRaw(`DELETE FROM config WHERE key = 'dream.single_value.mode'`);+ await seed(OUT_OF_ORDER);+ const r = await runPhaseEdgeContradictions(engine, { judge: noJudge });+ expect(r.totals).toMatchObject({ declared_proposed: 2, declared_applied: 0 });+ expect((await proposals()).map(p => p.status)).toEqual(['proposed', 'proposed']);+ expect(await liveWorksAt()).toEqual(['companies/acme-example', 'companies/gadget-co', 'companies/widget-co']);+ });+test('closes the chain with no model, lands as timeline lines, and a rerun changes nothing', async () => {+ await engine.setConfig('dream.single_value.mode', 'apply');await seed(OUT_OF_ORDER);expect(await liveWorksAt()).toEqual(['companies/acme-example', 'companies/gadget-co', 'companies/widget-co']);const r = await runPhaseEdgeContradictions(engine, { judge: noJudge });@@ -154,6 +164,7 @@ describe('declared single-value closures in edge_contradictions', () => {});test('a hand-deleted closure line is reverted and never re-applied', async () => {+ await engine.setConfig('dream.single_value.mode', 'apply');await seed(OUT_OF_ORDER);await runPhaseEdgeContradictions(engine, { judge: noJudge });await seed(OUT_OF_ORDER);