Skip to content

refactor(knowledge): label backends through the pool's _label helper - #32201

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/simplify-knowledge
Nov 7, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/simplify-knowledge

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the knowledge pool's worker logs name a backend the one way the module already defines, with no change to behaviour.

knowledge/llm_pool.py has a helper, _label(backend), that gives a backend's policy id for messages (Kiro CLI shows as kiro, not ""). The fallback messages and one zero-tool restart message already use it. Four other log calls in AcpWorker write the same lookup out by hand as POLICY_ID_BY_BACKEND.get(x, x).

Why it matters

When a module has two ways to spell one label, the next change to how a backend is named in messages updates the helper and misses the four hand-written copies. The startup, restart, refusal and unsupported-effort logs would then name the backend differently from the fallback message about the same worker.

Not a goal

  • Any other edit in knowledge/. ingestion.py hand-builds its _gate and _insert_job closures twice, in ingest_file and ingest_text. That file's structure is pinned by AST ratchet tests (test_knowledge_ingest_created_ids.py, test_knowledge_ingestion_off_loop.py) and touched by two open PRs, so it is left alone.
  • embedder.py:_fresh_cached_availability. The detector matched it against model_resident_async, but the two do not compute the same value.
  • The authorize_upload_root copies across the discord, feishu, webex and wecom renderers. They span four packages.

What changed (motivation → approach → change)

src/kiro_crew/knowledge/llm_pool.py: four log arguments in AcpWorker, at spawn, the restart after an unconfirmed zero-tool spec, the refusal when a spec has no "tools": [], and the unsupported-effort warning, now call _label(x) instead of POLICY_ID_BY_BACKEND.get(x, x). _label's body is that exact expression. No import changes, because _label still reads POLICY_ID_BY_BACKEND.

Backwards compatibility

Compatible: each call returns the same string from the same module global, so every log line is byte-identical.

Removes nothing: no name, key or path is deleted. The four expressions are replaced by a call that returns the same value.

Tests

No test added or changed: the rewrite produces the same log arguments, so a test has nothing new to observe.

Proof: not provable -- other: behaviour-preserving call-site dedup, no production behaviour to revert

  • Related tests (Python 3.12): test_llm_pool.py, test_llm_pool_lifecycle.py, test_llm_pool_effort.py, test_llm_pool_enterprise_floor.py, test_llm_pool_ccworker.py, test_knowledge_spec_repair.py, test_knowledge_effort_pools.py, test_knowledge_harness_refusal_ingest.py, test_claude_zero_tools.py, test_acp_goose_backend.py, test_acp_pi_backend_session.py, test_knowledge_owner_gate.py and test_knowledge_budget.py. All 454 passed.
  • Static gates (Python 3.12): flake8, isort, mypy, the pinned black gate, comment-history, brand, harness parity, subprocess encoding, the line cap, both docs lints, the per-file coverage self-test and the vendor manifest. All exit 0 on the committed tree. scripts/scrub-lint.sh does not exist in the tree.
  • Overlap: git merge-tree against the open fix(knowledge): [Crew pulse] reset pool workers in place after every call #31762 and feat(git): switch branches from the Git panel and composer chip #17628, which also touch llm_pool.py, shows this hunk auto-merging. Each PR's conflict set is the same with and without this commit.
  • Pre-PR review. Three read-only reviewers, one lens each: AUTOSDE blocking rules plus the code-review.yml greps and the claude-review.yml bar; behaviour preservation (helper body, argument types, test patches, source pins, imports, comments); and keystone, boot path and harness parity. None found anything, so there was nothing to verify or drop. The codex-review.yml severity sections were not read by that reviewer.

Manual verification

N/A: the replaced expressions and the helper are the same expression, so no path can behave differently.

Screenshots / video

Why no screenshot: backend-only change to log arguments in one Python module; no page, route or rendered string changes.

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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 7, 2026 07:49
@bolichen97
bolichen97 enabled auto-merge (squash) November 7, 2026 08:14
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution for head d133173f64. None of these reds comes from this diff, which changes four log arguments in knowledge/llm_pool.py.

  • Backend Tests (3.12, 2), Backend Tests (Windows) (2) and Coverage Gate. The only failing test is test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget (34,855 lines against a budget of 34,845). It fails the same way on pristine origin/main @ 0795ebc479, and this PR touches nothing under security/. test: raise the security package line budget to its size on main #32183 is the open fix. Once it lands I'll rebase this PR.
  • The seven AI and license lanes (Opus, GPT, Design, First Principles, UX, Sensitive Change, Dependency License). Each one failed closed in review-merge-base.sh with gh: API rate limit exceeded for installation (HTTP 403), at 07:49 and again on the 08:04 rerun. No lane reviewed the diff. I'll rerun them once the installation quota resets.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 9b7903165c4d76f7c16126a26e1ccc60eaf44d25 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 9b7903165c4d76f7c16126a26e1ccc60eaf44d25 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the four call sites now go through the module's existing _label helper, whose body is the same expression they used, so every log line stays identical.

[DESIGN-REVIEWED] 9b79031

Description read

[DESCRIPTION-READ] 48cbe2cfd56d7fbf0911037376e1c728d7d0417147d58a6598c736d24d10e401

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 9b7903165c4d76f7c16126a26e1ccc60eaf44d25 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The PR swaps in a call to a helper the same module already defines and changes no behaviour.

Notes

  • Item 1 — point patch: this cleans up one module, but 13 POLICY_ID_BY_BACKEND.get( sites in src/ sit outside knowledge/. Six of them are private helpers that each spell the same lookup again: agent_backend_governance._policy_id, computer_use/cli.py:343, dashboard/messaging_api/spawn.py:107, agent_sdk/backend_cards.py:940, agent_sdk/backend_install.py:603 and doctor_checks/agents.py:407. The other seven are inline: four in providers/acp_model_effort.py and one each in acp/client_new_conversation.py:63, doctor_checks/agents.py:491 and dashboard/messaging_api/spawn.py:203. So "the next change to how a backend is named in messages" still misses most copies. Deferring them fits "Part of refactor: module-by-module behaviour-preserving backend simplification #16523". Subtraction: none in this PR. Later, the per-module helpers collapse onto one of the existing ones.

What this change ships

Inventory (1 items) — 0 justified

Intent: make the knowledge pool's worker logs name a backend through the module's single label helper. Refactor, no behaviour change (neither a fix nor an addition).

  1. Four AcpWorker log lines (start, zero-tool restart, refusal, unsupported effort) now get the backend label from _label instead of the inline lookup, and the output is byte-identical — point patch (13 sibling sites outside knowledge/)

[FIRST-PRINCIPLES-REVIEWED] 9b79031

Description read

[DESCRIPTION-READ] 727f09a4df47767c683ece2ddd942661d5ab5fd759776c2b843aeae60bdfc947

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

I checked the four changed call sites against the repository code. Each one now calls the module's _label helper (src/kiro_crew/knowledge/llm_pool.py:291), and that helper returns POLICY_ID_BY_BACKEND.get(backend, backend), the same expression it replaces. So every log message prints exactly what it did before. The candidate list was empty, and I found nothing to add.

No findings.

[OPUS-REVIEWED] 9b79031

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9b7903165c4d76f7c16126a26e1ccc60eaf44d25 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9b79031

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9b7903165c4d76f7c16126a26e1ccc60eaf44d25 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 force-pushed the refactor/simplify-knowledge branch from d133173 to f382bf1 Compare November 7, 2026 12:32
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main @ bab2387339, which carries the raised security line budget (34,894; the package measured 34,855 on the previous head), so the shard-2 / Windows shard-2 / Coverage Gate red attributed above should clear. New head f382bf17a7, diff unchanged (four log arguments in knowledge/llm_pool.py). Locally re-gated: flake8, isort, mypy, black gate, brand, harness parity, comment history, docs lint, per-file coverage, line cap, vendor manifest all exit 0; targeted tests (29 llm_pool/AcpWorker files + test_security_gate_liveness.py) 1321 passed, with 3 setup errors in test_auto_research_handlers_coverage_campaign_routes.py that reproduce identically on pristine main (local venv plugin mismatch). 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 Nov 7, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-knowledge branch from f382bf1 to 9b79031 Compare November 7, 2026 13:25
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/conftest.py since this head went green (bab2387 -> f58c3cf); 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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: refactor (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: four log calls use the existing _label helper, which returns the same POLICY_ID_BY_BACKEND lookup they inlined; no behaviour change.

@bolichen97
bolichen97 merged commit 7a5fddd into main Nov 7, 2026
98 of 99 checks passed
@bolichen97
bolichen97 deleted the refactor/simplify-knowledge branch November 7, 2026 15:09
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