internal/planner: three documented invariants are unguarded by tests
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start with internal/planner/doc.go and the CLAUDE.md Key Patterns, then inspect TestReconcile_CreatesPlanOnFirstRun and node_update_test.go. Add coverage for zero submissions on plan creation, one Status().Patch per reconcile path, and Running after terminal NodeUpdate failure. Run the internal/planner tests and confirm all three invariants are enforced.
Written by the indexing model from the issue text.
Description
Problem
Three internal/planner invariants are documented in doc.go (sei-k8s-controller#391) and listed in CLAUDE.md Key Patterns, but no test directly guards them — a regression of any of the three compiles, lints, and passes CI today:
- Atomic plan creation (persist-before-execute ordering).
TestReconcile_CreatesPlanOnFirstRunasserts the plan is persisted andActive, but does not assert zero task submissions on the creating reconcile. Its comment even says "and executes the first task," which contradicts theplanAlreadyActivegate (the creating reconcile requeues without executing). The ordering — plan visible before any side effect — is unverified. - Single-patch model. Nothing asserts how many
Status().Patchcalls occur per reconcile path. A second status write per reconcile is legal Go and would pass; the single-snapshot/single-flush invariant is unverified. FailedPhase == ""means retry, not terminal.node_update_test.goasserts a NodeUpdate plan'sFailedPhaseis empty, but no test assertsnode.Status.PhaseremainsRunningafter a NodeUpdate task fails terminally — the actual retry-not-terminal behavior is unverified.
Impact
These are correctness/idempotency invariants: plan-creation atomicity (external observers must see the plan before side effects), single-patch staleness safety (paired with the optimistic-lock rule), and NodeUpdate retry semantics. They are load-bearing per CLAUDE.md, but a silent regression would not be caught by the suite.
Relevant experts
kubernetes-specialist— controller-runtime test patterns, envtest harness.idiomatic-reviewer— surfaced these during the/idiomaticpilot.
Proposed approach
- Atomic creation: assert
len(submitted) == 0on the creating reconcile inTestReconcile_CreatesPlanOnFirstRun, and fix the misleading comment. - Single-patch: assert exactly one
Status().Patchper reconcile path (a counting fake client, or a reconcile-level assertion). - Retry semantics: assert the node stays
Runningafter a NodeUpdate task fails terminally.
Out of scope
- The
doc.godocumentation change itself (sei-k8s-controller#391). - A stale-write race test for the optimistic-lock invariant — needs an envtest concurrency harness; separate and harder.
References
- Surfaced by the Tide
/idiomaticexpert pilot: sei-protocol/Tide#126 - Invariants documented in: sei-k8s-controller#391
- Dominant language
- Go
- Stars
- 1
- Forks
- 2
- Avg merge
- 2h 29m
- Merged PRs (30d)
- 56
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sei-protocol/sei-k8s-controller
-
Difficulty 5/5 Over a week Newbie friendliness 32/100
-
Difficulty 5/5 Over a week Newbie friendliness 32/100
sei-protocol/sei-k8s-controller#457 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in sei-protocol/sei-k8s-controller
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100