Skip to content

FE-807: Structured response capture into selected-spec graph truth#173

Open
lunelson wants to merge 17 commits into
nextfrom
ln/fe-807-capture-response-to-graph
Open

FE-807: Structured response capture into selected-spec graph truth#173
lunelson wants to merge 17 commits into
nextfrom
ln/fe-807-capture-response-to-graph

Conversation

@lunelson
Copy link
Copy Markdown
Contributor

@lunelson lunelson commented Jun 5, 2026

Summary

Carries the cumulative review-response fixes for the stack: WebSocket cleanup hardening, web update/route validation, structured-exchange request tool activation, prompt-context registration cleanup, seed-edge deduplication, and non-empty graph migration backfill.

Verification

npm run verify passed on the top branch.

@lunelson lunelson changed the title Align chain-card stale status FE-807: Structured response capture into selected-spec graph truth Jun 5, 2026
@lunelson lunelson force-pushed the ln/fe-807-capture-response-to-graph branch from 7db75c9 to f333700 Compare June 5, 2026 09:26
@lunelson lunelson force-pushed the ln/fe-808-graph-tool-resilience branch 2 times, most recently from 3304114 to ede9c8e Compare June 5, 2026 09:36
@lunelson lunelson force-pushed the ln/fe-807-capture-response-to-graph branch from f333700 to 597841f Compare June 5, 2026 09:36
Base automatically changed from ln/fe-808-graph-tool-resilience to next June 5, 2026 09:46
@lunelson lunelson marked this pull request as ready for review June 5, 2026 12:39
Copilot AI review requested due to automatic review settings June 5, 2026 12:39
@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 5, 2026

PR Summary

Low Risk
Mostly committed fixtures, docs, and seed-generation script changes; edge deduplication only affects emitted Bilal seed JSON, not runtime product code in this diff.

Overview
Extends the fixture/probe story beyond transcript-only runs: .fixtures now documents a seeds/ layout for reusable explicit-basis starting truth and optional graph-snapshot.json when graph readback is the proof target.

Adds bilal-port-variants with a reproducible macro-view-grounded-intent seed (intent-plane, explicit, grounded sources only) plus _variant-script.ts, and commits a fixture-curation probe run showing read_graph → single commit_graph on that seed (two implicit requirements, graph snapshot at LSN 3).

Bilal port script now deduplicates edges after node collapse (source/target/category/stance key) and tracks duplicate-after-collapse drops in generated README stats (lower emitted edge counts for the three specs).

ln-scope chain discipline adds stale as an explicit card status alongside next/in progress/done/dropped.

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

@lunelson lunelson force-pushed the ln/fe-807-capture-response-to-graph branch from 597841f to 221be7e Compare June 5, 2026 12:40
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 the “selected-spec graph truth” pipeline by (1) adding durable node-code ordinals + resolution, (2) wiring synchronous capture of labeled structured-exchange text answers into CommandExecutor.commitGraph, and (3) hardening the web/WebSocket update path and transcript/probe artifacts to reflect Pi-derived LLM-visible context.

Changes:

  • Add kindOrdinal-backed projected node codes (DB migration, snapshot readers, code parsing/formatting, code resolution).
  • Capture labeled request_answer text into explicit-basis graph commits via session.submitExchangeResponse, and publish targeted graph.* invalidations; add gated dev.graph.commitGraph harness + seed loader + docs.
  • Refactor transcript rendering to a project/format seam aligned with Pi-derived LLM context; tighten web route param validation and update invalidation filtering; harden WebSocket send/error handling.

Reviewed changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web/subscriptions/brunch-updates.ts Filter malformed update entries before invalidation
src/web/routes/spec.tsx Validate /spec/$specId before graph queries
src/web/README.md Update mutation invalidation note for capture
src/web/features/graph/GraphOverview.tsx Avoid per-node array copies when grouping
src/web/app.test.tsx Add tests for malformed updates + invalid spec route
src/structured-exchange/project/request-review.ts Topology stub for request_review projection
src/structured-exchange/project/request-choices.ts Topology stub for request_choices projection
src/structured-exchange/project/request-choice.ts Topology stub for request_choice projection
src/structured-exchange/project/request-answer.ts Topology stub for request_answer projection
src/structured-exchange/project/present-review-set.ts Topology stub for present_review_set projection
src/structured-exchange/project/present-question.ts Implement present_question projection + details
src/structured-exchange/project/present-options.ts Topology stub for present_options projection
src/structured-exchange/project/present-candidates.ts Topology stub for present_candidates projection
src/structured-exchange/project/capture-review.ts Topology stub for capture_review projection
src/structured-exchange/project/capture-choices.ts Topology stub for capture_choices projection
src/structured-exchange/project/capture-choice.ts Topology stub for capture_choice projection
src/structured-exchange/project/capture-candidate.ts Topology stub for capture_candidate projection
src/structured-exchange/project/capture-answer.ts Topology stub for capture_answer projection
src/structured-exchange/format/request-review.ts Topology stub for request_review formatting
src/structured-exchange/format/request-choices.ts Topology stub for request_choices formatting
src/structured-exchange/format/request-choice.ts Topology stub for request_choice formatting
src/structured-exchange/format/request-answer.ts Topology stub for request_answer formatting
src/structured-exchange/format/present-review-set.ts Topology stub for present_review_set formatting
src/structured-exchange/format/present-question.ts Format present_question projection to markdown
src/structured-exchange/format/present-options.ts Topology stub for present_options formatting
src/structured-exchange/format/present-candidates.ts Topology stub for present_candidates formatting
src/structured-exchange/format/capture-review.ts Topology stub for capture_review formatting
src/structured-exchange/format/capture-choices.ts Topology stub for capture_choices formatting
src/structured-exchange/format/capture-choice.ts Topology stub for capture_choice formatting
src/structured-exchange/format/capture-candidate.ts Topology stub for capture_candidate formatting
src/structured-exchange/format/capture-answer.ts Topology stub for capture_answer formatting
src/session/session-transcript.ts Delegate transcript rendering to project/format seam
src/session/session-transcript.test.ts Update transcript expectations to Pi-derived context
src/session/project/transcript-context.ts Project + filter LLM-visible messages from session
src/session/format/transcript.ts Format projected transcript messages to markdown
src/rpc/websocket.ts Harden request handling + defer notifications + safe send
src/rpc/web-host.test.ts Test updates still deliver after a failed request
src/rpc/README.md Document capture result + dev RPC gating + code refs
src/rpc/methods/session.ts Add capture outcome + publish graph invalidations
src/rpc/methods/dev-graph.ts Add gated dev.graph.commitGraph harness
src/rpc/handlers.ts Allow dev RPC registry extension; share graph runtime
src/render/toon.ts Topology stub for TOON formatting substrate
src/render/markdown.ts Shared markdown helpers (headings/bullets/blocks)
src/probes/public-rpc-parity-proof.test.ts Adjust transcript assertions post-refactor
src/probes/propose-graph-commit-proof.test.ts Update proof schema + add scenario classifiers
src/probes/fixture-curation-loop.test.ts Add fixture curation loop report/artifact tests
src/probes/capture-response-to-graph-proof.ts New probe: response capture → graph truth proof
src/probes/capture-response-to-graph-proof.test.ts Tests for capture-to-graph probe + artifacts
src/graph/workspace-store.ts Add selected-spec resolveNodeCode reader
src/graph/spec-ownership.test.ts Update commitGraph result shape; tighten schema guard test
src/graph/snapshot.ts Add kindOrdinal mapping; add graph_truth projection; code resolver
src/graph/snapshot.test.ts Add node-code metadata tests; update projection expectations
src/graph/seed-fixtures.ts Seed consolidated fixtures via CommandExecutor (CLI)
src/graph/seed-fixtures.test.ts Tests for seedFixture behavior + basis rejection
src/graph/schema/nodes.ts Add code labels/parse/format + readiness bands + kindOrdinal
src/graph/schema/edges.ts Update basis semantics comment (explicit/implicit)
src/graph/README.md Document capture translators + ordinals + snapshot additions
src/graph/project/reconciliation-needs.ts Topology stub for reconciliation-need projection
src/graph/project/overview.ts Topology stub for overview projection
src/graph/project/neighborhood.ts Implement neighborhood projection using node codes
src/graph/project/commit-result.ts Topology stub for commit result projection
src/graph/index.ts Re-export code parse/format + new snapshot option types
src/graph/format/reconciliation-needs.ts Topology stub for reconciliation-need formatting
src/graph/format/overview.ts Topology stub for overview formatting
src/graph/format/neighborhood.ts Format projected neighborhood into model-facing text
src/graph/format/commit-result.ts Topology stub for commit-result formatting
src/graph/command-executor/commit-graph-types.ts New shared commitGraph input/result types
src/graph/capture/structured-response.ts Capture labeled text answers into explicit-basis commitGraph
src/graph/capture/structured-response.test.ts Tests for capture: success/no_capture/diagnostics/non-text
src/db/schema.ts Add kind_ordinal + node_kind_counters; basis enum update; indexes
src/db/row-schemas.ts Add row schemas for node_kind_counters
src/db/README.md Update schema posture docs for ordinals/counters
src/db/connection.test.ts Test migration of non-empty legacy DB to ordinals/basis
src/brunch.ts Gate dev RPC methods via BRUNCH_DEV_RPC in rpc mode
src/brunch.test.ts Test BRUNCH_DEV_RPC gating exposes dev method in discovery
src/brunch-tui.ts Add resolveNodeCode to runtime graph readers
src/brunch-tui.test.ts Expect request_* tools active for structured exchange
src/agents/state.ts Add request_* tools to structured-exchange method tool list
src/agents/state.test.ts Update tool expectations to include request_*
src/agents/contexts/node.ts Switch to project/format neighborhood renderer
src/agents/contexts/node.test.ts Update expectations to node-code anchors/endpoints
src/agents/contexts/graph.ts Render node/edge endpoints using projected node codes
src/agents/contexts/graph.test.ts Add kindOrdinal to test node helpers
src/.pi/pi-extension-shell.ts Conditionally register prompting only with promptContext
src/.pi/extensions/structured-exchange/present-question.ts Route present_question through project+format seam
src/.pi/extensions/prompting.ts Require promptContext param; remove runtime throw path
src/.pi/extensions/graph/tool-schemas.ts Use existingCode + nodeCode schema changes; tighten additionalProperties
src/.pi/extensions/graph/review-set-proposal.ts Commit review-set proposals as explicit-basis batch
src/.pi/extensions/graph/index.ts Resolve existingCode/nodeCode; structural_illegal formatting; new renderer
src/.pi/extensions/graph/command-adapter.ts Normalize edge refs via existingCode; render codes in outputs
src/.pi/tests/structured-exchange-present-request.test.ts Add test for present_question project/format seam
src/.pi/tests/review-set-proposal.test.ts Assert explicit basis + no per-item basis fields
src/.pi/tests/prompting.test.ts Update prompt-pack tests for kindOrdinal + request_* tools
src/.pi/tests/operational-mode.test.ts Update active tools list to include request_*
src/.pi/tests/extension-registry.test.ts Remove duplicate event expectation
package.json Add seed script for fixture seeding
memory/cards/tooling--worktree-command-ux.md Add/update tooling scope card (worktree UX hardening)
drizzle/meta/_journal.json Register migration 0001
drizzle/0001_aspiring_orphan.sql Migration: ordinals, counters, basis rewrite, unique indexes
docs/testing/seeded-dev-rpc.md Guide for seeded workspace + gated dev RPC workflow
docs/README.md Link new testing guide
docs/archive/PLAN_HISTORY.md Archive completion notes for recent frontiers
docs/architecture/probes-and-transcripts.md Clarify transcript.md is Pi-derived context rendering
AGENTS.md Add “intentional topology stubs” policy
.fixtures/seeds/bilal-port/README.md New seed-set README documenting provenance/contract
.fixtures/seeds/bilal-port-variants/README.md Variant seed-set README
.fixtures/seeds/bilal-port-variants/_variant-script.ts Script to generate grounded intent variant seed
.fixtures/seed-specs/bilal-port/README.md Remove legacy seed-specs layout (deleted)
.fixtures/seed-specs/bilal-port/macro-view/spec.json Remove legacy seed-specs file (deleted)
.fixtures/seed-specs/bilal-port/explorer-ui/spec.json Remove legacy seed-specs file (deleted)
.fixtures/seed-specs/bilal-port/code-health/spec.json Remove legacy seed-specs file (deleted)
.fixtures/runs/propose-graph-commit/2026-06-04-retry-diagnostics/report.json Add committed probe report artifact
.fixtures/runs/propose-graph-commit/2026-06-04-existing-code-ref/session.jsonl Add committed probe session JSONL artifact
.fixtures/runs/propose-graph-commit/2026-06-04-existing-code-ref/report.json Add committed probe report artifact
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/transcript.md Add committed probe transcript artifact
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/session.jsonl Add committed probe session JSONL artifact
.fixtures/runs/propose-graph-commit/2026-06-04-ambiguity-no-overcommit/report.json Add committed probe report artifact
.fixtures/runs/fixture-curation/fixture-curation-2026-06-05T104440Z/report.json Add fixture-curation committed report artifact
.fixtures/README.md Document seeds + optional graph snapshot artifacts
.agents/skills/ln-scope/SKILL.md Allow stale card status
.agents/skills/ln-review/SKILL.md Add deletion guard for topology stubs
.agents/skills/ln-plan/references/earned.md Add topology-stub deletion caution
.agents/skills/ln-judo-review/SKILL.md Guard against deleting topology stubs
.agents/skills/ln-build/SKILL.md Guard against deleting comment-only export {} stubs

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

Comment thread src/rpc/websocket.ts
import type { Server as HttpServer } from 'node:http';

import { WebSocketServer, type RawData } from 'ws';
import { WebSocketServer, type RawData, type WebSocket } from 'ws';
Comment thread src/rpc/websocket.ts
Comment on lines +103 to 111
function sendIfOpen(client: WebSocket, message: string): void {
if (client.readyState !== client.OPEN) return;
try {
client.send(message);
} catch {
// Ignore per-client transport failures; other observers and request
// accounting must continue.
}
}
Comment on lines +119 to +121
if (options.promptContext) {
extensions.splice(4, 0, (api) => registerBrunchPrompting(api, options.promptContext!));
}
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 221be7e. Configure here.

continue;
}
brunchEdges.push({
emitEdge({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Synthetic edges win duplicate dedup

Medium Severity

emitEdge keeps the first edge for a given endpoint/category/stance key and silently drops later ones. Synthetic realization edges from phase 3a are emitted before Bilal produced edges in 3b, so duplicated realization rows lose the ported edge (including any rationale) even when that row is the authoritative source.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 221be7e. Configure here.

"sessionJsonl": "/Users/lunelson/Code/hashintel/brunch-next/.fixtures/runs/fixture-curation/fixture-curation-2026-06-05T104440Z/session.jsonl",
"transcriptMarkdown": "/Users/lunelson/Code/hashintel/brunch-next/.fixtures/runs/fixture-curation/fixture-curation-2026-06-05T104440Z/transcript.md",
"reportJson": "/Users/lunelson/Code/hashintel/brunch-next/.fixtures/runs/fixture-curation/fixture-curation-2026-06-05T104440Z/report.json",
"graphSnapshotJson": "/Users/lunelson/Code/hashintel/brunch-next/.fixtures/runs/fixture-curation/fixture-curation-2026-06-05T104440Z/graph-snapshot.json"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Probe report uses absolute paths

Low Severity

The new fixture-curation report.json stores machine-specific absolute paths under artifacts (a developer home directory), while other committed probe reports use repo-relative paths. That breaks portable references for reviewers and any tooling that expects stable artifact locations.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 221be7e. Configure here.

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