Repository navigation
Adds Predicator.Analysis: references, calls, assignments - #249
Merged
Merged
Conversation
references/1, calls/1 and assignments/1 list every variable a program reads, every function it calls and every location it stores to, in source order, as maps with a path (strings, integer indexes, :dynamic for a computed key) or a name and arity, and a position. Each accepts a source string (read as a program), an AST, a program, an instruction list or a compiled envelope. The instruction form rebuilds paths through a symbolic stack and agrees with the AST form on a table of sources; a bare list carries no positions. Assignments walk the location chain directly. A binding test reads the clause heads against the parser's node kinds and every opcode, retired ones included, and joins the sabotage test roots. ADR-0020 records the decision at proposed. No ISA change, no corpus change. Refs: px-533c
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
johnnyt
added a commit
that referenced
this pull request
Oct 13, 2026
ADR-0020's Status line now reads accepted, naming predicator 9.5.0, the version that carries its code: the analysis and the record landed in #249, the corpus surface in #250, the release prep #252 merged at fd7fb01, and the tag v9.5.0 on that commit published through run 38413868048 on its first attempt. The index row in docs/adr/README.md reads accepted. A dated foot Note records the evidence and the SHA of origin/main at which every claim the record makes was re-verified today; the one sentence the earlier 2026-10-13 Note already covers is named there, and no other sentence is superseded. The flip was decided by the conductor under a standing consent, 2026-10-13. Only docs/adr/ changes: the Status line and the index row are the only removed lines. No Elixir touched, no gate run. Refs: px-bv26
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
Adds
Predicator.Analysis, a reading surface in thePredicator.Vocabularymould:references/1- every variable read, as%{path: [segment], position: pos | nil}.calls/1- every function call, as%{name: name, arity: n, position: pos | nil}, nested calls included, the outer call first; a qualified name (ns.fn) keeps its dots.assignments/1- every store target of a program, as%{path: [segment], position: pos | nil}.A segment is a string, an integer (a literal integer index) or
:dynamic(any other bracket key); the path continues past:dynamic, and a computed key's own reads are references of their own. Every occurrence is listed, in source order; a caller dedupes. The answer shape was ruled by the operator, 2026-10-12. Assignments walk the location chain (identifier, property access, bracket access) directly and never callPredicator.ContextLocation, ruled by the operator, 2026-10-13.Each function accepts a source string, an AST (or a statement or block), a program, an instruction list or a
Predicator.Compiledenvelope, and answers{:ok, list}.The instruction form rebuilds paths through a symbolic stack:
loadthenaccess/bracket_accessruns, alitbefore abracket_accessfolding to a string or integer segment and anything else:dynamic, calls fromcall, store targets fromstore, positions from the envelope's table when it has one, elsenil. That reconstruction and the opcode coverage below were decided by the conductor under a standing consent, 2026-10-12 (the coverage of the retired opcodes, 2026-10-13).ADR-0020 records the decision at proposed, with the index row, and
docs/architecture.mdgains a component-map entry. Changelog fragmentchangelog.d/px-533c.md(Added).No ISA change, no opcode, no corpus change, and no existing function changes what it answers.
Tests
test/predicator/analysis_test.exs- unit cases per function and per input form, the module's doctests, and the refusals.test/predicator/analysis_forms_test.exs- the AST and instruction forms agree on a table of expression and program sources: paths, calls and stores in every form, positions wherever the instruction form has a table (point and span). Two companion tests prove the table reaches every node kind the parser builds and every opcode the compiler emits. The one disagreement the test allows is positions from a bare instruction list, which carries none.test/predicator/analysis_clause_coverage_test.exs- binding: the AST clause heads against the constructors ofParser.visitable/0, and the instruction clause heads against every key ofPredicator.Instructions.opcodes/0, retiredand/orincluded, both ways. Added togate.sabotage.test_rootsin.claude/wurk.json.Sabotage, each run against the branch and restored byte-equal before the next:
ast/0in parser.ex:durationclause tag renamed in analysis.exopcodes/0["or"]clause renamed in analysis.exFull
mix qualitygreen on the committed tree: Format, Compile, Credo, Tests, Dialyzer, Docs, Doc links and Dependencies pass; Doctor is not installed (a standing project gap), Gettext and Sobelow are declared not applicable.Provenance
Engineering choices made in this branch, each recorded in ADR-0020:
Predicator.parse_program/2reads it. Every expression is a one-statement program and=is never equality (ADR-0002), so a condition reads the same either way and a script written as a string is analysed too. A test checks that every source in the agreement table answers the same as a string, as a program and as an expression AST.a[true],a[1.5]) is:dynamic, so it fits the ruled segment shape.ParseErrorcompile_program/1returns, and anEvaluationErrorwith the evaluator's"unknown_instruction"reason for an unknown opcode or a malformed operand. A list that underflows is read as far as it goes. No new reason term.proposed, asdocs/adr/README.md's Status paragraph has it: "An ADR isproposedwhile it is drafted andacceptedonce the maintainer confirms it records the decision as actually made. An agent may draft; only the maintainer accepts". This repo's work extension asks foracceptedor nothing; the README's lifecycle is the one this record follows, and its own Consequences say the flip is a separate reviewed change.## Notessection yet: the record carries no note to put there.Tier: contract (a new public module). Cold review to follow; this PR stops at open.
Refs: px-533c