P5b: analysis package — AnalysisContext, session split, analysis/loops, typed lower-bound IR
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #546 by @LKlinke — closed without merging
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the design note required by the issue, then read docs/source/architecture.md sections “Current state and target” and “Order of the milestone,” and check which items are already on main. The work spans prodigy/analysis/, including session.py, while_handler.py, lowerbounds/ir.py, and prodigy/util/logger.py; begin by mapping the target module tree and PR order. Done means the specified package changes and #508 fix are complete, targeted tests, make fuzz, and examples remain unchanged, and the listed pylint checks pass.
Written by the indexing model from the issue text.
Description
Work package P5b of #221 (index): the analysis package after the layer cuts of P5a (#497). Several PRs.
Scope
- T11: instruction handlers get an explicit
AnalysisContextinstead of the 6-argument positional signature andcurrent_context(); dispatch by a table. - T12, second part: split
analysis/session.py(decision providers, records, session) below 800 lines; alsonested_inference.py,result.py,trace.py,while_handler.pybelow 800 lines (review A1, A5 layout only — JSON types are P9). - T13:
analysis/loops/holds the loop proof rules (while_handlerstrategies,evtinvariants/,lowerbounds/), one module per strategy group, the registry in one place; strategies declare their goals; the invariant check no longer reaches into the compare mode (review A3). - T14, first part: the lower-bound calculus works on a typed AST with a fragment check instead of the tuple IR (
lowerbounds/ir.py); affine guard forms throughdistribution/linear_guards.py(review §2.6). Steps 2–3 belong to #417. - Review A4 (
plan_parameters,certificate_checks,egcalc.assign: split by case), A9 (silentexcept: pass→ debug log), A11 (templates as expressions, not strings), §2.4 forevtinvariants(shared three-valuedall). - #508: the unrolling "terminated already" test never fires for programs with variables — fix it with the
loops/move (behaviour change only there; soundness argument in the PR). - B5: check the lower-bound
zip()sites by hand (alreadystrict=True?) and confirm no constraint can be dropped. - Logging leftover of #284 (exists on
main): every logger is created with levelDEBUG(prodigy/util/logger.py, 29log_setup(…, logging.DEBUG)calls), so each debug call builds aLogRecordeven without a log file; and 7 calls format eagerly withstr(…)(e.g.analyzer.py:83prints the whole program on everycompute_semantics). Change: levelWARNINGunlessPRODIGY_LOG_FILEis set (thenDEBUG), lazy arguments at the 7 sites, a test that no debug record is created without the variable. With PR 2 (it rewritesanalyzer.py). - Left by #525 (exist on
main):too-many-localsin 11 functions ofsession,trace,nested_inference(session constructor,Tracer.snapshot/finish/_record_iterate,infer,call_in_joint,run_loop, …);AnalysisSession.__init__with 18 keyword arguments (a parameter object changes the front-end API: decide with PR 8);Tracer.pseudo_step/loop_iterate/_record_iteratewith 6–7 positional arguments. - From #537 (exists on
main), for PR 8:compute_semanticsraises "No analysis is running" unlessprodigy.analysis.sessionwas imported, because the session module registers the detached context at import. With the removal ofactivate/use_context, make the detached context independent of that import. - From #522/#539 (exist on
main), for PR 8:equivalence/equivalence_check.py:20still defines its own copy of the 5-argumentAnalyzeralias (the second-order check moves in PR 8; useFrameor the one alias incontext.py);AnalysisContext.loop_iterate,AnalysisSession.loop_iterateandTracer.loop_iteratetaketerminated: Any, inside: Anyand 6 positional arguments — type them (no reflexiveAny) and decide keyword-only together withLoopTask.iterate. - From #522 (deviation), for PR 8:
Frame.configis a field next to the context's configuration, because the CLI'sevt_*commands run a detached session with their own configuration. Whenactivategoes and the CLI passes its session explicitly, give that session the command's configuration and deriveFrame.configfrom the context, so there is one source of the configuration.
pylint checks this package makes clean
too-many-arguments/-positional-arguments in analysis (handlers, loops), too-many-branches/-statements in lowerbounds and evtinvariants, too-many-lines of while_handler, session, nested_inference, result, trace, duplicate-code (three-valued all), too-many-locals in analysis.
Approach
A design note first (one page, posted here): the AnalysisContext fields and lifetime, the target module tree of analysis/ and analysis/loops/, the typed IR of T14, and the PR order. Coding starts after the note is checked. No shared files with P4 (distribution), P6 (language), P7 (web, cli).
Done when
- T11–T13 and the first part of T14 are reached as described in
architecture.md; #508 is closed. - No module of
analysishas more than 800 lines; no handler takes the session globally. - Targeted tests,
make fuzzand the examples are unchanged; the checks above are clean forprodigy/analysis.
Rules for this package
- Work package of the v0.7.0 milestone; target and order in
docs/source/architecture.md("Current state and target", "Order of the milestone"). Review items refer to the written review in #221 (first comment); §13 is the pool of PRs. - Behaviour-preserving: no change of results, messages only where an item says so. Soundness unchanged; the examples give the same results on all engines.
- Items may already be done by P1–P3/P5a: check each against
mainand say in the PR which were already done. - The package's pylint checks are clean at the end, measured with
pylint --disable=all --enable=<check> prodigy/<package>; any local exception is justified in a comment. - New findings for this package go into this issue's body, not into #221.
- Dominant language
- Python
- Stars
- 6
- Forks
- 2
- Avg merge
- 1h 52m
- Merged PRs (30d)
- 187
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LKlinke/Prodigy
-
area: engines bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: gui bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: gui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
area: engines bug priority: medium
Maintainers usually reply within 1 day
-
area: maintenance priority: low
Maintainers usually reply within 1 day
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day