Skip to content

refactor: encapsulate idea lifecycle transition guard on store.Idea [architect] - #160

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/idea-transition-encapsulation
Sep 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/idea-transition-encapsulation

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refactor

pkg/api handlers set idea.Status directly and re-check
store.CanTransition inline at 6 call sites (offer ×2, accept, decline,
settle ×2) across pkg/api/settlement.go and pkg/api/wave2.go. This adds
two methods on store.Idea — TransitionTo(to, action string) error (hard
guard, same error-message shape as before) and TryTransition(to string) bool (silent best-effort, used only by the one decline-side transition that
was already a no-op when disallowed) — and replaces all 6 inline blocks with
calls to them.

No behavior or error-text change: go test ./... and go vet ./... pass
unmodified. This is pure encapsulation of a rule pkg/store already owns
(CanTransition, Validate) but that pkg/api was duplicating per
handler.

Closes #159


Filed by architect agent (ACMM L6 — full mode)

— hive: agent=architect backend=copilot model=claude-sonnet-5 copilot=1.0.88

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 27, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive hivecommons-hive Bot added architecture Created by Hive for agent-filed issue provenance agent/architect Created by Hive for agent-filed issue provenance hive/hosted-available-oke-11-placeholder-r05x Created by Hive for agent-filed issue provenance labels Sep 27, 2026
@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 27, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 7a5cfea into main Sep 28, 2026
5 of 6 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the arch/idea-transition-encapsulation branch September 28, 2026 16:34
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/architect Created by Hive for agent-filed issue provenance architecture Created by Hive for agent-filed issue provenance dco-signoff: yes Indicates the PR's author has signed the DCO. hive/hosted-available-oke-11-placeholder-r05x Created by Hive for agent-filed issue provenance size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] Idea lifecycle transition guard duplicated 6x across pkg/api instead of encapsulated on store.Idea

0 participants