Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Q2 landing: world-v1 identity fixtures follow master's #6191 target-role rule; LINK_EXTRACTOR_VERSION_TS 2026-10-08; docs record the held-out verdicts
garrytan563af91652fb
diff --git a/docs/architecture/key-files/graph-and-facts.md b/docs/architecture/key-files/graph-and-facts.mdindex db2204e89e..dab22b8667 100644--- a/docs/architecture/key-files/graph-and-facts.md+++ b/docs/architecture/key-files/graph-and-facts.md@@ -110,7 +110,7 @@ rejection of serve-only flags before a brain opens.- `src/core/trajectory-format.ts` — shared `formatTrajectoryBlock(points, entitySlug, opts)` consumed by both `gbrain think` (production) and the LongMemEval harness (benchmark). Groups by `(metric ?? event_type)`, per-metric cap 20, total cap 100, knowledge_update intent annotates value-change rows with `(superseded prior)`. Emits a `<trajectory entity="...">` XML envelope — `INJECTION_PATTERNS` in `src/core/think/sanitize.ts` escapes `</trajectory>`, `<trajectory ...>` open tags, and attribute injection so adversarial fact text can't break out. Pinned by `test/trajectory-format.test.ts`.-- `src/core/line-grammar.ts` + `src/core/machine-sections.ts` — the line grammar: `parseLineGrammar` reads list items in a page body as typed relation lines (`- works_at [[companies/x]] (context)`: one type token or quoted phrase, exactly one link, optional `(context)`, optional `@effective[start,end)`, an optional trailing `[Source: ...]` citation) and fact lines (`- [category] claim #tag (context)`). Guards: a category is one letter-led token (timecodes, dates, citations, footnotes, task boxes and bracket phrases never match), `x`/`todo`/`done`/`wip` are refused, and code, blockquotes, HTML comments, frontmatter and the machine-written sections from `rolePriorSuppressedRanges` (now in `machine-sections.ts`, shared with type inference) are skipped. Prose after the link, two links, stoplisted generic words and verbs the active pack does not declare fall back to inference with a diagnostic. `statedRelationTypes` feeds `extractPageLinks` (and the filesystem scan in `commands/extract.ts`): the stated type wins for the link on its line, except an `attended` line on a meeting page, which stays with canonical attendance. `parseEffectiveQualifier` normalizes ISO ranges to half-open `[from, until)` dates and refuses everything else unpeeled (a range with more than one comma is refused with an exactly-one-comma message). Parsing stays linear on adversarial lines: the qualifier's date groups exclude commas, the trailing-citation pattern has no overlapping whitespace quantifiers, and links come from `findLinks`, a scan with precomputed stop positions that returns exactly the old link regex's matches. `lineGrammarOptions` resolves `line_grammar.enabled` (default off: held-out verdict H3 failed its precision bar) and `line_grammar.allow_undeclared_types`. Fact lines are reported (put_page `line_grammar`, `gbrain lint` rule `line-grammar`, `schema detect --fields`), not projected into `facts`. Pinned by `test/line-grammar.test.ts` (incl. a timeout-bounded adversarial input, a 200k-character linear-time ratio check and a `findLinks` equivalence property test), `test/link-extraction-line-grammar.test.ts`, `test/put-page-line-grammar.test.ts`.+- `src/core/line-grammar.ts` + `src/core/machine-sections.ts` — the line grammar: `parseLineGrammar` reads list items in a page body as typed relation lines (`- works_at [[companies/x]] (context)`: one type token or quoted phrase, exactly one link, optional `(context)`, optional `@effective[start,end)`, an optional trailing `[Source: ...]` citation) and fact lines (`- [category] claim #tag (context)`). Guards: a category is one letter-led token (timecodes, dates, citations, footnotes, task boxes and bracket phrases never match), `x`/`todo`/`done`/`wip` are refused, and code, blockquotes, HTML comments, frontmatter and the machine-written sections from `rolePriorSuppressedRanges` (now in `machine-sections.ts`, shared with type inference) are skipped. Prose after the link, two links, stoplisted generic words and verbs the active pack does not declare fall back to inference with a diagnostic. `statedRelationTypes` feeds `extractPageLinks` (and the filesystem scan in `commands/extract.ts`): the stated type wins for the link on its line, except an `attended` line on a meeting page, which stays with canonical attendance. `parseEffectiveQualifier` normalizes ISO ranges to half-open `[from, until)` dates and refuses everything else unpeeled (a range with more than one comma is refused with an exactly-one-comma message). Parsing stays linear on adversarial lines: the qualifier's date groups exclude commas, the trailing-citation pattern has no overlapping whitespace quantifiers, and links come from `findLinks`, a scan with precomputed stop positions that returns exactly the old link regex's matches. `lineGrammarOptions` resolves `line_grammar.enabled` (default off: held-out verdict H3 failed its precision bar, and Q2's G1 natural-junk and G3 decoy gates failed again with the guards) and `line_grammar.allow_undeclared_types`. Fact lines are reported (put_page `line_grammar`, `gbrain lint` rule `line-grammar`, `schema detect --fields`), not projected into `facts`. Pinned by `test/line-grammar.test.ts` (incl. a timeout-bounded adversarial input, a 200k-character linear-time ratio check and a `findLinks` equivalence property test), `test/link-extraction-line-grammar.test.ts`, `test/put-page-line-grammar.test.ts`.- `src/core/wanted-links.ts` + `src/core/wanted-links-store.ts` — wanted pages. `collectWantedLinks` turns an origin's link candidates (each body markdown link / wikilink carries an `authoredRef` from `extractPageLinks`) and unresolved frontmatter names into `wanted_links` rows: a reference is wanted only when every alternative resolution failed with `missing_target`/`cross_source` (an unqualified target existing only in another source is wanted in the origin source; a qualified target in a source the origin may not link to is not). Bare prose paths never become rows. `replaceWantedLinks` runs inside `replaceDerivedLinks` (`opts.wanted`, per producer `body`/`frontmatter`), so every extraction path (managed put_page and stale sweep via `links-preparation.ts`, unmanaged `extract`, the serve sweep, source reconciliation) replaces rows atomically with links; it keeps only `possibleWantedRows` (a slug target `validateSlug` accepts, in the origin's or a registered source read `FOR SHARE`, so a regex literal on a code page or a `[[memory:123]]` citation never reaches the page guard and aborts extraction, #6228/#6225; `links-preparation.ts` filters the receipt preview the same way), locks slug targets and stamps a row `-infinity` when its exact target already exists. `WANTED_ORIGIN_IS_STALE` in `engine-sql/pages.ts` joins the stale-for-extraction predicate: a live target (exact slug, or basename for `ref_kind='name'`) updated after `checked_at` makes the origin stale, so the next sweep creates the edge; restore and rename bump `updated_at`. `listWantedPages` backs the `wanted_pages` op (`gbrain wanted`): source-scoped, private origins excluded before aggregation for remote callers, soft-deleted origins never count, bare-name targets list `existing_matches`. `wanted_pages.enabled` (default on). Migration v214. Pinned by `test/wanted-links.test.ts` + `test/e2e/wanted-links-postgres.test.ts`.diff --git a/docs/eval/decisions/q2-parser-gaps/dev-units.md b/docs/eval/decisions/q2-parser-gaps/dev-units.mdindex f3e85acbd2..26dadaa09e 100644--- a/docs/eval/decisions/q2-parser-gaps/dev-units.md+++ b/docs/eval/decisions/q2-parser-gaps/dev-units.md@@ -413,3 +413,16 @@ bun scripts/q2-typing-dev.ts compare --base /tmp/none.json --arm /tmp/u2.json`--dev-phrasing-file` was patched into a local gbrain-evals copy the way the harness lane adds it (not yet pushedthere when these runs were made). Zero model calls; no paid run.++## Landing merge (master b5f12b12, v0.60.117.0)++The landing merge brings in master's #6191 (no `works_at` or `founded` inferred toward person, meeting or calendar+targets), which changes link typing for every build. On world-v1, the change from the confirmed package `afcec1ad`+(723 lines, `1763359f…`) to the landing head (706 lines, `02b15d1b…`) is exactly the change from the master `afcec1ad`+was built on (units off, 725 lines, `ce8f52bd…`) to master `b5f12b12` (708 lines, `3222513a…`): 22 lines removed and 5+changed in both, every one a company-to-person `works_at` edge or its tense row, and no other line differs. With no+unit, the landing head types world-v1 byte-identically to master `b5f12b12`. On temporal-edges phrasings A, A2 and A3+(seeds 3 and 5, the harness's `--c-gate` settings) the landing head reproduces the pre-merge numbers exactly, with+units off and with the shipped package: E5 false starts 48/48/37 → 0, E5 wrong closures 24/24/8 → 0, wrong+transitions by identity 89/89/59 → 17/17/14, live recall and traps unchanged, A3 as-of 0.619 → 0.650.+diff --git a/docs/guides/line-grammar.md b/docs/guides/line-grammar.mdindex 047c21e8c5..19b6a18365 100644--- a/docs/guides/line-grammar.md+++ b/docs/guides/line-grammar.md@@ -9,13 +9,19 @@ page?" hint when a write creates a page.Off by default; turn the line grammar on with`gbrain config set line_grammar.enabled true`. While it is off, these lines are-ordinary list text and their links keep their inferred types. In the held-out-junk audit, the grammar read 18 of 696,295 list lines in public notes and-transcripts as grammar lines, and none of the 18 were real: all were fact-lines, mostly unfilled template slots (`- [Time] - [Event]`) and a few-dictionary usage labels. That failed the 0.95 precision bar. No relation line-was minted, and no timecode, citation, task box, date or machine-written-section was read.+ordinary list text and their links keep their inferred types. It stays off+because natural notes still produce false reads. In the first held-out junk+audit, the grammar read 18 of 696,295 list lines in public notes and+transcripts as grammar lines, and none of the 18 were real (mostly unfilled+template slots and dictionary usage labels). The guards in+[Lines the grammar does not read](#lines-the-grammar-does-not-read) remove+those shapes, but the second held-out audit (decision `q2-parser-gaps-2026-10`,+fresh natural pages) still minted 583 grammar lines, 459 of them wrong: an+upper bound of 75.6 wrong reads per 100,000 list lines against a bar of 2. It+also minted 17 of 52 decoy lines built to look like grammar lines. Typed lines+written on purpose were read correctly, 511 of 511. Turn it on when you or+your agent write typed lines on purpose; on a brain of imported notes and+transcripts, expect some list lines to be read as grammar lines they are not.When it is on, a list item that names a relation type and exactly one linkstates that link's type:diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.tsindex 490741f8e4..339f6e2b6b 100644--- a/src/core/link-extraction.ts+++ b/src/core/link-extraction.ts@@ -101,7 +101,9 @@ export { parseInlineCitationTimelineEntries, type InlineCitationTimelineCandidat// 2026-10-05T03: typed relation lines (core/line-grammar.ts) state their link's type; a per-edge verb that// belongs to another link in the window no longer types this one; "joined [X] as <role>" reads as works_at.// Re-extract so existing pages pick these up.-export const LINK_EXTRACTOR_VERSION_TS = '2026-10-05T03:00:00Z';+// 2026-10-08: adviser wording and local negation (U1), board/observer/investor wording never types works_at (U3)+// and advisory/board/investor roles are not employment starts (U4), each confirmed on held-out data (Q2).+export const LINK_EXTRACTOR_VERSION_TS = '2026-10-08T20:00:00Z';// ─── Entity references ──────────────────────────────────────────diff --git a/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256 b/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256index c04ce027af..44c89658ba 100644--- a/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256+++ b/test/fixtures/q2-typing-units/world-v1-confirmed-package.sha256@@ -1 +1 @@-1763359f75ac050fc19e8fdd17a6694a8cf0e6a7fbd12c2b01ef5932f9ef96fd+02b15d1bb73495bf1797d9910d15918802b00a1021cba3a47ab0807c970511dadiff --git a/test/fixtures/q2-typing-units/world-v1-master.sha256 b/test/fixtures/q2-typing-units/world-v1-master.sha256index e1eee5e302..29c2f63ac6 100644--- a/test/fixtures/q2-typing-units/world-v1-master.sha256+++ b/test/fixtures/q2-typing-units/world-v1-master.sha256@@ -1 +1 @@-ce8f52bd1b17f443b1ec5069e247dfba341cef1f02a9372d6722b158f42bf45b+3222513a773d0b0aed3b9cb9c8ee2ee276f20fdd766b68e75c12be2f0f2764bfdiff --git a/test/link-typing-units-subsets.test.ts b/test/link-typing-units-subsets.test.tsindex c66dacb9b7..3025663ee1 100644--- a/test/link-typing-units-subsets.test.ts+++ b/test/link-typing-units-subsets.test.ts@@ -1,7 +1,8 @@/*** Every subset of the shipped typing units (U1, U3, U4: 2^3 = 8) passes the frozen examples* (test/helpers/typing-unit-examples.ts). With no unit, extraction types the world-v1 corpus byte-identically to master- * (digest of master c5fb0201); with the shipped package it types it as the confirmed package afcec1ad did+ * (digest of master b5f12b12); with the shipped package it types it as the confirmed package afcec1ad did, plus master's+ * #6191 target-role rule (the only difference; docs/eval/decisions/q2-parser-gaps/dev-units.md, Landing merge)* (scripts/q2-typing-dev.ts world-v1). Those checks need a gbrain-evals checkout (GBRAIN_TEST_TYPING_EVALS_DIR, else* ../gbrain-evals) and are skipped without one.*/@@ -40,7 +41,7 @@ test.skipIf(!haveWorld)('no unit: world-v1 typing is byte-identical to master',expect(r.sha256).toBe(master);}, 60_000);-test.skipIf(!haveWorld)('shipped package: world-v1 typing is byte-identical to the confirmed package afcec1ad', async () => {+test.skipIf(!haveWorld)('shipped package: world-v1 typing is the confirmed package afcec1ad plus master\'s target-role rule', async () => {const confirmed = readFileSync(join(import.meta.dir, 'fixtures/q2-typing-units/world-v1-confirmed-package.sha256'), 'utf8').trim();const r = await worldV1Edges(loadWorldV1(worldDir), extractPageLinks as never, deriveTemporalEvidence as never);expect(r.sha256).toBe(confirmed);