Skip to content

FE-1056: Move the handle integration guide into the architecture docs - #8926

Closed
kube wants to merge 12 commits into
mainfrom
petrinaut-sdcpn-input
Closed

FE-1056: Move the handle integration guide into the architecture docs#8926
kube wants to merge 12 commits into
mainfrom
petrinaut-sdcpn-input

Conversation

@kube

@kube kube commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Gives a host application a documented path to implementing its own PetrinautDocHandle, which is what TOPOS needs to embed Petrinaut in CatCollab (FE-1056). The integration guide moves into the Petrinaut architecture docs, where the build checks its links and layer references. On the code side, SDCPNInput lets hosts author documents without spelling out every extension field.

🔗 Related links

🔍 What does this change?

@hashintel/petrinaut-core

  • New types/sdcpn-input.ts: SDCPNInput is a loose authoring variant of SDCPN, and normalizeSDCPN() fills plain-net defaults. Arcs accept the placeId shorthand or an explicit endpoint (including component ports); subnets, componentInstances, and place isPort pass through. A complete SDCPN remains a valid SDCPNInput, asserted at compile time in the test.
  • createJsonDocHandle accepts SDCPNInput and normalizes internally.
  • Both are exported from the package root; changeset included (patch).

Architecture docs (@local/petrinaut-arch-docs)

  • content/handle/host-integration.mdx, attached to the core.handle layer: the contract, a per-member table of what the editor does with each handle member, the invariants a custom handle must keep (synchronous atomic change(), referentially stable doc(), emit-per-change, stable id), the model-mapping recipe, a worked adapter, the <Petrinaut /> prop table, and capabilities (now five extensions, including subnets). Two diagrams: a sequence of the local/remote event flows and a pipeline of the adapter's write paths.
  • content/handle/contract-gaps.mdx: where the contract under-specifies or misbehaves today (implicit invariants, readiness and lifecycle, local vs remote changes, validation and versioning, history under collaboration), each with the enhancement it calls for, and a sequencing note. Every claim was checked against the current code.
  • Both pages are linked from the docs index and appear under the core.handle layer's Guides section.

Removals

  • libs/@hashintel/petrinaut/INTEGRATION.md is deleted; its content was rewritten into the two pages above. The package READMEs keep a short embedding section and link to the new guide.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)
    • @hashintel/petrinaut-core: patch. The @hashintel/petrinaut change is README and files only, no changeset.

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

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

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • The handle interface is experimental. The contract-gaps page documents its current weaknesses; this PR does not fix them.

🐾 Next steps

The enhancements listed in contract-gaps.mdx, cheapest first: TSDoc for the implicit invariants plus a conformance test kit for third-party handles, an error channel and specified readiness semantics, validation shared between file import and handle construction, then local/remote and history semantics alongside the first collaborative backend.

🛡 What tests cover this?

  • types/sdcpn-input.test.ts: default filling, endpoint and subnet passthrough, absent-key preservation for structural equality, idempotence on a complete document, and the compile-time SDCPN-to-SDCPNInput assignability assertion.
  • lint:arch-docs fails the build on unresolved doc:/layer: links, unknown attachTo targets, and missing @diagrams/ components in the new pages.

❓ How to test this?

  1. turbo run test:unit --filter @hashintel/petrinaut-core
  2. yarn workspace @local/petrinaut-arch-docs lint:arch-docs
  3. turbo run dev --filter @apps/petrinaut-docs, then open Architecture → core → handle: both guides appear under "Guides", with the diagrams rendered.

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 27, 2026 3:29pm
petrinaut Ready Ready Preview Aug 27, 2026 3:29pm
petrinaut-docs Ready Ready Preview Aug 27, 2026 3:29pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 27, 2026 3:29pm

Request Review

@github-actions github-actions Bot added 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 labels Jul 1, 2026
@semgrep-code-hashintel

Copy link
Copy Markdown

Semgrep found 4 path-join-resolve-traversal findings:

Detected possible user input going into a path.join or path.resolve function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>.claude/setup.mjs</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/hashintel/hash/blob/3c80fef937ed2cd8869428222504b8915ebc22eb/.claude/setup.mjs#L226 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 226] _0x2912ea</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/hashintel/hash/blob/3c80fef937ed2cd8869428222504b8915ebc22eb/.claude/setup.mjs#L226 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 226] _0x2912ea</a>"]
        end
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/hashintel/hash/blob/3c80fef937ed2cd8869428222504b8915ebc22eb/.claude/setup.mjs#L257 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 257] _0x2912ea</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading

@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 4, 2026 10:35 Inactive
@TimDiekmann
TimDiekmann force-pushed the petrinaut-sdcpn-input branch from 3c80fef to 52ee22d Compare August 4, 2026 14:13
@kube
kube force-pushed the petrinaut-sdcpn-input branch from 52ee22d to 00a0fb7 Compare August 16, 2026 02:58
@github-actions github-actions Bot added the type/eng > backend Owned by the @backend team label Aug 16, 2026
@kube kube changed the title FE-1056: Improve Petrinaut Handle + Integration Docs FE-1056: Move the handle integration guide into the architecture docs Aug 16, 2026
@kube kube self-assigned this Aug 16, 2026
kube added 2 commits August 27, 2026 03:25
Sort masked depends-on entries so count-driven reordering cannot flag a
page; scope every mask to the block shape it targets, keeping embedded
README prose untouched. Clean up the scratch tree on any extraction
failure and only swallow git-archive pathspec misses; refuse refs with a
leading dash. Warn on an empty --diff-base, drop dead custom properties,
and mark sidebar links with a data attribute instead of a second class.
@kube
kube force-pushed the petrinaut-sdcpn-input branch from e8b0afe to 3454ded Compare August 27, 2026 01:49
@kube
kube changed the base branch from main to claude/fe-1514-arch-docs-diff-highlighting August 27, 2026 01:49
@kube

kube commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Restacked and revised, per request:

  • Rebased onto claude/fe-1514-arch-docs-diff-highlighting (PR FE-1514: Highlight arch-docs changes against a base ref on preview builds #9366, the arch-docs diff mode) and retargeted the PR there, so this now sits at the top of that stack. The five original commits are squashed into one.
  • Re-verified the guide's claims against current main: the PetrinautDocHandle interface, the full <Petrinaut> prop table, the SDCPN optional-field list, the export list, and the four reference-implementation paths are all still accurate. No handle-relevant code changed in the 71 commits the branch was behind. One row updated: aiAssistant also carries interactive tools since FE-1448.
  • Prose pass per the house technical-writing rules: "gate" → check, "surfaces" → shows, "invariants" → requirements (headings, anchors and cross-links updated), one duplicated-fact sentence removed.
  • Gates on the restacked branch: petrinaut-core 943 tests + tsc, lint:arch-docs, formatting, and the docs-site build (60 pages) all pass.

A nice side effect of the stacking: this branch's own diff build flags exactly its footprint — the two guides as new, the handle layer page and core.types (which gains sdcpn-input.ts) as changed — so the preview deployment will show reviewers precisely these pages.

🤖 Generated with Claude Code

…supply it

A Vercel build gets a snapshot of the sources with no usable git clone
behind it, so resolving the base ref locally fails and every preview
degraded to a plain bundle. When local resolution fails, fetch the ref
from the public repository into a scratch repo — blobless, with a
sparse checkout of only the covered directories — and log which
strategy ran. Verified against github.com from a directory with no
clone: 3s to materialize, and the base model matches a local build.
@kube
kube force-pushed the petrinaut-sdcpn-input branch from 53a4f16 to 6a1fdd0 Compare August 27, 2026 12:18
Two linked chips beside the title on diff builds: the deployed PR (or
branch) and the base it is diffed against, each with the commit built.
The base's PR is looked up by head branch, anonymously; the context is
resolved once in astro.config.mjs and injected as a compile-time
constant, since a bundled component has no stable path to the manifest.
Cache entries are keyed in the file name by the generator-inputs hash
then the base commit, so different generator versions keep separate
entries instead of overwriting one slot. Every clean build also stores
its own side as a future base: the CI cache falls back to the
production deployment's, so the entry a main build writes is what a PR
targeting main finds on its first build — the common case computes no
base at all, and entries shared across branches are only ever written
by protected-branch builds.
kube added 2 commits August 27, 2026 16:56
Base-side acquisition (cache lookup, materialization, build, seeding)
moves from cli.ts into diff/base-side.ts, leaving the CLI as wiring and
logging. Ref validation runs at every entry point that takes a ref, not
only in materialization, so no call order lets an unvalidated ref reach
a git command line; the credentialed origin-fetch fallback is removed —
local resolution either succeeds or the anonymous fetch takes over.
ls-remote resolution peels annotated tags to the commit the cache and
materialization both key on. The CI resolver's crash costs the
highlighting instead of the deploy, and it only prints branch-name
shaped output; branch names are URL-encoded in the header chips.
The default stays node_modules/.cache, which CI providers persist
without configuration and local builds can always write; a CI whose
persisted location differs sets PETRINAUT_ARCH_DOCS_CACHE_DIR instead
of the code guessing its layout.
@cursor

cursor Bot commented Aug 27, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Backward-compatible API widening plus documentation; no changes to auth, persistence, or editor mutation paths beyond normalizing handle initial input.

Overview
Moves Petrinaut host embedding documentation into the architecture docs (host-integration.mdx, contract-gaps.mdx) under the core.handle layer, with index links and short embedding sections in the @hashintel/petrinaut and @hashintel/petrinaut-core READMEs (replacing the old package-level integration write-up).

In @hashintel/petrinaut-core, adds SDCPNInput and normalizeSDCPN() so hosts can seed documents without every extension field; createJsonDocHandle now takes SDCPNInput and normalizes before existing extension sanitization. Types and the normalizer are exported from the package root, with unit tests and a patch changeset.

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

kube added 2 commits August 27, 2026 17:18
Two of these were invisible on GitHub: base-cache.ts carried raw NUL
bytes as hash separators, so git rendered it as a binary file — now the
escape spelling, with identical hash input — and the ref guard's
control-character class tripped oxlint's no-control-regex; it is now an
allow-list, which also subsumes the empty and leading-dash checks.

The prune could evict exactly the shared base entry: eviction now
orders by last use (a hit refreshes the timestamp), the cap rises to
16, and seeding runs after the diff has read its base. Cache keys hash
package-relative paths, so relocated checkouts sharing a cache
directory hit. Seeding is wrapped whole — no failure in a bonus write
may fail a passed build. Network git calls get a timeout and prompt
suppression; the marker stylesheet reads every hue through its custom
property so re-theming works as documented; empty Vercel variables no
longer produce empty header chips.
Base automatically changed from claude/fe-1514-arch-docs-diff-highlighting to main August 27, 2026 15:56
@kube kube closed this in #9366 Aug 27, 2026
@kube
kube force-pushed the petrinaut-sdcpn-input branch from b8740a9 to 5b9aa22 Compare August 27, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

2 participants