Skip to content

feat(ctx): phase-2 chain — one-hop reference + supersession neighborhood#445

Merged
eris-ths merged 1 commit into
mainfrom
feat/ctx-chain
Jun 23, 2026
Merged

feat(ctx): phase-2 chain — one-hop reference + supersession neighborhood#445
eris-ths merged 1 commit into
mainfrom
feat/ctx-chain

Conversation

@eris-ths

Copy link
Copy Markdown
Owner

What

The second phase-2 ctx verb (read-side): ctx chain <id>.

Shows the records adjacent to a fact in one hop, so a reader can follow related observations without grepping the substrate — the ctx analogue of gate chain.

Edge kinds (all from a single substrate scan)

  • outbound — ctx ids the root's own prose mentions. Resolved to their facts; a prose mention of an absent id is surfaced as (referenced but not found) rather than dropped (records-outlive-writers). Self-references ignored.
  • inbound — other facts whose prose mentions the root id.
  • supersedes — the fact the root corrects (its forward link).
  • superseded by — the facts that correct the root (a fork yields more than one).

One hop only, like gate chain: to go deeper, run ctx chain on a surfaced id — the reader drives the depth. A missing root is a recoverable not-found; an isolated fact reports an empty neighborhood rather than an error.

Shared scanner change (affects gate chain too — behavior unchanged)

extractReferences (the lexical id-scanner behind gate chain and UnrespondedConcernsQuery) gains a third id kind: ctx-YYYY-MM-DD-NNN, returned in a new ctxIds field. This also fixes a latent mis-classification: the leading (?<!\w) boundary allowed a hyphen, so a ctx-… (or i-…) id's digits could leak into requestIds. Capturing the prefix in the pattern keeps the three kinds disjoint. gate chain does not surface ctx ids, so its behavior is unchanged — covered by the existing chain regression tests plus new direct unit tests for the scanner.

Verification

  • Full suite green: 1859/1859 pass, 0 fail (node tests/run.mjs, exit 0).
  • Dogfooded through the real binary: supersede-chain both directions, inbound prose reference, outbound + dangling ref, one-hop (no transitive walk), empty neighborhood, error paths.
  • New tests: chain.test.ts (7 e2e) + extractReferences.test.ts (6 unit, incl. the mis-classification regression guard).
  • Docs (verbs.md / AGENT.md / playbook.md / CLAUDE.md) + changelog fragment updated.

Remaining phase-2

fork / status.

🤖 Generated with Claude Code

ctx chain <id> shows the records adjacent to a fact in one hop, so a
reader follows related observations without grepping the substrate. Four
edge kinds from a single scan: outbound (ctx ids the root's prose names,
resolved or surfaced as '(referenced but not found)'), inbound (facts
that name the root), supersedes, and superseded-by (a fork yields >1).
One hop only, like gate chain — deeper walks are the reader re-invoking.

The shared extractReferences (also behind gate chain) gains a third id
kind: ctx-YYYY-MM-DD-NNN, returned in a new ctxIds field. This also fixes
a latent mis-classification — the leading boundary allowed a hyphen, so a
ctx-/i- id's digits could leak into requestIds; capturing the prefix
keeps the three kinds disjoint. gate chain behavior is unchanged.

Docs (verbs.md / AGENT.md / playbook.md / CLAUDE.md) and a changelog
fragment updated. Full suite 1859/1859 green. Remaining phase-2: fork /
status.
@eris-ths eris-ths merged commit 14b9eac into main Jun 23, 2026
5 checks passed
@eris-ths eris-ths deleted the feat/ctx-chain branch June 23, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant