Skip to content

fix(hierarchy): the views under a workflow instance are read from the hierarchy rooted at it - #240

Merged
endrix merged 2 commits into
mainfrom
fix/recorded-instance-hierarchy
Nov 24, 2026
Merged

endrix merged 2 commits into
mainfrom
fix/recorded-instance-hierarchy

Conversation

@endrix

@endrix endrix commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What was wrong

Open orfs/picorv32_orfs.py and step into circuit (picorv32_flow(instance=RUN), a workflow instance answered by run picorv32-1). Then double-click flow. The view fails with:

Cannot render diagram from this file — ModuleNotFoundError: No module named 'streamblocks.designs.'

  • The producer's hierarchy export of picorv32_orfs leaves the instance out. It runs nothing with its parent, so the export has no circuit and nothing under it.
  • Every view under circuit therefore fell back to a plan of its own.
  • flow is made by a factory, streamblocks_flow(design="picorv32")(). Planned on its own it has no design, so the module path keeps the placeholder.
  • From picorv32_flow.py as the root, the same flow opens fine.

The fix

  • Where the views come from. The insides of an instance answered by a past run are what that run elaborated: its workflow, as a root of its own. hierarchyRootAt(trail) (shared) returns the deepest crumb that carries recordedRun (fix(run): the edges inside a workflow instance are drawn from the run it nests #239). A view at or under that crumb is read from the hierarchy rooted there, by the instance names below it.
  • The outline and node lists stay the trail root's. Their paths are the trail's, from its first crumb, and the outline is the one the reader navigates by, so a click on a row still builds the right trail.
  • A trail with no recorded crumb is read exactly as before.

Tests

hierarchy-cache.test.ts, 4 new tests:

  • the instance and a view under it are read from the instance's export, and each root is exported once;
  • the outline and node lists are the trail root's;
  • a trail through a live instance is still read from the trail root;
  • hierarchyRootAt takes the deepest crumb with recordedRun, never the root crumb.

Typecheck and neutrality pass. The diagram-server (1059) and diagram-client (1000) suites pass.

variant-node-create-wizard.test.ts times out at 5 s on this machine. It stubs the sidecar and imports nothing touched here, and it passed in main's CI.

Live check

VS Code harness, on a copy of the ORFS workspace with run picorv32-1:

https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu

… hierarchy rooted at it

A unit answered by a past run (`circuit = picorv32_flow(instance=RUN)`)
runs nothing with its parent, and the parent's hierarchy export has
nothing under it. Every view under it fell back to a plan of its own, and
a workflow made by a factory there (`streamblocks_flow(design=...)()`) had
no `design`: "ModuleNotFoundError: No module named
'streamblocks.designs.<design>'".

Its insides are what that run elaborated: its workflow, as a root of its
own. A view at or under the deepest crumb answered by a past run
(`hierarchyRootAt`) is read from the hierarchy rooted at that crumb, by
the instance names below it. The outline and the node lists stay the
trail root's, whose paths the trail has.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
…t once, one crumb rule

- Under a unit answered by a past run, the view carries no list of nodes:
  the trail root's nodes are not that run's, and the list's run is the
  view's (it would open the root's viewers against the past run).
- The unit's export and the trail root's (for the outline) are asked at
  once; a view whose trail root does not export is drawn without an
  outline, and the log says so.
- recordedRunOfTrail takes its crumb from hierarchyRootAt, so the run a
  view is drawn from and the hierarchy it is read from are rooted at the
  same crumb.
- The tests' temporary folders are removed.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
@endrix

endrix commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Review (/code-review medium), fixed in 378d40a:

  • The node list under a past run. The view now carries none there. The trail root's nodes are not that run's, and the list would have opened the root's viewers against the past run. Listing the instance's own viewers needs the list to be rooted at the instance, so that is left for a later change. Before this PR there was no list there either.
  • Two exports one after the other. They now run in parallel (Promise.all). When the trail root does not export, the view is drawn without an outline and the log says so (new test).
  • Two copies of the crumb rule. recordedRunOfTrail now takes its crumb from hierarchyRootAt.
  • Temp folders. The tests remove them in afterEach.

Not changed:

  • "Elaborated from today's source with default arguments, not what the run ran." Nothing gets worse here. Before this PR, the instance's own view and every view under it were already planned from today's file with defaults (plan --best-effort --workflow <unit>), and every view in Dialogram draws a run's overlay over the current source. The difference is that the views under the unit are now elaborated from the unit as a root, as a run of it is. The instance node carries only the run (meta.workflowInstance.run), with no arguments to elaborate from.
  • The cwd and variables for each crumb's file. A run of the unit's file starts at that file's run root (resolveRunRoot) with that file's variables. The run that answers the instance was such a run, and the plan this replaces used the same cwd and variables.

https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu

@endrix
endrix merged commit 6600ff1 into main Nov 24, 2026
1 check passed
@endrix
endrix deleted the fix/recorded-instance-hierarchy branch November 24, 2026 21:43
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.

1 participant