Repository navigation
compass(detect): the set-iteration lint over atom/compass, carried from #96 - #512
Conversation
…ncio.sleep Carries ClockSourceLint from the closed #96 head (ee5b591) with its anchored read comparison, and its tests from #91 and #96, into atom/compass/detect/clock_source.py and tests/compass/test_clock_source_lint.py. Changes from the carried module: - asyncio.sleep leaves CLOCK_READS: an asyncio timer runs on the event loop's clock, which a simulated run replaces. - The watchdog allow-list entry goes with the watchdog; the list is empty. - The unused enabled flag and scan_tree are dropped. The lint is clean over atom/compass at the tip. Closes #101. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A static pass that reports every read of a set in hash order under atom/compass: file, line, form and enclosing symbol, parsed with ast. Membership is not reported. Carried from ee5b591, stacked on the clock-source lint (#511) whose module walk and scope lookup it reuses, with two settlements of the sites it reports at the tip: - a comprehension handed straight to sorted() is not a read; it is the same remedy as sorted(s) with a filter (graph_pool.capture_token_shapes); - SimulatedKVConnector._matured collects the finished requests in a list in the dict's own order, so no set is iterated. The tests move to tests/compass/test_set_iteration_lint.py; the clock-source cases they shared are in #511. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…old recursion, alias chains and innermost scope check() refuses a root holding no module, so a mistyped path no longer reports clean over zero modules. The seeded read sits one directory down, so the walk's recursion is held; the clean-line test checks a single file, so the file-root branch that #512 relies on is held too. CLOCK_READS_THAT_FIRE pairs each spelling with its exact report line, which folds in the three exact-report tests and the datetime test and adds alias-of-alias and innermost-scope cases. _scopes and _scope_at become scopes and scope_at for the set-iteration lint. Dropped: the believable-number test (it ran no repository code), the CLOCKS_HANDED_AROUND table (it asserted blind spots), main and argparse (no caller), scan_modules (one caller, inlined). The alias-expansion record is a set. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| yield from _scoped(child, inner) | ||
|
|
||
|
|
||
| def _sorted_away(tree) -> set: |
There was a problem hiding this comment.
REQUEST CHANGES, required 1. A call in the element or filter still runs in the set's order and is not reported: sorted(ids.take(x) for x in s) gives (), the same body as a for loop is reported. Delete _sorted_away and write capture_token_shapes as tuple(s for s in sorted(shapes) if s <= max_num_batched_tokens); atom/compass is then clean. Or exempt only an element and filters with no Call, NamedExpr, Await or Yield, with a fire form.
| SIMULATED_PATH = os.path.dirname(atom.compass.__file__) | ||
|
|
||
| #: A step loop that reads its participants out of a set every way the pass | ||
| #: claims to see, and seven more it does not. Everything here runs; nothing |
There was a problem hiding this comment.
REQUEST CHANGES, required 2. seven more counts BEYOND_THE_PARSER and goes stale when an entry moves, as do Two false positives (module docstring) and Half of these (above FORMS_THAT_STAY_QUIET). Drop the numbers.
| code, report = lint.check(SIMULATED_PATH) | ||
| assert code == 0 | ||
| assert report == ( | ||
| f"set-iteration lint: clean over {len(lint.modules(SIMULATED_PATH))} " |
There was a problem hiding this comment.
No blocking issues; ponytail. The second lint.modules(SIMULATED_PATH) walks the tree again. Use len(scanned).
|
Review, round 1. Verdict: CHANGES NEEDED. REQUEST CHANGES: 2 blocking, head Required:
Checked: carried code matches Accepted with reservation: the Watch next:
EvidenceProbes at the head (
Over Revert-red on
Ponytail review: the exemption and its four test forms can go (above); Generated with Claude Code |
Base update. #511 publishes `scopes` and `scope_at` (formerly `_scopes` and `_scope_at`, same signatures) and deletes `ClockSourceLint.scan_modules` and `main`. `set_iteration.py` now imports the public names, and the local that held the spans is renamed `enclosing` so it does not shadow `scopes`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t first in capture_token_shapes A comprehension's element and filter run in the set's order before `sorted` sees them, so `sorted(ids.take(x) for x in s)` is an order dependence the exemption hid. The exemption and its test forms are gone; the fire list carries that case instead. `capture_token_shapes` sorts the set before filtering, which returns the same tuple and reads no set in hash order. The test file's prose no longer states item counts, and the clean-today assertion reuses the scanned module list instead of walking the tree twice. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Round 2 pushed 0554449. Both required findings fixed; the ponytail comment taken.
branch @ Findings, fixes and redsEach defect reinstated on the head tree, over
ruff 0.16.7 check rc 0, format and black clean on the three changed files. Generated with Claude Code |
| "augmented": "def f(n, t):\n s = set(n)\n s |= t\n for x in s:\n yield x\n", | ||
| "typing-Set": "from typing import Set\n\n\ndef f(r: Set[str]):\n return [x for x in r]\n", | ||
| "string-annotation": 'def f(r: "set[str]"):\n return [x for x in r]\n', | ||
| "sorted-generator": "def f(s: set[str], ids):\n return sorted(ids.take(x) for x in s)\n", |
There was a problem hiding this comment.
No blocking issue. A list comprehension handed to sorted has no fire form, so only the generator case is held. Put the exemption back for ast.ListComp alone and tests/compass still passes: 1371 passed, 6 skipped. Add one beside this form, e.g. sorted([ids.take(x) for x in s]).
|
Review, round 2. Verdict: APPROVE. APPROVE at head Both round-1 findings are closed:
Checked: the merge Accepted with reservation: a list comprehension handed to Watch next: #511 has not landed. The stacked form below takes #511 onto the current tip first. The literal
EvidenceThe stacked tree is the head tree plus #478's three files ( Reinstated on the head tree and run over
Ponytail review of the delta: Lean already. Ship. Generated with Claude Code |
…ass/issue-487-set-iteration-lint Base update only. One add/add conflict in tests/compass/test_clock_source_lint.py, resolved by taking the integration tip's version unchanged (the final version of #511; this branch carried an earlier round of it and never changed the file itself). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Base update pushed 1be46ea. No blocking issues. Merged
|
|
Review, round 3. Verdict: APPROVE. APPROVE at head Checked: the only remerge hunk is the add/add in Generated with Claude Code |
Closes #487. Ready for review. No blocking issues.
Adds
atom/compass/detect/set_iteration.py, carried from #96 atee5b591dc, and gatesatom/compasswith it intests/compass/test_set_iteration_lint.py. Stacked on #511, whoseClockSourceLint.modules,scopesandscope_atit imports.Dev record
0e16d3a98the carried lint reports the same two sites compass: a determinism harness two processes wide, and the set-iteration lint #96's base update found:SimulatedKVConnector._maturedinatom/compass/kv/connector.pyandcapture_token_shapesinatom/compass/memory/graph_pool.py._maturedcollects finished ids in a list, in the dict's order.capture_token_shapessorts the set before filtering it, which returns the same tuple.graph_pool.pyis outside the issue's file set; the review asked for this change there. A comprehension handed tosortedis reported, because its element and filter run in the set's order.atom/utils/clock.pyis not a scan root because compass(clock): the LP runtime — TAR, NER, send registration and TSO release inside an ATOM process #455 has not landed; whichever of the two lands second adds it. Both static passes name their own blind spots and both lists are short #110 still holds the recognisers compass: a determinism harness two processes wide, and the set-iteration lint #96's reviews routed there.Scheduler._update_from_kv_xfer_finishedfrees blocks in the order of the sets the connector returns. It is outside the scan root, so this PR does not change it.Named result
atom/compassgoes from 2 reported sites at0e16d3a98to 0 at the head, both settled in code.Gates
0554449a3: 5327 passed, 155 skipped, 3 xfailed, 0 failed,GATE_CPU_RC=0. ruff check and format clean on the three changed files, rc 0.8056b1933: 5238 passed, 155 skipped, 3 xfailed, rc 0. The +89 are this PR's tests.Evidence
Revert-red: one line-preserving edit of the head tree each, run over
tests/compass/test_set_iteration_lint.py(89 pass unedited).capture_token_shapesback totuple(sorted(s for s in shapes if ...))test_the_simulated_path_is_clean_today:assert 1 == 0_sorted_awayand its call reinstatedtest_every_form_it_claims_to_report_is_reported[sorted-generator]:assert () != ()connector.pyback to0e16d3a98test_the_simulated_path_is_clean_today:assert 1 == 0ClockSourceLint.moduleswalks the top directory onlytest_the_simulated_path_is_clean_today:kv/connector.pynot among the scanned modulesThe last two rows are from
eb29a5a92; neither line changed since. Reinstating the exemption is not line-preserving; no test in the file reads line numbers ofset_iteration.py.capture_token_shapesold and new forms return equal tuples on 2004 inputs: four fixed ladders and 2000 random ones, with empty ladders and a zero budget among them.Changes to the carried code, relative to
ee5b591dc:set_iteration.py: +9 / -6 lines. The publicscopesandscope_atimports, one docstring sentence saying a comprehension undersortedis reported, and a_bindsdocstring that states no count.reading_setsfixture andTestTheSetIterationLint, with a new module docstring and the walk assertion. It adds thesorted-generatorfire form and leaves out the clock-source cases, which are in compass(detect): the clock-source lint over atom/compass, without asyncio.sleep #511.connector.py: 3 lines changed.graph_pool.py: 1 line changed.Cost, as docstring-inclusive AST statements / non-blank physical lines at
0554449a3:set_iteration.py: 278 / 486 (carried 278 / 483).Generated with Claude Code