Skip to content

refactor(config): flatten the store-binding chain in the resolver - #12803

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/simplify-config
Sep 23, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/simplify-config

Conversation

@bolichen97

@bolichen97 bolichen97 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

resolve_agent_bindings in src/kiro_crew/config/loader.py picks which memory
store a session reads. It made that three-way choice as one conditional
expression nested inside another, so the reader had to unwrap it from the inside
out to learn which arm wins.

Why it matters

That statement decides a memory silo. Reading the wrong store answers a crew
with someone else's memory and nothing goes red — the prompt is well formed and
the content is plausible. A reader is the only detector this code has, so how
easily the precedence can be read is part of how safe it is.

What changed (motivation → approach → change)

The store choice now reads top to bottom as the three cases it always was.

Arm Store
a frozen execution record exists execution_context.store.store_id
a passthrough kiro agent is dispatched DEFAULT_MEMORY_STORE
otherwise require_member_memory_store(...)

One if/elif/else replaces the nested conditional expression. Nothing else
moves: the same three conditions in the same order, spelled the same way
(execution_context is not None, then bare passthrough), and
require_member_memory_store is still evaluated only in the last arm, so its
directory validation and its UnknownMemoryStore refusal fire on exactly the
inputs they fired on before.

This is the whole diff — 7 added lines, 10 removed, one file, no import moved
and no comment rewritten. It is one module's turn in a behavior-preserving
readability sweep of src/kiro_crew/config/; the module's mechanical-candidate
queue is empty after it.

The kiro_agent conditional three lines below keeps its expression form on
purpose. It is one two-arm conditional that already reads top to bottom, not a
nested one, so flattening it would add lines without making any precedence
easier to see. Folding both assignments under a single if on the shared
execution_context is not None test would couple two independent bindings to
one branch structure, which is a larger change than a readability pass should
make.

Backwards compatibility

Compatible: the statement chooses the same store for every combination of
execution_context and passthrough, and raises the same exception in the same
cases, so no caller or configuration behaves differently.

Tests

No new tests. The change is provably equivalent rather than a behavior change,
and the existing suites already cover every arm: test/test_config_loader.py,
test/test_crew_memory_store_binding.py, test/test_member_memory_ownership.py
and test/test_memory_v2_isolation.py — 787 tests, all passing on this head.

Manual verification

N/A — unit coverage sufficient: a pure control-flow flatten of one assignment
has no runtime surface that a manual step reaches but the store-binding and
ownership suites do not.

Why no screenshot: backend-only diff — one Python statement in
config/loader.py, no frontend path touched, so nothing rendered changes.

Related Issues

no linked issue: routine readability work, not a reported defect.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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 review from a team and hoang-phan98 September 22, 2026 12:45
@bolichen97 bolichen97 changed the title refactor(config): flatten the store-binding chain in resolve_agent_bindings refactor(config): flatten the store-binding chain in the resolver Sep 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Intent: Make the three-way memory-store choice in resolve_agent_bindings readable top-to-bottom, so the arm that wins is visible without unwrapping a nested conditional expression — this statement selects a memory silo, and a reader is its only detector.
Not a goal: Changing which store any input selects, touching the surrounding guards or imports, or sweeping a second module in this PR.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of c86485f236b7c82d3b27c0c2f438c4afe41d39a3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c86485f

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

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] c86485f

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

The diff is a pure structural refactor: the nested conditional expression and the new if/elif/else evaluate the same three branches in the same order (execution_context is not None → passthrough → require_member_memory_store(...)), assigning the identical values with the identical call arguments. No behavioral change, and no defect to ground.

No findings.

[OPUS-REVIEWED] c86485f

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

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

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of c86485f236b7c82d3b27c0c2f438c4afe41d39a3 — 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

Confirm CI ran the store-binding suites green on this head — the claimed 787-test pass is the only evidence I could not reproduce.

What this change ships

Inventory (1 item) — 1 justified

Intent: make the three-way memory-store precedence in resolve_agent_bindings readable top-to-bottom — a behavior-preserving refactor (neither FIX nor ADDITION in the feature sense).

  1. The store-binding choice is spelled as if/elif/else instead of a nested conditional expression; same three conditions, same order, require_member_memory_store still evaluated only in the last arm — justified

The diff is exactly the one hunk the description claims (7+/10−, one file, comment untouched); I verified the rewritten form at src/kiro_crew/config/loader.py:6484-6491 is condition-for-condition equivalent to the deleted expression, including lazy evaluation of the validating call. No new surface, no moved default, no deleted pin, no rider.

[FIRST-PRINCIPLES-REVIEWED] c86485f

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from ebf6169 to ae826be Compare September 22, 2026 17:30
@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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 22, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from ae826be to 21e7287 Compare September 22, 2026 17:57
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 22, 2026
@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: checking Automated validation is still running labels Sep 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (macOS) (3) red — not from this diff, and it will not clear on a re-run.

FAILED test/test_subprocess_pool.py::TestResolutionParity::test_a_name_that_is_not_utf8_round_trips
OSError: [Errno 92] Illegal byte sequence: b'.../not\xffutf8'

Tracked at #12877, filed earlier today from run 35759085445 — a different head than this one.

Why it is not attributable here:

  • This PR changes exactly one file, src/kiro_crew/config/loader.py. git diff origin/main...HEAD -- test/test_subprocess_pool.py src/kiro_crew/subprocess_pool.py is empty: the failing test and its subject are byte-identical to origin/main.
  • The cause is in main and is deterministic, not a flake. The test builds a filename holding a raw 0xff byte and is guarded by posix_names_only = pytest.mark.skipif(os.name == "nt"), which skips only Windows. macOS is posix, but APFS rejects non-UTF-8 names with EILSEQ, so the test's real precondition is Linux rather than not-Windows. Nothing about a store_name assignment influences whether APFS accepts a filename.
  • It is normally invisible: the macOS lane runs only on a 1-in-20 head-SHA sample, a darwin-paths match, or the ci:macos label. This head sampled in; that is luck, not a regression.

Left unfixed on purpose. The fix belongs to #12877 and lands in test/test_subprocess_pool.py, a different module from this sweep — correcting it here would widen a one-module, one-commit readability PR into another area's tracked test fix. Weakening or skipping the assertion is not on the table.

PR Readiness is green on this head, and the other 94 checks pass, including all 8 Windows shards.

@bolichen97
bolichen97 enabled auto-merge (squash) September 22, 2026 19:47
The memory-store choice in resolve_agent_bindings read as a nested
conditional expression whose middle arm was itself a conditional, so the
three-way decision (execution record, passthrough, configured member)
had to be reassembled from the reader's inside out.

State the three arms as an if/elif/else in the order they are decided.
Same arms, same order, same short-circuiting: require_member_memory_store
is still reached only when no execution record and no passthrough apply,
so its directory validation and refusal fire on exactly the same inputs.
@bolichen97
bolichen97 force-pushed the refactor/simplify-config branch from 21e7287 to c86485f Compare September 22, 2026 22:34
@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (macOS) (3) — now resolved by rebase, not by any change here.

The root cause landed on main while this PR was open: #12914 ("test: skip the non-UTF-8 pool name test on macOS, like its siblings", commit b35a866d85) fixes #12877 by splitting the guard — posix_names_only keeps skipping only Windows for the newline case, and a new utf8_relaxed_names_only skips os.name == "nt" or sys.platform == "darwin" for the non-UTF-8 case, which is the real precondition. That is the fix the previous note said belonged to #12877, and it landed there rather than being widened into this sweep.

So this branch is now rebased onto origin/main (cc385211d8, was base +9 commits behind) and carries that fix. No assertion was weakened, no skip was added here, and no re-run was used to paper over it.

Supporting attribution, for the record: the same test — test_subprocess_pool.py::TestResolutionParity::test_a_name_that_is_not_utf8_round_trips, OSError: [Errno 92] Illegal byte sequence — was failing macOS shard 3 on at least five other unrelated heads in the same window (feat/terminal-exit-closes-tab, feat/workspace-fullscreen-controls-v2, fix/pod-orphan-home-reclaim, feat/redaction-renderer-hard-rules, feat/crewmate-teams-api). It was a standing main break that the macOS lane's 1-in-20 head sampling only exposes on whichever PR happens to sample in.

The diff itself is unchanged by the rebase: still one file, src/kiro_crew/config/loader.py, 7 insertions / 10 deletions.

Gates re-run on the rebased head with the Python 3.12 parity venv: flake8 0, isort --check-only 0, mypy src/kiro_crew 0 (1694 files — this confirms the flatten did not trip mypy's first-assignment inference for the now conditionally-assigned store_name), check_black_formatting 0, check_subprocess_encoding 0, check_brand_name 0, check_harness_parity 0, docs_lint --test 0, docs-lint.sh 0, check_per_file_coverage --test 0, verify_vendor_manifest 0. Targeted tests across the eight suites that exercise resolve_agent_bindings and the memory-store binding: 1045 passed, 0 failed.

Disposition of every verdict on the previous head

The rebase preserved the diff byte-for-byte, so each of these was reviewed against identical content:

  • Design Review (Fable 5) — PASS. Accepted, no action.
  • First Principles Review (Fable 5) — PASS, 1 item, 1 justified. Accepted, no action.
  • GPT 5.6 Review — no blocking findings. Accepted, no action.
  • Opus 4.8 Review — no blocking findings. Accepted, no action.
  • Backend Tests (macOS) (3) — fixed, by rebasing onto the main commit that carries test: skip the non-UTF-8 pool name test on macOS, like its siblings #12914.
  • Automated Rule Check / Inclusive Language / SAST (Semgrep) / PR Hygiene / Screenshot Evidence cancelled — not findings: each was superseded by a higher-priority concurrency request for the same PR and re-ran green on the same head.

No unresolved review threads.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for c86485f236b7c82d3b27c0c2f438c4afe41d39a3; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

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

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

Copy link
Copy Markdown
Contributor Author

Housekeeping: there are two codex-ai-review comments on this PR, and the older-looking one is the stale copy.

The rate-limit window described above also broke the GPT lane's update-in-place. That lane failed with "Could not read this PR's comments after 3 attempts", so when it retried it posted a second <!-- codex-ai-review --> comment instead of editing the first. Both are scoped to the same head, c86485f236b7c82d3b27c0c2f438c4afe41d39a3:

  • #issuecomment-5776777167 — GPT 5.6 Review — ✅ no blocking findings, last updated 22:59:33Z. This is the authoritative verdict: it is the canonical comment the lane edits in place, and it was written by the successful re-run.
  • #issuecomment-5785367976 — GPT 5.6 Review — ⚠️ review incomplete, last updated 22:36:25Z. Stale. It has a higher comment id but an earlier update time, because it was created during the outage and then never touched again once the lane recovered.

The GPT 5.6 Review check itself is green on this head and PR Readiness resolved to SUCCESS, which confirms the contract read the completed verdict rather than the incomplete one. No /ai-review override is being requested: nothing needs overriding, the review completed. Flagging it only so a human skimming the thread does not read the stale copy as an open concern.

Full state on c86485f236b7: 93 checks, 0 failing, 0 running; PR Readiness SUCCESS; Design PASS, First Principles PASS, GPT no blocking findings, Opus no blocking findings; 0 unresolved review threads; MERGEABLE.

Not merging and not arming auto-merge — landing is the maintainers' call.

@bolichen97
bolichen97 merged commit 76ce559 into main Sep 23, 2026
96 of 104 checks passed
@bolichen97
bolichen97 deleted the refactor/simplify-config branch September 23, 2026 01:30
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…odotdev#12803)

The memory-store choice in resolve_agent_bindings read as a nested
conditional expression whose middle arm was itself a conditional, so the
three-way decision (execution record, passthrough, configured member)
had to be reassembled from the reader's inside out.

State the three arms as an if/elif/else in the order they are decided.
Same arms, same order, same short-circuiting: require_member_memory_store
is still reached only when no execution record and no passthrough apply,
so its directory validation and refusal fire on exactly the same inputs.
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