Skip to content

fix(acp): end a shared sub-agent turn whose tenancy claim cannot be recorded - #25605

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/shared-turn-claim-failure-15557
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/shared-turn-claim-failure-15557

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a shared sub-agent turn whose tenancy claim cannot be recorded ends at once with a logged reason, instead of running a turn whose every internal-API call is refused.

AcpSessionProvider._claim_shared_turn swallows any exception from claim_runtime_tenancy at DEBUG and returns None. Since #15529 the tenancy entry is the ONLY record admitting a sharing sub-agent's X-Session-Key on a shared pid. The principal's lease keeps that pid's bound set non-empty, so a turn without its claim reads as positive evidence the session is not on the process, and every stub call for the rest of the turn is refused 403 peer_session_unbound, explained by one debug line.

Why it matters

The cost of the silent path moved from "undefended against a sweep" to "this sub-agent cannot call the internal API for a whole turn", while the log level stayed at DEBUG.

Not a goal

  • Changing RuntimeTenancy.claim or the peer check.
  • The RuntimeTeardownCommitted arm, which already raises AcpProcessDied.

Intended? / Repro

Intended? No longer. The guard's docstring (src/kiro_crew/acp/session_provider.py:231-238 on main) justifies it by "the worst case of not claiming is the behaviour that shipped before this table existed", which #15529 made untrue. The issue names this as option 1 of two acceptable fixes.

Repro: latent, as the issue says: RuntimeTenancy.claim does guarded work and its one raise is re-raised above. Forcing claim_runtime_tenancy to raise on main makes _claim_shared_turn return None and log only at DEBUG; the turn then proceeds unclaimed.

What changed (motivation → approach → change)

Symptom: a silently unclaimed turn. Cause: a blanket except Exception at DEBUG. Change: end the turn the way a committed teardown already does.

  • _claim_shared_turn: reading _owns_runtime / _runtime / _session_key stays inert on AttributeError (a provider built without __init__, as the translation unit tests do, has no runtime to claim). An exception from claim_runtime_tenancy itself now logs a WARNING with the traceback and raises AcpProcessDied("shared-runtime tenancy claim failed: ..."), the same death callers already answer by getting another runtime. The docstring states the new rule.
  • docs/system-specs/modules/runtime-ownership.md (Tenancies): one paragraph on the refusal.

Backwards compatibility

Compatible for every turn whose claim lands, which is every reachable path today. A turn whose claim fails now dies at its start instead of 403-ing its stub calls.

Removes nothing.

Tests

test/test_runtime_ownership.py:

  • test_a_claim_that_cannot_be_recorded_ends_the_turn: claim_runtime_tenancy raising makes _claim_shared_turn raise AcpProcessDied, logs "could not be recorded" at WARNING, and leaves no claim behind.
  • test_a_provider_without_a_runtime_stays_inert: a provider built with object.__new__ still answers None.

On main the first fails (it returns None).

Proof: not provable -- other: this host runs no local tests; CI runs the new tests

Manual verification

N/A: latent path, covered by the tests. Static gates: black, flake8, scripts/docs_lint.py, scripts/check_comment_history.py.

Related Issues

Fixes #15557

Sibling sweep

Swept: git grep -n "_claim_shared_turn" -- src
Sibling: stream (session_provider.py:650) -- not affected (already lets AcpProcessDied from the claim propagate)
Sibling: stream_command (:769) -- not affected (same)
Sibling: stream's stub reclaim() guard -- not affected (a failed push keeps the session fail-closed for a turn, as its comment states)

Pattern harvest

Not generalizable: one guard.

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.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 29, 2026 03:02
@CrysisDeu
CrysisDeu requested a review from iamwhatever October 29, 2026 03:03
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 236a6d314c2e5c3ea9ff0315145d6ff7527fd4fb — 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 change narrows one blanket except to the cause #15529 created. The reversed pin is quoted and refuted in the description, with issue #15557 as provenance.

What this change ships

Inventory (4 items) — 4 justified

Intent: a sharing sub-agent whose tenancy claim fails should die visibly at turn start, not run a turn where every internal-API call is refused. FIX.

  1. A shared sub-agent turn whose tenancy claim raises now ends at once with AcpProcessDied, which callers already handle, instead of continuing unclaimed. — justified
  2. That failure now logs at WARNING with a traceback, not at DEBUG. — justified
  3. A provider built without __init__ still returns None, now through a separate AttributeError arm. Without this arm the narrowed except would turn that case into a turn death. — justified
  4. The Tenancies section of runtime-ownership.md gains one paragraph on the refusal. The spec has to move in the same commit. — justified

[FIRST-PRINCIPLES-REVIEWED] 236a6d3

Description read

[DESCRIPTION-READ] 14ae615b642e3c45cc639c198ae59293e39cda4c081d786c32381adc4f7cad7b

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change turns a silent, turn-long run of 403s into an immediate, logged failure that callers already handle, and a revert undoes it cleanly.

Notes

  • The description says callers handle AcpProcessDied "by getting another runtime", but it never shows that a retry stops picking the same shared runtime. If the claim keeps failing, each retry could fail the same way. That is still better than the old silent 403s, and nothing reaches this path today.

[DESIGN-REVIEWED] 236a6d3

Description read

[DESCRIPTION-READ] c9c91053bb54274a1e6099c4643792eaa8340a2d6559768e3953ba46773c9e67

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 236a6d3

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

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

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 236a6d3

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention 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 Oct 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 236a6d3 for human review (policy: runtime tenancy / process lifecycle).

The change makes a shared sub-agent turn end with AcpProcessDied when its tenancy claim cannot be recorded, instead of running unclaimed and having every stub call refused (session_provider.py#L254-L282). The tenancy record is both the process's teardown defence and what admits the sub-agent on the peer check, so a maintainer should review it.

I found no defect. The claim is taken before each turn's try, so a raise leaves nothing to release (L662, L781). A provider without __init__ stays inert. The Design note about a retry hitting the same runtime does not block: no path reaches this branch today, and callers bound retries. All AI lanes pass and CI is green.

What clears it: a maintainer review of the tenancy behaviour change.

— crew-pr-reviewer (r134)

@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.

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 4a64f64 into main Oct 29, 2026
143 of 166 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/shared-turn-claim-failure-15557 branch October 29, 2026 19:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth: a silently skipped shared-turn tenancy claim now costs the whole turn its API access

3 participants