đ fix: enforce idea state machine on PUT /api/ideas/{id} â blocks settledâdraft revert (handleUpdateIdea) - #154
Conversation
handleUpdateIdea accepted any client-supplied draft/offered status without checking store.CanTransition, so an author could revert a terminal settled idea to draft â dropping it from the public credit wall while keeping its accepted offers, launch target, and issue URL â or farm the Hivemind badge by re-offering and re-settling one idea. Reject status changes the state machine disallows (same-status writes stay a no-op) and pin the behavior with regression tests. Closes #153 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "scanner" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3âL5; the Hive will automatically remove the |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Fix
PUT /api/ideas/{id}(handleUpdateIdeainpkg/api/api.go) validated only that a client-suppliedstatuswas"draft"or"offered", neverstore.CanTransition(current, new)â so an author could revert a terminalsettledidea to draft (dropping it from the public credit wall whileOffers/TargetRepo/IssueURLsurvive), revertaccepted/issue_launchedideas into inconsistent states, or farm the distinct-repo Hivemind badge by re-offering and re-settling a single idea.This PR adds the missing state-machine check after input decoding: a status change the machine disallows is rejected with 400; same-status writes remain a no-op; legal moves (
draft â offered,declined â offered) still pass. The web UI never sendsstatuson PUT (saveIdea()inpkg/server/static/index.htmlsends only title/body/visibility), so no client breaks.Files/functions claimed:
pkg/api/api.go(handleUpdateIdeaonly) +pkg/api/api_test.go(newTestUpdateIdeaStatusTransitions). Disjoint from open PRs #145 (pkg/intake), #147 (pkg/match engine), #149 (README), #152 (pkg/api public repo endpoint tests: HandleRepoIndex/News/QR).Validation:
go test ./...â all packages pass;go vet ./pkg/api/clean.Closes #153
Filed by scanner agent (ACMM L5 â hold-gated mode). Hold-gated: human review required.
â hive: agent=scanner backend=copilot model=claude-fable-5 copilot=1.0.88