Skip to content

FE-808 persist graph node ordinals#171

Open
lunelson wants to merge 21 commits into
ln/fe-806-agents-composition-layerfrom
ln/fe-808-graph-tool-resilience
Open

FE-808 persist graph node ordinals#171
lunelson wants to merge 21 commits into
ln/fe-806-agents-composition-layerfrom
ln/fe-808-graph-tool-resilience

Conversation

@lunelson
Copy link
Copy Markdown
Contributor

@lunelson lunelson commented Jun 4, 2026

FE-808 persist graph node ordinals

FE-808 normalize graph approval basis

FE-808 resolve graph references by code

FE-808 enforce supersession acyclicity

FE-808 split active graph projection

Align probe transcripts with Pi context rendering

Amp-Thread-ID: https://ampcode.com/threads/T-019e92bc-e43a-727f-8acf-0213915029ff
Co-authored-by: Amp amp@ampcode.com

FE-808 canonicalize graph tool handles

Stub projection and format topology for LLM context

Amp-Thread-ID: https://ampcode.com/threads/T-019e92bc-e43a-727f-8acf-0213915029ff
Co-authored-by: Amp amp@ampcode.com

Thread representative LLM projection seams

Amp-Thread-ID: https://ampcode.com/threads/T-019e92bc-e43a-727f-8acf-0213915029ff
Co-authored-by: Amp amp@ampcode.com

Apply remaining context rendering cleanup

Amp-Thread-ID: https://ampcode.com/threads/T-019e92bc-e43a-727f-8acf-0213915029ff
Co-authored-by: Amp amp@ampcode.com

FE-808: Normalize graph tool outcomes

FE-808: Add existing-code graph probe

FE-808: Add retry diagnostics graph probe

FE-808: Add ambiguity no-overcommit probe

FE-808: Close graph commit planner judo findings

Add fixture seed loader and consolidate Bilal-port seed fixtures

Restructure .fixtures/seed-specs/ into .fixtures/seeds/bilal-port/ with
vendored Bilal originals under _originals/, the throwaway port script, and
one consolidated .json per spec ({spec, nodes, edges}).

Fix the port script's basis mapping: epistemicStatus no longer maps to the
invalid 'accepted_review_set' basis (forbidden per GRAPH_MODEL.md). Bilal
authored each item directly, so every ported node is 'explicit'; the
epistemic flavor is preserved in source text instead.

Add src/graph/seed-fixtures.ts: a loader that commits each consolidated
fixture through CommandExecutor (createSpec + one explicit commitGraph
batch) so graph clock / change log / lsn stay coherent. Lives in graph/
(not db/) to respect the db/ <- graph/ dependency direction. Exposed via
'npm run seed'; covered by src/graph/seed-fixtures.test.ts.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp amp@ampcode.com

Self-validate ported seeds against the real loader before writing

The port script now runs each assembled seed through seedFixture against a
throwaway in-memory DB before writing .json, reusing the exact
structural validation commitGraph enforces (planCommitGraph: node
kind/plane/detail + edge category/stance/ref/cycle checks). A seed that
would not commit cleanly aborts the run instead of producing an unloadable
fixture.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp amp@ampcode.com

plan: add dev-seed-fixtures parallel frontier

Capture the landed seed-fixture substrate (consolidated {spec,nodes,edges}
contract, src/graph/seed-fixtures.ts loader, npm run seed, self-validating
port scripts) and the two enhancement ideas as backlog: (1) enrich
Bilal-port graphs through Brunch from the original briefs to recover
thesis/goal structure, (2) port + enhance the legacy product fixtures.
Notes manual-testing.md seed-doc drift for the doc-reconciliation track.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp amp@ampcode.com

FE-808 validate createNode basis

agent and skill guidance re not deleting stubs

FE-808: Sync graph resilience closeout

lunelson and others added 21 commits June 4, 2026 15:02
Restructure .fixtures/seed-specs/ into .fixtures/seeds/bilal-port/ with
vendored Bilal originals under _originals/, the throwaway port script, and
one consolidated <slug>.json per spec ({spec, nodes, edges}).

Fix the port script's basis mapping: epistemicStatus no longer maps to the
invalid 'accepted_review_set' basis (forbidden per GRAPH_MODEL.md). Bilal
authored each item directly, so every ported node is 'explicit'; the
epistemic flavor is preserved in source text instead.

Add src/graph/seed-fixtures.ts: a loader that commits each consolidated
fixture through CommandExecutor (createSpec + one explicit commitGraph
batch) so graph clock / change log / lsn stay coherent. Lives in graph/
(not db/) to respect the db/ <- graph/ dependency direction. Exposed via
'npm run seed'; covered by src/graph/seed-fixtures.test.ts.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp <amp@ampcode.com>
The port script now runs each assembled seed through seedFixture against a
throwaway in-memory DB before writing <slug>.json, reusing the exact
structural validation commitGraph enforces (planCommitGraph: node
kind/plane/detail + edge category/stance/ref/cycle checks). A seed that
would not commit cleanly aborts the run instead of producing an unloadable
fixture.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp <amp@ampcode.com>
Capture the landed seed-fixture substrate (consolidated {spec,nodes,edges}
contract, src/graph/seed-fixtures.ts loader, npm run seed, self-validating
port scripts) and the two enhancement ideas as backlog: (1) enrich
Bilal-port graphs through Brunch from the original briefs to recover
thesis/goal structure, (2) port + enhance the legacy product fixtures.
Notes manual-testing.md seed-doc drift for the doc-reconciliation track.

Amp-Thread-ID: https://ampcode.com/threads/T-019e91ee-aa39-73d2-a346-a0ae1e55e3b9
Co-authored-by: Amp <amp@ampcode.com>
Copy link
Copy Markdown
Contributor Author

lunelson commented Jun 4, 2026

@lunelson lunelson marked this pull request as ready for review June 4, 2026 16:18
Copilot AI review requested due to automatic review settings June 4, 2026 16:18
@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 4, 2026

PR Summary

Low Risk
Changes are agent-skill guidance and committed probe/seed fixture artifacts; no runtime graph or auth paths in this diff slice.

Overview
Adds deletion guardrails across ln-build, ln-review, ln-judo-review, and earned-mode ln-plan: comment-rich export {} files must be treated as intentional topology stubs per AGENTS.md §intentional topology stubs—build/cleanup, review delete findings, and delete-as-progress / judo deletions need explicit proof the documented seam is obsolete or absorbed, not merely unused.

Checks in three A14-L propose-graph-commit probe runs under .fixtures/runs/propose-graph-commit/ (existing projected-code edge via {existingCode: "G1"}, STRUCTURAL_ILLEGAL then corrected retry, ambiguous user prompt with clarification and no commit_graph), each with report.json, session.jsonl, and transcript.md.

Removes the legacy split fixture .fixtures/seed-specs/bilal-port/code-health/edges.json in favor of the consolidated Bilal-port seed shape described elsewhere in the branch.

Reviewed by Cursor Bugbot for commit 03a8137. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances FE-808’s “graph write contract” by persisting per-kind node ordinals (projected node codes), normalizing graph approval basis to explicit|implicit, tightening supersession/active-context projections, and aligning probe transcripts with Pi-derived LLM-visible context. It also adds a dev seed-fixture substrate (npm run seed) that loads consolidated fixtures through the CommandExecutor mutation boundary.

Changes:

  • Persist nodes.kind_ordinal with per-(spec, plane, kind) monotonic allocation (node_kind_counters), expose projected node codes, and add selected-spec code → node id resolution.
  • Normalize graph basis semantics (explicit|implicit), retire accepted_review_set, and route tool/adapter paths through projected codes (no raw node ids in agent tools).
  • Introduce transcript projection + formatting modules and add a seed-fixture loader + tests, plus probe/report updates.

Reviewed changes

Copilot reviewed 104 out of 119 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/structured-exchange/project/request-review.ts Add intentional projection seam stub.
src/structured-exchange/project/request-choices.ts Add intentional projection seam stub.
src/structured-exchange/project/request-choice.ts Add intentional projection seam stub.
src/structured-exchange/project/request-answer.ts Add intentional projection seam stub.
src/structured-exchange/project/present-review-set.ts Add intentional projection seam stub.
src/structured-exchange/project/present-question.ts Implement canonical projection for present_question.
src/structured-exchange/project/present-options.ts Add intentional projection seam stub.
src/structured-exchange/project/present-candidates.ts Add intentional projection seam stub.
src/structured-exchange/project/capture-review.ts Add intentional projection seam stub.
src/structured-exchange/project/capture-choices.ts Add intentional projection seam stub.
src/structured-exchange/project/capture-choice.ts Add intentional projection seam stub.
src/structured-exchange/project/capture-candidate.ts Add intentional projection seam stub.
src/structured-exchange/project/capture-answer.ts Add intentional projection seam stub.
src/structured-exchange/format/request-review.ts Add intentional formatting seam stub.
src/structured-exchange/format/request-choices.ts Add intentional formatting seam stub.
src/structured-exchange/format/request-choice.ts Add intentional formatting seam stub.
src/structured-exchange/format/request-answer.ts Add intentional formatting seam stub.
src/structured-exchange/format/present-review-set.ts Add intentional formatting seam stub.
src/structured-exchange/format/present-question.ts Implement markdown formatting for projected present_question.
src/structured-exchange/format/present-options.ts Add intentional formatting seam stub.
src/structured-exchange/format/present-candidates.ts Add intentional formatting seam stub.
src/structured-exchange/format/capture-review.ts Add intentional formatting seam stub.
src/structured-exchange/format/capture-choices.ts Add intentional formatting seam stub.
src/structured-exchange/format/capture-choice.ts Add intentional formatting seam stub.
src/structured-exchange/format/capture-candidate.ts Add intentional formatting seam stub.
src/structured-exchange/format/capture-answer.ts Add intentional formatting seam stub.
src/session/session-transcript.ts Replace bespoke transcript rendering with projection+formatter pipeline.
src/session/session-transcript.test.ts Update transcript expectations to Pi-derived projection/markdown rendering.
src/session/project/transcript-context.ts New Pi-derived transcript projection (filter to markdown-bearing content).
src/session/format/transcript.ts New transcript markdown formatter.
src/rpc/handlers.test.ts Update tests for commitGraph created-node result shape.
src/render/toon.ts Add intentional TOON formatting substrate stub.
src/render/markdown.ts Add shared markdown helpers for formatters.
src/probes/public-rpc-parity-proof.test.ts Update transcript assertions to new tool-result headings.
src/probes/propose-graph-commit-proof.test.ts Expand proof scenarios + adapt to created-node/code evidence.
src/graph/workspace-store.ts Add selected-spec resolveNodeCode reader.
src/graph/spec-ownership.test.ts Update node-id assertions + strengthen tool-schema specId guard checks.
src/graph/snapshot.ts Add graph projections, node code resolver, kindOrdinal mapping, edge filtering.
src/graph/snapshot.test.ts Extend tests for code metadata, kindOrdinal, active vs truth projections.
src/graph/seed-fixtures.ts New consolidated seed-fixture loader + CLI (npm run seed).
src/graph/seed-fixtures.test.ts New tests proving loader runs through command boundary and preserves clock/log.
src/graph/schema/nodes.ts Add kind metadata, projected-code parse/format, and kindOrdinal on GraphNode.
src/graph/schema/edges.ts Update basis semantics comment for `explicit
src/graph/README.md Update topology/docs for new commitGraph planner and code/ordinal contract.
src/graph/project/reconciliation-needs.ts Add intentional projection seam stub.
src/graph/project/overview.ts Add intentional projection seam stub.
src/graph/project/neighborhood.ts Implement neighborhood projection using projected codes.
src/graph/project/commit-result.ts Add intentional projection seam stub.
src/graph/index.ts Re-export projected-code helpers and new overview option types.
src/graph/format/reconciliation-needs.ts Add intentional formatter seam stub.
src/graph/format/overview.ts Add intentional formatter seam stub.
src/graph/format/neighborhood.ts Implement neighborhood formatting for projected neighborhood.
src/graph/format/commit-result.ts Add intentional formatter seam stub.
src/graph/command-executor/commit-graph-types.ts New commitGraph input/result types (created node identity includes code).
src/graph/command-executor/commit-graph-batch.ts New shared batch planner (validation, supersession cycle detection).
src/db/schema.ts Persist kind_ordinal, add unique index, add node_kind_counters, update bases.
src/db/row-schemas.ts Add typebox schemas for node_kind_counters.
src/db/README.md Document new ordinal/counter storage contract.
src/brunch-tui.ts Thread resolveNodeCode into runtime snapshots.
src/agents/contexts/node.ts Switch node context rendering to projected neighborhood formatter.
src/agents/contexts/node.test.ts Update expectations to projected codes in node context.
src/agents/contexts/graph.ts Render graph context nodes/edges using projected codes.
src/agents/contexts/graph.test.ts Add kindOrdinal in graph context fixtures.
src/.pi/extensions/structured-exchange/present-question.ts Route tool through project + format seam for durable details/content.
src/.pi/extensions/graph/tool-schemas.ts Update tool schemas to use projected codes (existingCode, nodeCode).
src/.pi/extensions/graph/review-set-proposal.ts Make review-set translation basis: 'explicit' and remove per-item basis.
src/.pi/extensions/graph/index.ts Resolve node codes in adapters; return STRUCTURAL_ILLEGAL (no throws) for bad codes.
src/.pi/extensions/graph/command-adapter.ts Resolve existingCode → node id, format created nodes by code, export diagnostics formatter.
src/.pi/tests/structured-exchange-present-request.test.ts Add test proving present_question uses shared project+format seam.
src/.pi/tests/review-set-proposal.test.ts Assert review-set commits are explicit and don’t leak per-item basis fields.
src/.pi/tests/prompting.test.ts Update prompt context fixtures for kindOrdinal + snapshots API addition.
src/.pi/tests/graph-tools.test.ts Update schemas + adapters tests for projected codes and created-node result shape.
package.json Add npm run seed.
memory/SPEC.md Update FE-808 evidence claims and test coverage references.
memory/PLAN.md Mark FE-808 done; add dev seed-fixtures frontier; archive notes.
memory/cards/graph-tool-resilience--graph-write-contract.md Delete completed scope card.
drizzle/meta/_journal.json Record new migration.
drizzle/0001_aspiring_orphan.sql Add node_kind_counters + nodes.kind_ordinal + unique indexes.
docs/archive/PLAN_HISTORY.md Archive FE-808 closeout notes.
docs/architecture/probes-and-transcripts.md Update transcript.md description.
AGENTS.md Document “intentional topology stubs” convention.
.fixtures/seeds/bilal-port/README.md Update seed fixture location and consolidated contract docs.
.fixtures/seeds/bilal-port/_port-script.ts Update port script to consolidated contract + self-validation through loader.
.fixtures/runs/propose-graph-commit/2026-06-04-retry-diagnostics/transcript.md Add new probe transcript artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-retry-diagnostics/session.jsonl Add new probe session artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-retry-diagnostics/report.json Add new probe report artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-existing-code-ref/transcript.md Add new probe transcript artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-existing-code-ref/session.jsonl Add new probe session artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-existing-code-ref/report.json Add new probe report artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/transcript.md Add new probe transcript artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/session.jsonl Add new probe session artifact.
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/report.json Add new probe report artifact.
.agents/skills/ln-review/SKILL.md Add deletion-guard guidance for intentional topology stubs.
.agents/skills/ln-plan/references/earned.md Add deletion-guard guidance for intentional topology stubs.
.agents/skills/ln-judo-review/SKILL.md Add deletion-guard guidance for intentional topology stubs.
.agents/skills/ln-build/SKILL.md Add deletion-guard guidance for intentional topology stubs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +12
CREATE TABLE `node_kind_counters` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`spec_id` integer NOT NULL,
`plane` text NOT NULL,
`kind` text NOT NULL,
`next_ordinal` integer DEFAULT 1 NOT NULL,
FOREIGN KEY (`spec_id`) REFERENCES `specs`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `node_kind_counters_spec_plane_kind_unique` ON `node_kind_counters` (`spec_id`,`plane`,`kind`);--> statement-breakpoint
ALTER TABLE `nodes` ADD `kind_ordinal` integer NOT NULL;--> statement-breakpoint
CREATE UNIQUE INDEX `nodes_spec_plane_kind_ordinal_unique` ON `nodes` (`spec_id`,`plane`,`kind`,`kind_ordinal`); No newline at end of file
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.

2 participants