Skip to content

FE-1850, FE-1336: Explain a net element from the Ledger, on the canvas and to Brunch - #10067

Open
lunelson wants to merge 21 commits into
ln/fe-1943-shorten-turn-timesfrom
ln/fe-1850-1336-1851-ledger-provenance-comments
Open

lunelson wants to merge 21 commits into
ln/fe-1943-shorten-turn-timesfrom
ln/fe-1850-1336-1851-ledger-provenance-comments

Conversation

@lunelson

@lunelson lunelson commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🌟 What is the purpose of this PR?

Brunch and its users can now ask why a net element is modelled the way it is and get an answer from the Ledger. Select something on the canvas and the Ledger tab shows the reflections that name it, the claims they rest on and the user messages behind those claims, and highlights those records in the Ledger. The query_basis tool gives Brunch the same answer. The Ledger tab is now a document whose records carry anchors, which is the ground the next step, comments on the Ledger (FE-1851), builds on.

The branch also gives each type shared by the Brunch server and website one owner, mostly in @hashintel/brunch-agent, and trims that library's exports to what its consumers import.

🔗 Related links

🚫 Blocked by

🔍 What does this change?

  • One backward trace. traceLedger follows a net element to the reflections that name it, then to their claims, entities and discharged obligations, and each record to the user turn it came from. It never walks forward: an entity does not pull in every claim about it.

  • query_basis answers from that trace alone. Its dispositions are basis-declared, basis-absent, not-found and stale-read. It no longer treats records committed in the same turn as an element's basis, so an element no reflection names reads as having no recorded basis. Turn excerpts (240 characters) are filled in. Brunch is told to quote the turns it cites, and to offer no rationale of its own when no basis was recorded.

  • Ledger tab as a document. The tab renders the Ledger projection as React instead of Markdown. Every record occurrence carries data-ledger-address, and record IDs stay hidden.

  • Canvas selection. A panel explains the selection, or says Brunch recorded no reasoning for it. The records behind it are ringed and the rest fade; the first scrolls into view.

  • Reflections. Show Brunch's reflections, off by default, lists each reflection under the entities it concerns. Show in net selects the elements it names. The tab reads and sets the selection through Brunch's editor plugin, so the host passes nothing.

  • Badge. The Ledger tab's badge counts commits only; net changes add nothing to read there.

  • Markdown only for the model. The user skin of renderLedgerMarkdown had no callers left and is removed. The model's Markdown is unchanged, byte for byte.

  • User turns. Petrinaut's injected diagnostics are dropped from Brunch's user turns, and the petrinaut-contextual-user-message envelope is removed. Making that injection optional per host is FE-1991.

  • Shared ID matching. namesId moves into @hashintel/brunch-agent, with netElementSelectionItem and namesSelectionItem, so the website matches the IDs Brunch wrote as query_basis does.

  • react-markdown and remark-gfm leave the website.

  • Type ownership. The library's README states which code belongs there: what the server and browser must agree on. The library now owns, and both sides import:

    • the browser-tool result envelope;
    • the browser-call protocol;
    • the set of tools the browser runs;
    • the net read-back type (NetStructure);
    • Ledger record types derived from their schemas.

    The server takes thinking levels, JSON and chronology types from Flue. The website takes its voice, approval and replay types from their owners. The library exports only what its consumers import.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

  • Changes only @hashintel/brunch-agent, which is private, and the unpublished docs/ of @hashintel/petrinaut. No changeset.

📜 Does this require a change to the docs?

  • libs/@hashintel/petrinaut/docs/ai-assistant.md describes the selection panel, the reflections switch and the badge. apps/brunch-agent/docs/petrinaut/ARCHITECTURE.md describes query_basis and the tab.

🕸️ Does this require a change to the Turbo Graph?

  • Does not affect the execution graph.

⚠️ Known issues

  • The canvas link and query_basis assume reflections name the net elements they explain. Nothing enforces that yet (FE-2020). In a live session, reflections named every top-level place and transition but no parameters, arcs or elements inside a subnet.
  • Brunch doesn't see the canvas selection, so a "why" question has to name the element (FE-1332).
  • Show in net selects an element inside a subnet the user isn't viewing but doesn't move the canvas there.
  • A confirmed claim with no entity appears in neither ledger_compile nor the Ledger tab (from FE-1764: Keep elicited knowledge in an efficient append-only Ledger #9865).
  • src/server/provider-admission.test.ts fails intermittently, also when run alone. It predates this branch.

🛡 What tests cover this?

  • traceLedger, the projection's per-entity reflections, ID matching and query_basis dispositions have unit tests.
  • Pane tests cover the document, the selection panel, the reflections switch and the badge. An in-editor test runs Show in net through the real editor and plugin and checks the selection comes back explained.
  • Checked live in a persona-built conversation. Asked why a place is modelled as it is, Brunch called query_basis and answered from the reflections and claims behind it. Asked about a parameter no reflection names, it said no basis was recorded.
  • Lint, type, unit, build and integration checks pass for @hashintel/brunch-agent, @apps/brunch-agent, @apps/petrinaut-website and @tests/petrinaut-brunch-integration.

@lunelson
lunelson added this pull request to stack #10068 October 16, 2026 11:23
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
petrinaut Ready Ready Preview Oct 20, 2026 4:17pm UTC
petrinaut-docs Ready Ready Preview Oct 20, 2026 4:17pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
hash Ignored Ignored Preview Oct 20, 2026 4:17pm UTC
hashdotdesign-tokens Ignored Ignored Preview Oct 20, 2026 4:17pm UTC

Request Review

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team area/apps labels Oct 16, 2026
@lunelson lunelson changed the title ln/fe 1850 1336 1851 ledger provenance comments FE-1850, FE-1336: Explain a net element from the Ledger, on the canvas and to Brunch Oct 16, 2026
@lunelson
lunelson force-pushed the ln/fe-1850-1336-1851-ledger-provenance-comments branch from a0a1463 to 0237453 Compare October 16, 2026 16:35
@github-actions github-actions Bot added the area/tests New or updated tests label Oct 16, 2026
@lunelson
lunelson force-pushed the ln/fe-1850-1336-1851-ledger-provenance-comments branch from 0237453 to 6c6fab9 Compare October 19, 2026 08:31
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs October 19, 2026 13:37 Inactive
@lunelson
lunelson force-pushed the ln/fe-1850-1336-1851-ledger-provenance-comments branch from ff1b216 to ace369b Compare October 19, 2026 13:45
lunelson and others added 20 commits October 20, 2026 17:49
Petrinaut's assistant panel appends a reserved diagnostics message after client tool results. Brunch's adapter packed it into the human's turn as a JSON envelope that the server never unpacked, so the model and the stored history read raw JSON instead of the user's words. Brunch checks diagnostics through its own getNetCompilationErrors tool, so the adapter now drops the reserved message and the envelope leaves @hashintel/brunch-agent. Making the injection each host's choice is FE-1991.
traceLedger walks back from net elements or record addresses to the reflections, obligations, claims and entities behind them, and the turns those records came from. query_basis now answers from that trace instead of listing every record committed in the same turn as a change, and reports a traced claim a later claim replaced. Each turn now carries the opening of the user's words instead of an empty excerpt.
The Ledger tab renders the projection as React instead of Markdown, marking every record occurrence with its address. Selecting net elements shows the reflections that name them, the claims they rest on and the turns they came from, and highlights those records. Reflections can be shown under their entities, each able to select the net elements it names. namesId moves to @hashintel/brunch-agent so the website matches written IDs the way query_basis does.
…nly for commits

The Ledger tab renders the projection as a document, so the Markdown renderer's user skin had no caller left; renderLedgerMarkdown now always carries addresses and kind tokens. The tab's badge counted net changes too, which lit it up while the tab still had nothing to show; it now counts accepted commits only.
Traced records get a stronger fill, a ring and medium weight; the rest of the document recedes while a selection is traced, and the first traced record scrolls into view.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1 potential issue.

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 0e9955d. Configure here.

Comment thread libs/@hashintel/brunch-agent/src/ledger/trace.ts Outdated

This branch was successfully deployed

3 active (1 outdated) deployments
Preview – petrinaut-docs — 94852d8c Deployed Oct 20, 2026 by vercel[bot]
Preview – petrinaut — 94852d8c Deployed Oct 20, 2026 by vercel[bot]
Preview – hash — 0e9955d2 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants