Skip to content

feat(smt,solve): read the lowered graphs by id and expression record - #2257

Merged
HuiJun merged 14 commits into
developfrom
feat/ir-smt-solve-off-tree
Nov 17, 2026
Merged

HuiJun merged 14 commits into
developfrom
feat/ir-smt-solve-off-tree

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Step 7b of the execution-owned IR (docs/internals/execution-ir-design.md, "Migration as a stack of pull requests"): the satisfiability engine (internal/exec/smt) and the solving engine (internal/exec/solve) stop reading the syntax tree out of the lowered graphs. Neither package imports internal/syntax/ast any more, and tests/hygiene forbids both edges.

#2249, #2252 and #2253 have merged; the base is develop.

  • exec/smt. A node is smt.Node{Graph, ID} (node.go): the lowered graph and its program.NodeID. Flow's tables (Index, FrameOf, Incoming, Outgoing, Repeats, Crosses) are keyed by it, Flow.Ends names each edge's ends, and support.go, encode.go, state.go, witness.go, input.go and property.go walk the graphs through the id-indexed accessors of feat(lower): name the nodes and vertices of the lowered graphs by id #2253.
  • exec/solve. translate.go, expression.go, reference.go, quantify.go, pin.go, variant_value.go, replay.go, query.go, objective.go and nested.go translate a *lower.ExprEntry by program.ExprKind and program.Operator; Var.Ref is an entry, and conditions, objectives and defaults are read by their ExprID.
  • ir/lower, shared with the later sub-steps. graph_questions.go answers what a consumer asked the tree about a node or record, by id (FormOf, FormName, Invokes, CaseNode, ExpressionOf, TraceLabel, ScopeOf, and methods on Loop, Assign, Send, Accept, ObjectFlow, ActionEdge). expr_questions.go gains Written, Reference, Segments, Invoked, Reads and Declared.
  • ir/program. An ExprBody record carries Params, Result and Locals, and lower.ExprEntry.Answer is the entry behind Result; quantifier translation reads these. The fields are additive and the runtime does not read them. An ExprInvoke written with a qualified name records its segments in Path, as an ExprRef does, so a quoted name holding :: stays one name; TestQuantifierNamedInSegmentsIsTheLibraryQuantifier pins it.
  • exec/runtime. expr_entry.go evaluates and labels by entry and by node id (ExprEntry, EvalEntry, EvalEntryOn, ReadEntryInSatisfaction, EntryText, TokenLabelOf, BranchLabelOf, DecisionPlaceOf).
  • semantic. Resolver.ResolveSegments, semantics.DeclaresSubject/DeclaresFeature and ResultExpressionConflict.Written, so the two engines ask by name and span.

What still reads the tree, inside lower. The questions in graph_questions.go and Reads/Reference/Written are answered from the tree the graphs still hold: a walk over program.Expr alone would miss the local members of a body expression, which the record only counts. Step 8 deletes the tree side and rewrites these over the records; the consumers do not change again. The design document records this.

Error behaviour. One satisfiability refusal changes, by design; no other solver or satisfiability error moves. Two steps typed by one definition, each stating a flow of its own (action one : Leg { … }, action two : Leg { … } inside one action), lower to two subflow graphs over the same declarations.

  • Before: smt: malformed action flow: node a: the initial node is not among the flow's nodes (*smt.FlowError).
  • Now: smt: not encoded: node one: nested flow: a node stating a flow of its own is encoded by a later stage (*smt.UnsupportedError), the refusal every other nested flow gets.
  • Why: Flow keyed nodes by tree pointer and skipped one it had already numbered, so the second step's frame was left without the definition's nodes. That was an artifact of the key, not a property of the model. A node is now keyed by graph and id only, each frame numbers its own nodes, and the model reaches the nested-flow refusal. TestAnalyzeRefusesTwoFlowsOfOneDefinition pins it and a changelog fragment records the text change.
  • The initial node is not among the flow's nodes check is removed: a graph gives ids only to its own nodes, so a flow's initial node is always numbered in its own frame, and a flow with no initial node is still reported as the flow has no initial node.

make().flag (a feature of an invocation's result) is refused as before the migration: Segments answers references and feature chains only, and the quantifier translation asks the invoked name through Invoked; a TestRefusals case and TestExprEntryInvoked pin it.

Left for step 8. Refusal texts that name a node or expression kind still print the tree's Go type names (%T, expression *ast.X), answered by lower so they stay byte-identical; they move to IR kind names when the tree side is deleted.

How it was verified

  • New tests: expr_questions_test.go and graph_questions_test.go in internal/ir/lower, TestAnalyzeRefusesTwoFlowsOfOneDefinition in internal/exec/smt, TestExprEntryInvoked, the quantifier-alias test and the make().flag refusal case in internal/exec/solve, TestResolveSegments, TestDeclaresSubjectAndFeature and the span assertions of the result-expression tests.
  • go build ./..., go vet ./..., gofmt -l . (empty), make lint, go test ./... with the training, pilot and specification-example corpora required (140 packages), go test ./tests/hygiene, go test -C tools ./..., make docs-counts, make spec-compliance-check, make changelog-check, make wasm-check.
  • Pilot execution differential: 514 cases, agree 229 · kind-only 1 · order-only 0 · disagree 38 · differs-by-design 5 · pilot-unevaluated 167 · pilot-silent 24 · pilot-error 7 · ours-error 10 · ours-undetermined 17 · both-error 16 · nondeterministic 0, equal to the committed record. pilot-xpect -check passes (432 files, 1299 agree, 30 disagree).
  • benchstat, n=10, alternating prebuilt binaries, against the base:
benchmark base head
REPLEvalExpr 6.799 ms ± 11% 6.911 ms ± 7% ~ (p=0.529)
GRPCEvaluate 14.55 µs ± 8% 14.54 µs ± 11% ~ (p=0.853)
ConnectEvaluateHTTP 121.6 µs ± 10% 122.6 µs ± 19% ~ (p=0.247)

Allocations per operation: 123 → 124, 144 → 145, 224 → 224. The benchmarks evaluate Perf::Calc1(2.0, 3.0), a qualified invocation, and the one allocation is its segments. Bytes per operation: GRPCEvaluate +2.28% (11.65 Ki → 11.91 Ki, p=0.000), the others unchanged.

What moved. No ratchet: replGzipBudget in tests/wasm/browser_repl_test.go is the 16,400,000 bytes develop sets, and tests/wasm is identical to develop; the browser REPL build measures 16,312,572 gzipped at this head (core 7,482,077, engine 11,096,626, syntax 1,665,013). No conformance expectation, golden trace, view golden, corpus baseline, wire format or snapshot format moves.

Known on develop. go run -C tools ./cmd/pilot-diff -check fails identically on develop 0abb3aa; re-recorded by #2323. This branch does not touch docs/project/pilot-differential-baseline.json.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md — for the changed refusal text
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/f0e5153d16b3428e96fddec893eb225e
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/f0e5153d16b3428e96fddec893eb225e?variant=devin
Requested by: @HuiJun


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

The satisfiability and solving engines name action nodes by graph and node id,
translate expressions from the expression tables, and no longer import the
syntax tree; tests/hygiene forbids both edges. The lowering answers the
remaining questions about a node or expression by id, and a body expression's
record now carries its parameters, result and local count.

The browser REPL gzip budget moves from 16,250,000 to 16,300,000 bytes
(16,240,594 before, 16,257,913 after).

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 2 commits November 15, 2026 03:47
A quoted alias holding `::` is one name; splitting the recorded text on `::` made
it several and refused the quantifier. The invocation's record now carries the
segments of a qualified name, and the translation reads them.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Empty quoted names rejected by solving — Confirmed with a failing test: Segments and Invoked answered false for a name written ''. spelling now treats only a reference with no written span as naming nothing. The fix commit is local and will be pushed with the develop merge once released.

View findings in Devin Review · Follow Devin's work

Devin Review

devin-ai-integration Bot and others added 3 commits November 15, 2026 04:59
Segments answered an invocation's name, so the chain `make().flag` read as the
declaration path make.flag and the solver grounded it instead of refusing. The
name is now answered by Invoked, which only the quantifier translation asks.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The encoder numbered a node once per declaration, so the second of two steps typed
by one action definition had no nodes of its own and its flow was reported as
malformed. A node is its graph and id, and the first such step is refused as a
nested flow like any other.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
… nodes

A node is numbered by its graph and id, and a graph gives an id only to its own
nodes, so a flow with an initial id always numbers that node in its own frame.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…smt-solve-off-tree

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	tests/wasm/browser_repl_test.go
Base automatically changed from feat/ir-graph-ids to develop November 16, 2026 00:01
devin-ai-integration Bot and others added 4 commits November 16, 2026 00:03
A reference or an invocation written with the empty unrestricted name has
one segment, the empty string; ExprEntry.Segments and Invoked answered that
it named nothing, so the solver refused an expression it used to resolve.
Only a reference with no written span names nothing.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…smt-solve-off-tree

Co-Authored-By: jason.han <hanhuijun@gmail.com>
ExprEntry.Reads promised to stop where visit answers false, but only kept
from descending the node it had just visited: a sibling reference, or one
under a bracket index, was still visited. Stop the whole walk.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	tests/wasm/browser_repl_test.go
@HuiJun
HuiJun added this pull request to the merge queue Nov 16, 2026
devin-ai-integration Bot and others added 2 commits November 16, 2026 23:13
The bound-subrequirement refusal develop added names its expression by
id, as every other refusal on this branch does.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration
devin-ai-integration Bot removed this pull request from the merge queue due to a manual request Nov 17, 2026
@HuiJun
HuiJun added this pull request to the merge queue Nov 17, 2026
Merged via the queue into develop with commit 77a8820 Nov 17, 2026
32 checks passed
@HuiJun
HuiJun deleted the feat/ir-smt-solve-off-tree branch November 17, 2026 11:19
devin-ai-integration Bot added a commit that referenced this pull request Nov 17, 2026
…f-base

develop is over the browser REPL gzip budget since #2257 landed, so this
PR's own WebAssembly gate cannot pass without the raise it is queued behind.
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