Repository navigation
refactor(config): bind the superseded-default _ABSENT sentinel once - #17092
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (1 items) — 1 justifiedIntent: keep one sentinel object for "value is absent" in
[FIRST-PRINCIPLES-REVIEWED] b94e48e Description read[DESCRIPTION-READ] 101e59f301d341a4dd5b5826e452a27a11762a3b770c2cc2eed0daab70d3d9eb That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] b94e48e Description read[DESCRIPTION-READ] 707aa41cc161780aa2ed7d83582b7bc6afbda9d5d1bf3f4eca41f9d65a7aecee That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
be4a3b5 to
04e5001
Compare
|
Rebased: main moved in files this PR's module imports or sits beside ( |
|
CI attribution for head
I didn't re-run the jobs. A rerun reuses this run's merge SHA, so Coverage Gate would fail again until #17114 lands. Once #17114 and #17145 merge, I'll re-sync the branch. |
04e5001 to
b05f0cd
Compare
|
Rebased: main moved past this head's base (0ec74ff -> 557c8f8) and now carries the fixes for both reds attributed above: #17114 drops the graduated |
|
CI attribution for head
I didn't re-run anything. The failure is deterministic until #17285 is fixed on |
b05f0cd to
874c06c
Compare
|
Rebased onto latest
|
|
CI attribution for head
I rebased locally onto I am holding the push. CI tests the merge ref, so pushing now would red shard 3 on that |
superseded_defaults.py assigned `_ABSENT = object()` twice at module scope: once above _overlay_stt_provider and again above _stored_value. The second assignment replaced the first at import, so the binding a reader finds first is not the object any function compares against. Every reader resolves `_ABSENT` as a module global at call time and nothing outside the module imports it, so every function already used the later object. Dropping the later binding leaves them all on the surviving one, which sits above every reader; behaviour is unchanged.
874c06c to
b94e48e
Compare
|
Rebased onto
CI re-running. |
|
Green-age check for head I did not push a fifth re-sync. Instead I verified the rebased tree in a scratch worktree, cherry-picking this commit onto
The required checks are non-strict and CI tests the merge ref, so this head is review-ready as it stands. It is waiting on a human approval. |
iamwhatever
left a comment
There was a problem hiding this comment.
Approving (crew-pr-reviewer). This deletes the second _ABSENT = object() at line ~938, leaving the one at line 178. Every function in the module reads the module global at call time, so they all compare against the same object either way. Removing the rebind means a reader that imported _ABSENT before line 938 ran now holds the right object too. No behaviour change. CI is green, base is main.
Problem / Motivation
Goal: Make
config/superseded_defaults.pybind its_ABSENTsentinel once, so the object a reader finds is the one every function compares against.superseded_defaults.pyran_ABSENT = object()twice at module scope: once above_overlay_stt_providerand again, about 750 lines later, above_stored_value. The second line replaces the first when the module loads. A reader who finds the first binding is looking at an object that no function ever compares against.Why it matters
Nothing is broken today: every reader looks the global up when it runs, so all of them already use the later object. The trap is for the next edit. Code that captures
_ABSENTwhile the module loads — a default argument such asdef f(x=_ABSENT)placed between the two bindings — would hold the first object, while everyis _ABSENTcheck inside a function reads the second. A missing value would then read as present, and no test exercises that ordering.Not a goal
config/loader.py's_JSON_TYPE_LABELS, which reads as unused but is pinned by the facade-surface list intest/test_config_refactor_contract.py.knowledge/folder_watcher.py's_update_last_seen,telegram/client.py's_FILE_HOST, and others). One module per PR.What changed (motivation → approach → change)
The
configmodule's mechanical detector classes are at 0 actionable sites, so this is a judgment-class pass. An AST scan for module-scope names bound more than once found exactly one site in the tree: this one.The change deletes the second
_ABSENT = object()(above_stored_value). The first binding sits above all seven reads. Every read is inside a function body (_overlay_stt_provider,_stt_resolves_auto_locally,record_acks' inner_under_config_lock,_stored_value,stored_value_or_none), so each one resolves the module global when it runs. No code outside the module refers to this sentinel: the_ABSENTnames in other files are their own sentinels.History: the lower binding came first (#8405); the upper one was added with
_overlay_stt_provider(#16190). The PR keeps the upper one because it sits above every reader, and deletes the older lower one.Backwards compatibility
Compatible: the module still binds
_ABSENTonce, above all its readers, and nothing outside the module reads it.Removes nothing: only the duplicate assignment goes; the sentinel, every function and every public name stay.
Tests
No new tests: the diff removes a binding no reader observes on its own. Existing coverage runs both reader paths.
test_an_overlay_that_names_no_provider_leaves_the_base_provider_standingtakes the_overlay_stt_provider→is _ABSENTpath, andtest_record_acks_stores_what_is_storedtakes the_stored_value→is not _ABSENTpath.Local gates (Python 3.12): flake8, isort, mypy,
check_black_formatting.py,check_subprocess_encoding.py,check_brand_name.py,check_harness_parity.py,docs_lint.py --test,docs-lint.sh,check_per_file_coverage.py --testandverify_vendor_manifest.pyall exit 0. The seven test files that importsuperseded_defaultspass: 652 tests.scripts/scrub-lint.shis not in the checkout; that scan runs as CI'sinternal-content-scanjob. Backend-only diff, so CI reportsonly_backend=trueand the frontend suites cannot newly fail.Pre-PR review: six read-only lenses (AUTOSDE rules plus the Opus contract, the GPT contract, behaviour preservation, name and import semantics, security keystone and boot path, comment accuracy) found no defects. The behaviour lens confirmed the post-diff AST equals the pre-diff AST minus that one assignment. The comment lens's two wording hedges are applied here; no finding was dropped.
Manual verification
N/A — unit coverage sufficient: the change is one module-scope assignment. An import check shows one
_ABSENTbinding left and_stored_value({}, "a.b") is _ABSENT.Screenshots / video
Why no screenshot: backend-only refactor of one Python module; nothing renders differently.
Related Issues
Part of #16523
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)