Skip to content

Swift keyword families: closures, decorators and thread_sleeps read their contracts (Part of #8863) - #9312

Merged
squid-shepherd[bot] merged 1 commit into
mainfrom
churn/8863-20261125T1649Z
Nov 25, 2026
Merged

squid-shepherd[bot] merged 1 commit into
mainfrom
churn/8863-20261125T1649Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #8863

Checklist: done [c:swift]

Swift's three red cells on the pinned crucible (alamofire) are fixed in swift.py. Four more Swift cells are red but hatched (no pinned crucible); they are listed below.

What each rule now counts

Cell Before (recall / precision) After Cause class Change
closures 0.61 / 1.00 (46 fns) 0.85 / 1.00 the rule misses a form also { [self] in (capture list, no params), { x -> Int in (return type), and $0-shorthand closures ($N exists only inside a closure)
decorators 1.00 / 0.60 (21 fns) 1.00 / 0.95 the rule counts another construct @escaping, @autoclosure and a @Sendable in type position (after : ( [ < = , > or @escaping) attribute a TYPE, not the declaration the contract names
thread_sleeps precision 0.00 (1 fire, 0 oracle) no instances the rule counts another construct retryResult.delay is a property, not a sleep: now sleep( / usleep( / nanosleep( calls, .asyncAfter, Timer.scheduledTimer (the oracle's list; contract names timed deferral)

No oracle or contract change. Nothing else in the swift rows fell (family_oracle.py before/after diff: only these rows moved, plus state_halt_hits over-counts -> no-instances).

Class / Sibling gaps

Class: Swift keyword-family rules that count a different construct than their contract names (decorators, thread_sleeps) or miss a closure form (closures); all three pinned red members are handled here, each with tests in tests/test_swift_family_validity.py.
Sibling gaps (none needs a burned-estate COBOL program: Swift is not a mainframe language):

  • closures: ~44 parameterless trailing closures (queue.async { ... }, { retry() }) are not counted; a regex cannot tell them from if x { } blocks. Needs a ruling or a narrow member-call anchor; not chosen here because it would move counts without a ruling.
  • Hatched, not pinned (no crucible to measure on): regex_execution, time_date_logic (0.59 recall), io (0.73 recall), bitwise_ops (0.77 precision).
  • tests/family_validity_baseline.json on main is stale for other languages (c, go, javascript, rust, typescript cells differ from a fresh sweep); only swift's cells are updated here.

Evidence

  • CPU: rule micro-benchmark on the crucible swift text (process time, best of 3): closures 0.7 -> 0.9 ms, thread_sleeps 1.9 -> 4.5 ms, decorators ~0 -> ~0.05 ms per 209 KB (the @ literal stays first so the lookbehinds run only at an @). Not a three-run scan A/B.
  • keyword-rosetta: not run (KEYWORD_ROSETTA_PATH is not set in this worktree and no checkout was provided). Owed: verify_language.py swift on the branch; the new rules can move rosetta cells.
  • Goldens: blessed with golden-lock.sh crucible_check.py --update --yes (both legs; a second run reports no drift). scope_check.py --expect swift --mode full: 157 differences vs main, 130 swift, 27 repo-wide archetype-distribution rollups (Callbacks & Closures 1259 -> 1268 etc.), no other language.
  • pr_gates --fast: lint failed only on ruff format of my two files, fixed with the pinned ruff 0.17.5; the other 8 gates pass. pr_gates --ratchets: 9 pass, 0 fail.
  • Tests: tests/test_swift_family_validity.py, test_swift_strict.py, test_swift.py, family sweep/chart/red-cells tests pass.
  • Regenerated (not hand-written): goldens, family_validity_baseline.json (swift cells), the two docs/self_scan/family_validity_*.svg.

Lessons for agents

  • family_oracle_sweep.py --write rewrites every language's baseline cells; when main's baseline is stale, splice only your language back and write with json.dumps(indent=1, sort_keys=True) or test_committed_svgs_are_current fails on formatting.
  • A rule starting with a lookbehind runs it at every character; put the literal (@) first and the lookbehind after it.

🤖 Generated with Claude Code

…heir contracts (Part of #8863)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 25, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review November 25, 2026 17:24
@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 25, 2026 17:25
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-shepherd
squid-shepherd Bot merged commit f5b77c8 into main Nov 25, 2026
122 checks passed
@squid-shepherd
squid-shepherd Bot deleted the churn/8863-20261125T1649Z branch November 25, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant