This repository was archived by the owner on Sep 2, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 2, 2026. It is now read-only.
[Spec] Stage derivation engine #22
Copy link
Copy link
Closed
Labels
ready-for-agentready-for-agent
Description
Part of the wayfinder map. Decisions: #3, #4, #5, #6, #19.
Blocked by: #21.
Problem Statement
A feature's stage must reflect reality without anyone hand-maintaining it: an open PR means review, a merged PR means shipped, a closed PR means trouble. But stages are also declared by the user or an agent (idea, implementing), and the two sources disagree all the time. Today there is no single rule that reconciles them, and no guard against the engine being hard-wired to GitHub.
Solution
One pure derivation engine, run on reads and on fact events, with one neutral fact-source interface:
- Facts across the whole task tree (root + children), most-recent activity wins: any open PR →
review; all merged →shipped; a closed PR →triage; an open spec issue →spec(only from idea/exploring/unstaged — never regresses a card out ofimplementing); otherwise the declared stage applies. - A merged PR ships a card once: after a human de-ships, that same merge does not re-push it; only new facts re-drive it.
- Folder workspaces: manual regime — no fact derivation at all.
- Facts arrive through a source abstraction so GitHub is one implementation, not the engine's assumption.
User Stories
- As a user, I want an open PR anywhere in the task tree to move the card to
review, so that review state appears without any manual step. - As a user, I want all merged PRs to move the card to
shipped, so that delivery is automatic. - As a user, I want a closed (unmerged) PR to move the card to
triage, so that contradictions surface instead of silently sitting. - As a user, I want an open spec issue to move the card to
specwhen it is still in idea/exploring/unstaged, so that speccing shows up immediately. - As a user, I want a card that has reached
implementingto stay there even while its spec issue remains open, so that an old open issue doesn't pull finished work backwards. - As a user, I want a new PR on an already-shipped feature (a regression fix) to bring the card back to
review, so that follow-up work is visible on the board. - As a user, I want my declared stages (idea, exploring, implementing, review) to apply whenever no fact governs, so that I can still steer the board.
- As a user, I want to de-ship a card without the old merged PR instantly re-shipping it, so that reopening a feature works.
- As a user, I want only new facts to move a de-shipped card again, so that the board doesn't fight me.
- As a user, I want folder workspaces never fact-moved, so that manual work stays manual.
- As a user, I want derivation results computed the same way on the desktop, via RPC, and for remote workspaces, so that every surface agrees.
- As a maintainer, I want the fact source behind an abstraction, so that a non-GitHub tracker can be added without rewriting the engine.
Implementation Decisions
- Pure functions over plain inputs (task tree, per-worktree PR/issue facts, declared stage) → effective stage. No I/O inside the engine.
- Most-recent-wins precedence: open PR > merged > closed; spec issue only from idea/exploring/unstaged; declared stage as fallback.
- "Shipped once per merged PR" rule: a merge ships the card; after a human de-ship, the same merge is consumed and only new facts re-drive. Implemented as a consumed-fact guard, not a timestamp game.
- Fact source interface: neutral shape (issue state, PR states per worktree); the GitHub implementation queries through the existing GitHub machinery. Non-GitHub sources are a future implementation of the same interface.
- Derivation runs at read time (board/sidebar projection) and on fact events (PR refresh events, board open); writes only declared stages, never fact-derived ones (facts are computed, not stored).
- Remote workspaces: same engine, facts resolved client-side.
Testing Decisions
- Test external behavior via the pure engine: given facts + declared stage, the effective stage is X. Cover: precedence chains, regression-on-shipped, de-ship consumption, spec-from-idea-only, closed-PR triage, folder skip.
- Seams: the pure derivation module (one seam) and the fact-source interface (one mock source in tests).
- Prior art: none in Orca (new engine) — follow the pure-reducer style used by the shared workspace-status helpers.
Out of Scope
- Authority gates: who is allowed to declare which stage (spec 3).
- Where the stage is stored and the two-board model (spec 1).
- Board UI rendering of stages (spec 4).
- Auto-archive timing (spec 6) — the engine only decides the stage.
Further Notes
- The engine must never derive
implementingfrom a fact. - The "consumed merge" guard is what makes de-shipping stable; without it, derived
shippedwould reassert on every read. - Keep the engine's inputs serializable so a future sync (spec 9) can reproduce derivations on any machine.
Metadata
Metadata
Assignees
Labels
ready-for-agentready-for-agent
Activity
Spec #22: stage derivation engine (placeholder)
Merge pull request #57 from 64ix/spec/22-stage-derivation