fix(data): join ClearRotationForProject through namespace_entries (P6-DATA-02)#39
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR fixes per-project env rotation clearing through ChangesP6-DATA-02: Env Rotation Clear Fix
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as devstrap env rotate
participant Store as Store.ClearRotationForProject
participant DB as SQLite
CLI->>Store: ClearRotationForProject(projectID)
Store->>DB: SELECT env_profile_id FROM namespace_entries WHERE project_id=? AND env_profile_id IS NOT NULL
Store->>DB: UPDATE secret_bindings SET needs_rotation=false WHERE env_profile_id IN (...)
DB-->>Store: rows affected
Store-->>CLI: cleared count
CLI-->>CLI: print "Cleared N bindings for project"
Compact metadata:
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/audits/README.md`:
- Around line 50-52: The Pass 6 open-count header is out of sync with the actual
audit rows after moving P6-DATA-02 to Recently shipped. Update the summary text
in the Pass 6 ledger entry so the “open of 43” count matches the current table
totals (and the shipped count implied by the pass index and Recently shipped
section). Verify the arithmetic against the Pass 6 open table and the “Recently
shipped” entries in docs/audits/README.md, then correct the header wording
accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f8ec1626-37ac-4147-88e2-ebce780d8904
📒 Files selected for processing (7)
docs/audits/README.mdinternal/cli/env_test.gointernal/state/store.gointernal/state/store_test.gospec/09_SECRETS_AND_ENVIRONMENT.mdspec/12_DATA_MODEL_SQLITE.mdspec/18_WORK_LOG.md
…-DATA-02) The one-arg `devstrap env rotate <path>` (flag-clear-only) filtered its subquery on env_profiles.namespace_id — a column that does not exist — so every invocation failed with "no such column: namespace_id"; only `--all` worked. The project→profile link is namespace_entries.env_profile_id and the CLI already passes the namespace-entry ID, so the subquery now joins through namespace_entries (NULL-profile rows excluded). Pinned by TestClearRotationForProject (per-project isolation: clearing A leaves B flagged) and TestEnvRotateProjectClearsRotationFlag (one-arg CLI form exits 0 with the cleared-count message). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2aefb63 to
4fd16cb
Compare
…bit) The header and the open table used different semantics: fully-applied P6-DOC-02/P6-DOC-03 still sat in the open table while the header count excluded them. Move the fully-applied doc rows to Recently shipped so the header (33 open of 43) equals the row count by construction; P6-DOC-01/P6-DOC-04 stay listed for their open test-hardening residuals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Pass 6 P2 quick-win wave, PR 2 of 4 (
P6-DATA-02, docs/audits/AUDIT_RECOMMENDATIONS_2026-07-01_PASS6.md).Store.ClearRotationForProjectfiltered on the non-existentenv_profiles.namespace_idcolumn, so the one-argdevstrap env rotate <path>(flag-clear-only) form failed on every invocation with a SQL logic error —env rotate --allwas the only working path, and per-project rotation-flag clearing was dead. The subquery now joins throughnamespace_entries.env_profile_id(the actual project→profile link; the CLI already passes the namespace-entry ID):Tests
TestClearRotationForProject(internal/state): two projects with encrypted profiles, both flagged; clearing project A returns A's binding count, leaves B flagged.TestEnvRotateProjectClearsRotationFlag(internal/cli): one-argenv rotate work/xexits 0, prints "Cleared the needs-rotation flag on 2 binding(s) for work/x", zero flagged bindings remain.Validation
gofmt -w cmd internalgolangci-lint run(0 issues)go run ./cmd/spec-drift --base origin/main --head HEAD(pass)GOCACHE=/tmp/devstrap-gocache go test -race ./...(green)Specs: 09 + 12 (P6-DATA-02 sections → shipped), 18 work log; ledger reconciled. Note: the ledger open-count line will be reconciled against PR #38 at merge time (both PRs decrement it).
Implementation delegated to gpt-5.5 (Codex) per the model policy; diff reviewed line-by-line.
Follow-up (deferred): a CI lint that
db.Prepares every static store query against a migrated in-memory DB.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
env rotate <path>to scope properly and report the accurate cleared-binding count.Tests
Documentation