Skip to content

FE-808: Broaden direct graph-tool proof beyond the A14 happy path#171

Merged
lunelson merged 21 commits into
nextfrom
ln/fe-808-graph-tool-resilience
Jun 5, 2026
Merged

FE-808: Broaden direct graph-tool proof beyond the A14 happy path#171
lunelson merged 21 commits into
nextfrom
ln/fe-808-graph-tool-resilience

Conversation

@lunelson
Copy link
Copy Markdown
Contributor

@lunelson lunelson commented Jun 4, 2026

Summary

Hardens direct graph-tool behavior beyond the first happy path: stable graph handles, persisted kind ordinals, explicit/implicit basis normalization, reference resolution, supersession cycle protection, and probe-backed graph resilience checks.

Verification

Covered by graph command/tool, projection, seed-loader, and probe fixture tests; latest top-of-stack verification passed via npm run verify.

@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 docs, committed probe artifacts, and fixture cleanup—no runtime graph implementation in this diff.

Overview
Extends direct graph-tool proof beyond a single happy path by checking in three A14-L propose-graph-commit probe runs under .fixtures/runs/propose-graph-commit/: linking a new node to an existing goal via existingCode, recovering from STRUCTURAL_ILLEGAL diagnostics on a retry, and not calling commit_graph when the prompt is too ambiguous (clarification only).

Aligns agent workflows with AGENTS.md §intentional topology stubs: ln-build, ln-review, ln-judo-review, and ln-plan (earned) now treat comment-rich export {} files as planned seams—not delete candidates on unusedness or passing build alone.

Removes the redundant .fixtures/seed-specs/bilal-port/code-health/edges.json blob; bilal port seed data remains under .fixtures/seeds/bilal-port/.

Reviewed by Cursor Bugbot for commit ede9c8e. 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
@lunelson lunelson changed the title FE-808 persist graph node ordinals FE-808: Broaden direct graph-tool proof beyond the A14 happy path Jun 5, 2026
@lunelson lunelson force-pushed the ln/fe-806-agents-composition-layer branch from 8a9ab43 to be0b42b Compare June 5, 2026 09:26
@lunelson lunelson force-pushed the ln/fe-808-graph-tool-resilience branch from 03a8137 to 3304114 Compare June 5, 2026 09:26
Base automatically changed from ln/fe-806-agents-composition-layer to next June 5, 2026 09:27
lunelson and others added 11 commits June 5, 2026 11:35
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>
Copilot AI review requested due to automatic review settings June 5, 2026 09:36
@lunelson lunelson force-pushed the ln/fe-808-graph-tool-resilience branch from 3304114 to ede9c8e Compare June 5, 2026 09:36
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

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

Comment on lines +11 to +12
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
@lunelson lunelson merged commit 6f1397b into next Jun 5, 2026
7 checks passed
@lunelson lunelson deleted the ln/fe-808-graph-tool-resilience branch June 5, 2026 09:46
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