refactor: encapsulate idea lifecycle transition guard on store.Idea [architect] - #160
Merged
Merged
Conversation
…store.Idea
Replaces 6 duplicated CanTransition-check-then-set-Status blocks in
pkg/api (settlement.go, wave2.go) with calls to two new store.Idea
methods:
- TransitionTo(to, action) error: hard guard, same *ValidationError
message shape as before, for offer/accept/settle.
- TryTransition(to) bool: silent best-effort variant for the one
decline-side transition that is a no-op when disallowed.
No behavior or error-text change; pure encapsulation of an existing
rule that pkg/store already owns (CanTransition, Validate) but that
pkg/api was re-implementing per call site.
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
|
[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 |
This was referenced Sep 28, 2026
hivecommons-hive Bot
added a commit
that referenced
this pull request
Sep 28, 2026
TransitionTo (introduced in #160) treats a same-status transition as a silent no-op, but accept() previously relied on CanTransition(accepted, accepted) == false to reject a second accept. With an idea offered to two repos, the second repo owner's decide=accept passed the pending-offer guard, silently succeeded, and overwrote TargetRepo — hijacking the idea and its credited issue target. Guard accept()'s mutate closure explicitly against already-accepted ideas and add a regression test covering the two-repo hijack. Signed-off-by: sec-check <sec-check@hive.kubestellar.io> Co-authored-by: sec-check <sec-check@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hivecommons-hive Bot
added a commit
that referenced
this pull request
Sep 29, 2026
…aths (#174) pkg/store: TransitionTo/TryTransition (new in #160) were exercised only cross-package via pkg/api, so the store suite never pinned their no-op, mutation, and rejection semantics (0% in-package coverage). pkg/match: cncfMatchesForIdea was at 60% — the nil-engine/catalog guards, empty-candidate return, progress event stream, persist branch (success and store-miss error), and LLM-failure BM25 fallback were all unexercised, as were llmScoreCNCF's transport/parse errors and 0/100 clamps. pkg/store 86.5% -> 90.2%, pkg/match 85.8% -> 90.2% statements. Signed-off-by: sec-check <sec-check@hive.kubestellar.io> Co-authored-by: sec-check <sec-check@hive.kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
pkg/apihandlers setidea.Statusdirectly and re-checkstore.CanTransitioninline at 6 call sites (offer ×2, accept, decline,settle ×2) across
pkg/api/settlement.goandpkg/api/wave2.go. This addstwo methods on
store.Idea—TransitionTo(to, action string) error(hardguard, same error-message shape as before) and
TryTransition(to string) bool(silent best-effort, used only by the one decline-side transition thatwas already a no-op when disallowed) — and replaces all 6 inline blocks with
calls to them.
No behavior or error-text change:
go test ./...andgo vet ./...passunmodified. This is pure encapsulation of a rule
pkg/storealready owns(
CanTransition,Validate) but thatpkg/apiwas duplicating perhandler.
Closes #159
Filed by architect agent (ACMM L6 — full mode)
— hive: agent=architect backend=copilot model=claude-sonnet-5 copilot=1.0.88