Skip to content

refactor(config): bind the superseded-default _ABSENT sentinel once - #17092

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/simplify-config
Oct 6, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/simplify-config

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make config/superseded_defaults.py bind its _ABSENT sentinel once, so the object a reader finds is the one every function compares against.

superseded_defaults.py ran _ABSENT = object() twice at module scope: once above _overlay_stt_provider and 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 _ABSENT while the module loads — a default argument such as def f(x=_ABSENT) placed between the two bindings — would hold the first object, while every is _ABSENT check inside a function reads the second. A missing value would then read as present, and no test exercises that ordering.

Not a goal

  • Changing any behaviour. No reader, comparison, ack path or overlay read changes.
  • config/loader.py's _JSON_TYPE_LABELS, which reads as unused but is pinned by the facade-surface list in test/test_config_refactor_contract.py.
  • Unused names found in other modules (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 config module'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 _ABSENT names 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 _ABSENT once, 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_standing takes the _overlay_stt_provider → is _ABSENT path, and test_record_acks_stores_what_is_stored takes the _stored_value → is not _ABSENT path.

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 --test and verify_vendor_manifest.py all exit 0. The seven test files that import superseded_defaults pass: 652 tests. scripts/scrub-lint.sh is not in the checkout; that scan runs as CI's internal-content-scan job. Backend-only diff, so CI reports only_backend=true and 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 _ABSENT binding 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested a review from a team as a code owner October 5, 2026 18:06
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b94e48e78beb2826aa01ffeb5e6778d6aa7777fe — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (1 items) — 1 justified

Intent: keep one sentinel object for "value is absent" in superseded_defaults.py, so a later edit cannot end up comparing against a different object than the rest of the module. This is a FIX: it removes a latent trap and changes no behaviour.

  1. The second module-scope _ABSENT = object() (the one above _stored_value) is deleted. The only binding left is at line 178, above all its readers, and every read sits inside a function body. — justified

[FIRST-PRINCIPLES-REVIEWED] b94e48e

Description read

[DESCRIPTION-READ] 101e59f301d341a4dd5b5826e452a27a11762a3b770c2cc2eed0daab70d3d9eb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b94e48e78beb2826aa01ffeb5e6778d6aa7777fe — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b94e48e78beb2826aa01ffeb5e6778d6aa7777fe — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b94e48e

Verdict parsed from the review's SHA-scoped output markers for commit b94e48e78beb2826aa01ffeb5e6778d6aa7777fe.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b94e48e78beb2826aa01ffeb5e6778d6aa7777fe: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b94e48e78beb2826aa01ffeb5e6778d6aa7777fe and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b94e48e

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b94e48e78beb2826aa01ffeb5e6778d6aa7777fe: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 5, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from be4a3b5 to 04e5001 Compare October 5, 2026 22:32
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files this PR's module imports or sits beside (config/loader.py docstring, plus import-graph neighbours) since this head went green (6f70008 -> 0ec74ff); config/superseded_defaults.py itself is unchanged on main and the patch-id is identical. Local gates and the 7 test files that import superseded_defaults (652 tests) re-pass on the rebased tree; CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 5, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution for head 04e5001562. Both reds are standing on main and neither touches this diff, which only removes the second _ABSENT = object() in config/superseded_defaults.py.

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.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 5, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 6, 2026 04:42
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from 04e5001 to b05f0cd Compare October 6, 2026 07:43
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved past this head's base (0ec74ff -> 557c8f8) and now carries the fixes for both reds attributed above: #17114 drops the graduated apps/hooks_integration.py coverage-baseline row, and #17145 backdates closed_at in test_slot_ownership_checkpoint.py so the Windows clock tie cannot 409. config/superseded_defaults.py is unchanged on main and the patch-id is identical (256f34b9). Local gates (flake8, isort, mypy, brand, harness parity, docs lint, per-file coverage, vendor manifest) and the 7 test files that import superseded_defaults (653 tests) pass on the rebased tree; CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution for head b05f0cdd0c. The two earlier reds are gone after the rebase (#17114, #17145). The reds now are one test that is failing on main. This diff does not touch it. The diff only removes the second _ABSENT = object() in config/superseded_defaults.py.

I didn't re-run anything. The failure is deterministic until #17285 is fixed on main. I'll re-sync this branch then.

@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from b05f0cd to 874c06c Compare October 6, 2026 09:24

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (5edf2feecb), which was 9 commits ahead.

  • Head: b05f0cdd0c → 874c06c97a
  • Conflicts: none
  • git range-diff: 1:1 identical (=)
  • Verification: py_compile passes on src/kiro_crew/config/superseded_defaults.py; pytest passes on test/test_config_superseded_defaults.py, test_cli_config_defaults.py, test_config_refactor_contract.py, and test_config_module_boundaries.py (197 passed)

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution for head 874c06c97a. Neither red touches this diff, which only removes the second _ABSENT = object() in config/superseded_defaults.py.

I rebased locally onto ea7e91c8e6 (range-diff =, no conflicts). The gates pass on the rebased tree: flake8, isort, mypy, black gate, brand, harness parity, docs lint, per-file coverage, and vendor manifest. The 7 test files that import superseded_defaults pass too. But main is now red the other way on the same file: test_a_budget_falls_with_the_reads_it_covers reports (1, 3) because #17309 dropped the module to one read. I reproduced that on pristine origin/main ea7e91c8e6 (1 failed, 46 passed). It is tracked in #17338, and #17339 and #17380 fix it.

I am holding the push. CI tests the merge ref, so pushing now would red shard 3 on that main bug again. I'll re-sync once a fix lands.

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.
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from 874c06c to b94e48e Compare October 6, 2026 17:32
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main 9bf943b0f9 (head 874c06c97a → b94e48e78b). The shard-3 red on the previous head (test_source_pin_budget.py over test/test_session_control_owner_dm.py, #17289/#17338) is fixed on main by #17339, which is now in this branch's base.

  • Conflicts: none. git range-diff: 1:1 identical (=).
  • main touched config/superseded_defaults.py once since the last head (perf(acp): size session_start_concurrency from the host by default #17072, one SupersededDefault tuple entry). It adds no _ABSENT reader; the remaining binding still precedes every reader, all inside functions.
  • Local gates on the rebased tree: flake8, isort, mypy, black gate, subprocess encoding, brand, harness parity, docs lint (both), per-file coverage, vendor manifest — all exit 0.
  • Tests: test_source_pin_budget.py plus the 7 test files that import superseded_defaults — 700 passed.

CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Green-age check for head b94e48e78b: green_age.py reports main +19 commits (9bf943b0f9 -> 9a6f9b94e3). The overlap it lists is import-graph and same-directory neighbours only. config/superseded_defaults.py is unchanged on main across that range (git log 9bf943b0f9..origin/main -- src/kiro_crew/config/superseded_defaults.py is empty).

I did not push a fifth re-sync. Instead I verified the rebased tree in a scratch worktree, cherry-picking this commit onto origin/main 9a6f9b94e3:

  • Conflicts: none. Patch-id identical (256f34b9).
  • Gates, all exit 0: flake8, isort, mypy, black gate, subprocess encoding, brand, harness parity, docs lint (both), per-file coverage, vendor manifest.
  • Tests: the 7 test files that import superseded_defaults, plus test_config_validation.py (the one config/ file main changed): 698 passed, 1 failed. The failure is test_published_metadata_requires_config_validator, and it is a local-venv artifact. That venv's installed kirocrew dist-info is a stale 0.3.0 whose metadata predates the jsonschema requirement. The test fails the same way on pristine origin/main 9a6f9b94e3, and CI's fresh install passes it.

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.

@bolichen97
bolichen97 merged commit 1fe3b7b into main Oct 6, 2026
101 of 102 checks passed
@bolichen97
bolichen97 deleted the refactor/simplify-config branch October 6, 2026 23:49

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants