Repository navigation
refactor(runtime): key state executor state by graph-local ids - #2145
Open
devin-ai-integration[bot] wants to merge 6 commits into
Open
devin-ai-integration[bot] wants to merge 6 commits into
devin-ai-integration[bot] wants to merge 6 commits into
Conversation
The state executor's own records name states, regions, pseudostates and transitions by the program.StateID/RegionID/PseudoID/TransID values lowering assigns, and vertices by the new program.VertexRef, in place of AST and lower.Transition pointers: the active configuration, state stack, state attributes, history, ahead sets, routes, region and lazy entries, unit heads, firing scopes, dispatch candidates, held entries, join arrivals, breakpoints, timer and change-trigger maps, the held image and the snapshot. FiredTransition carries the transition id, source and target VertexRefs, an EntryRef for an entry transition and the Origin; StateExecutor.FiredNodes maps a firing back to its declarations for the LSP. Lowering now numbers the hidden states a parallel body's typed usages stand for, which the executor reaches through parent chains and region tables. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # internal/ir/lower/identity_test.go
firedNames spells a fired transition through FiredNodes, letting StateVertexName name a missing source as the empty string rather than branching on it. Co-Authored-By: jason.han <hanhuijun@gmail.com>
…cutor Keying the state executor's records by graph-local ids adds the id tables' accessors at every record read; the RE REPL wasm grew to 16108375 gzipped bytes and the engine to 9526983, past the 16100000 and 9500000 budgets the base holds under. The budgets move to 16200000 and 9600000. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
statesInOrder reaches hidden region owners through a worklist over parent chains and composite regions, and regionsInOrder walks it rather than States, so a hidden owner's own regions take ids too. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Nested parallel regions share a zero ID — statesInOrder now reaches hidden owners through a worklist over parent chains and composite regions, and regionsInOrder walks it instead of States, so a hidden owner's regions take ids. Lowering currently rejects a parallel typed usage inside a parallel body ("region a has no initial state"), so no fixture reaches the case; the numbering is complete regardless.
6 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Step 3 of the execution-owned IR migration (
docs/internals/execution-ir-design.md, "Migration as a stack of pull requests", row 3): the state executor's own records stop holding*ast.StateNode,*ast.StateRegion,*ast.PseudostateNodeand*lower.Transitionpointers as keys and hold the graph-local ids step 1 assigns. Stacked on #2137 (feat/ir-program-ids), which must merge first; this PR then retargets todevelop.Records keyed by id now:
stateConfiguration(simpleState StateID,regionStates map[RegionID]StateID,defaultComplete map[RegionID]bool),stateAttrs/stateAttrCells/stateAttrIndex,stateStack,history/historyRecord,joinArrived/joinChosen,breakpointNodes map[VertexRef]bool/breakpointHit/pausedAt VertexRef,timerScheduled/timeTriggerVerdict/changeFired/changeObserved/changePending/changeReads/changeRearmed/firingChangebyTransID,leftAhead/enteredAhead/entering/activeAtEntry/performing,pendingRouteEntryEffects,doAction.state,dispatchCandidate.leaf/source,route(target,choice,arrival,crossed,origin,terminate VertexRef),junctionDraw.at/origin,routeEffect.within,regionEntry,lazyEntry,unitHead.shared,firingScope,heldEntry, and the mirrors inimagedState(held image) andstateCapture(snapshot). Where a consumer still needs the declaration it goes throughProvenance(state_ids.go:stateID/stateDecl,regionID/regionDecl,pseudoID/pseudoDecl,transID/transDecl,vertexRef/vertexDecl). The graph keeps its AST fields; no layering change.Public surface:
program.VertexKind(VertexNone,VertexState,VertexPseudostate,VertexTerminate) andprogram.VertexRef{Kind, Index}withStateVertex,PseudoVertex,TerminateVertex,IsZero,State,Pseudo,Terminate. A terminate action's index is its 1-based ordinal inStateGraph.Terminates, which lowering does not number yet.runtime.FiredTransitionis now{Transition TransID; Source, Target VertexRef; Entry EntryRef; Origin program.Origin}; newruntime.EntryRef{Owner StateID; Region RegionID; Index int}names an entry transition (lowering gives those no id yet) by its body and 1-based position. New(*StateExecutor).FiredNodes(FiredTransition) (decl, source, target, owner ast.Node)is the back-map the LSP debugger uses.ActiveStates,ActiveLeaves,CurrentState,StateStack,EnclosingStates,StatePath,RegionOf,SetBreakpointAt,PausedAtkeep their AST signatures and translate at the boundary (step 7 moves those consumers).Where the design met the code:
StateGraph.States, so step 1 gave them no id, yet the executor reaches them throughParentState,RegionState,HiddenRegionOfandStateAttributes.assignStateIDsnow numbersStatesfirst and then those states (statesInOrder), solen(Origins) == len(ID)+1; the step 1 denseness test asserts againstIDrather thanStates. The step 1 API is otherwise unchanged.StateGraph.Machine) is also outside the state table; the executor gives it the id one past the last numbered state (machineID). Step 8/9 should fold it into the table.TransID/origin in step 1, soFiredTransition.Originfor one carries only the declaration's doc and span, withKind: "entry transition".No snapshot format bump: the snapshot is an in-memory capture and no serialized form changed. No conformance
.expected.json, golden trace or ratchet moved.One baseline moved: the gzipped wasm size budgets in
tests/wasm(replGzipBudget16100000 → 16200000,engineGzipBudget9500000 → 9600000). On the base both binaries fit; with the id tables' accessors at every record read the RE REPL build measures 16108375 gzipped bytes and the engine 9526983, so the budgets were raised with headroom for steps 2 and 5, which add the same kind of code.How it was verified
go build ./...,go vet ./...,gofmt -l .empty,make lintgo test ./...(withcmd/sysml,tests/codegen,tests/exportrun alone with-timeout 30m),go test -count=1 ./tests/corpus -run 'TestTrainingExamples|TestPilotCorpora'after the download scripts,go test ./tests/hygiene,go test -C tools ./...(PSSM referee record over the pinned suite)TestExecutionTraceunder every region-order policy,TestRuntimeRobustnessRegionOrder,…Terminate,…ResumableInlineDoBodyunchangedTestVertexRef*(program),TestAssignIDs_StateHiddenRegionOwnersNumbered(lower)git diff --merge-base origin/feat/ir-program-ids -- '*.go' | awk ...) prints nothingChecklist
make testandmake lintpass locallymake docs-countsrun if a gate count moved (none moved)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/a4a5e131eec042ecb18c40d69306af1a
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/a4a5e131eec042ecb18c40d69306af1a?variant=devin
Requested by: @HuiJun
🟢 Devin fixed the finding · Follow Devin's work