Skip to content

refactor(cloud): delete the unread _DELETE_DONE constant - #14498

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/simplify-cloud
Sep 28, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/simplify-cloud

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make src/kiro_crew/cloud/ec2.py say only true things about stack deletion: drop a constant nothing reads, and correct a docstring that promises an exception the code never raises.

_DELETE_DONE = "DELETE_COMPLETE" sits among the terminal CloudFormation state sets in cloud/ec2.py. No code, test, doc or script reads it, and it has never had a reader since it was added. Next to it, the destroy() docstring says the wait "raises on DELETE_FAILED". It does not: a failed delete comes back as destroyed: False.

Why it matters

A reader of the stack-state block assumes every name there feeds a decision; an unread one sends them hunting for delete logic that does not exist. The docstring is worse: a caller who trusts it wraps destroy() in a try and never checks destroyed, so a stack stuck in DELETE_FAILED keeps billing while the caller reports success.

Not a goal

  • No change to any stack-state set, the delete wait, teardown or the reaper. destroy() keeps returning a failed delete rather than raising it.
  • No other cloud cleanup: the deep if/elif chains in launch_job.py and wizard.py sit inside try/finally and do not flatten cleanly, so they stay.

What changed (motivation → approach → change)

One unread constant goes away and one docstring now matches the code; behaviour is unchanged.

The module-simplification detector reports zero mechanical sites tree-wide, so this is a judgment-class pass: an AST scan for top-level private names whose identifier appears exactly once across src/, test/, docs/, scripts/ and website/. In the cloud module that finds only _DELETE_DONE, and its line is deleted.

The destroy() docstring now says what the code does. wait_for_delete returns rc == 0 from the CLI waiter, and destroy() passes that through as destroyed. So False means the wait did not confirm DELETE_COMPLETE, and that outcome is returned, never raised. Every other DELETE_FAILED mention in cloud/, cli_cloud.py and dashboard/handlers_cloud.py already describes it this way.

Backwards compatibility

Compatible: the name is private and has no reader anywhere in the tree, so nothing that works today can observe its absence.

Tests

No test change. Nothing tests or patches the constant. The existing cloud tests (test_cloud_ec2.py, test_cloud_cli.py, test_launch_engine_ref.py, test_aws_profile_charset.py; 321 tests) pass unchanged.

Manual verification

N/A — a deleted unread constant and a docstring edit have no runtime path to exercise. Static gates (flake8, isort, mypy, brand, harness-parity, docs-lint, per-file coverage, vendor manifest) pass. Backend-only diff, so CI's changes job narrows to only_backend=true and the frontend suites do not run.

Pre-PR review: five read-only lenses (AUTOSDE blocking rules, behaviour preservation, import semantics, security keystone and boot path, comment accuracy), then independent refuters for each finding. Two findings survived: the destroy() docstring's false "raises on DELETE_FAILED" (fixed here) and an inaccurate history claim in the commit message (reworded). A verifier then flagged the first rewrite of the docstring as over-claiming ("the waiter giving up" cannot happen before the 1800 s timeout); it was tightened to the current wording. Nothing was dropped as a false positive.

Screenshots / video

Why no screenshot: backend-only constant deletion and docstring edit; nothing renders differently.

Related Issues

no linked issue: a readability cleanup from the module-simplification sweep, not a tracked defect.

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 September 27, 2026 18:01
@bolichen97

Copy link
Copy Markdown
Contributor Author

Intent: Make cloud/ec2.py state only true things about stack deletion — delete the never-read _DELETE_DONE constant and correct the destroy() docstring that promised a raise on DELETE_FAILED the code never performs. Behaviour-preserving.
Not a goal: changing how destroy() reports a failed delete (it keeps returning destroyed: False), or any other cloud refactor.

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

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 62ce026

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

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 62ce026

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 62ce0262e22e6de5d6fc133d54f3c09edef2786c — 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 (2 items) — 2 justified

Intent: FIX — make cloud/ec2.py stop stating two falsehoods about stack deletion: an unread constant and a docstring promising an exception the code never raises.

  1. The private constant _DELETE_DONE disappears from the stack-state block — justified
  2. destroy()'s docstring now says a failed delete is returned as destroyed: False, never raised — justified

Verified: grep for _DELETE_DONE across the tree finds zero readers; wait_for_delete (ec2.py:1274) returns rc == 0 from run_aws, which by its own contract (aws.py:207) never raises on non-zero exit and returns 124 on timeout, so the rewritten docstring matches the code and the deleted line ("raises on DELETE_FAILED") was demonstrably false — the evidence lens 8 requires for rewriting it.

[FIRST-PRINCIPLES-REVIEWED] 62ce026

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 62ce026

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

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

@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 Sep 27, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI reds on b057d395d8 are pre-existing main breaks, not this diff. The diff touches only src/kiro_crew/cloud/ec2.py (one deleted constant, one docstring), and every recent PR head on 20ed6a1dc7 reds the same jobs (checked: fix/untrusted-text-fencing run 36338508779, fix/memory-consolidate-refuses-temporary-sessions 36338408805, feat/mcp-chat-folder-project-dir 36338400787, feat/channel-queue-steer 36338349510, fix/bundle-ownership-roundtrip-2670 36338304470).

Job Failure Tracker
Backend Tests (3.12, 2) test/test_oneshot_supervisor.py::test_pidfd_fallback_through_ctypes_signals_a_group_member (1 failed, 22089 passed) — same node id on the other heads #14503
Electron Shell Tests no probe CALL is unclaimed by a list / no sentinel literal is unclaimed by a list #14491
Frontend Tests (2) src/i18n/style/bnStyle.test.ts — Bengali-digit ratchet, 9 catalog keys vs cap 8 none found
Coverage Gate cascade: backend-test=failure frontend-test=failure —

No rerun requested: all three are deterministic on main, so a rerun would fail identically. This PR is otherwise converged — GPT, Opus, Design, First Principles and UX all PASS with no findings.

ec2.py bound _DELETE_DONE = "DELETE_COMPLETE" at module scope, but no
code, test, doc or script in the tree reads it, and it has never had a
reader since it was added. The delete path waits on
`aws cloudformation wait stack-delete-complete` and never compares a
status string against it.

The destroy() docstring claimed the wait "raises on DELETE_FAILED". It
does not: wait_for_delete returns False whenever the wait does not
confirm the delete, and destroy() reports that as destroyed=False. The
docstring now says so. Behaviour is unchanged.
@bolichen97
bolichen97 force-pushed the refactor/simplify-cloud branch from b057d39 to 62ce026 Compare September 27, 2026 22:27
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto f57c1dee40 (#14518), which fixes the three pre-existing main reds this head hit (test_oneshot_supervisor backend shard 2, the bnStyle digit ratchet on frontend shard 2, and the Electron port-identity lint), plus the Coverage Gate that failed closed because of them. The diff is unchanged: still only src/kiro_crew/cloud/ec2.py. Local gates (flake8, isort, mypy, brand, harness parity, docs lint, per-file coverage, vendor manifest, test_cloud_ec2.py + test_oneshot_supervisor.py) are green on 62ce0262e2. CI is 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 Sep 27, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) on 62ce0262e2 failed one test, test_spawn_approval_mid_wait_deny_13559.py::TestAMidWaitDenyFallsThrough::test_an_approve_press_is_unaffected (22089 passed). I attribute it to a flake, not this diff: the diff touches only src/kiro_crew/cloud/ec2.py, which has no path into Telegram spawn approvals; the same test passed on the previous head's shard-2 run; and the file passes 5/5 in isolation locally on the Python 3.12 venv. I re-ran only the failed jobs (shard 2 + the Coverage Gate that depends on it). The test and its timing are unchanged.

@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 Sep 27, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) September 28, 2026 00:27
@chenmingwei23
chenmingwei23 merged commit c30159c into main Sep 28, 2026
141 of 143 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/simplify-cloud branch September 28, 2026 00:33
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 28, 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.

2 participants