FE-807: Structured response capture into selected-spec graph truth#173
FE-807: Structured response capture into selected-spec graph truth#173lunelson wants to merge 17 commits into
Conversation
7db75c9 to
f333700
Compare
3304114 to
ede9c8e
Compare
f333700 to
597841f
Compare
PR SummaryLow Risk Overview Adds Bilal port script now deduplicates edges after node collapse (source/target/category/stance key) and tracks
Reviewed by Cursor Bugbot for commit 221be7e. Bugbot is set up for automated code reviews on this repo. Configure here. |
597841f to
221be7e
Compare
There was a problem hiding this comment.
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_answertext into explicit-basis graph commits viasession.submitExchangeResponse, and publish targetedgraph.*invalidations; add gateddev.graph.commitGraphharness + 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.
| import type { Server as HttpServer } from 'node:http'; | ||
|
|
||
| import { WebSocketServer, type RawData } from 'ws'; | ||
| import { WebSocketServer, type RawData, type WebSocket } from 'ws'; |
| 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. | ||
| } | ||
| } |
| if (options.promptContext) { | ||
| extensions.splice(4, 0, (api) => registerBrunchPrompting(api, options.promptContext!)); | ||
| } |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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({ |
There was a problem hiding this comment.
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.
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" |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 221be7e. Configure here.



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 verifypassed on the top branch.