feat(github): close and reopen stories from Facility - #180
Open
prubianes wants to merge 1 commit into
Open
Conversation
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.
feat(github): close and reopen stories from Facility
Closes #102.
What changed
Adds:
POST /v1/projects/:projectId/stories/:number/closePOST /v1/projects/:projectId/stories/:number/reopenBoth routes are gated by
repos:write, acceptIdempotency-Key, and emitstory.closed/story.reopenedaudit events.Closing a story now:
state_reason;Reopen is intentionally minimal: it reopens the issue, updates the mirror, and records the audit event without adding another comment.
In the web app, the story page gains a
Close storyaction for issue stories — a required reason and acompleted/not plannedchoice — which becomes a one-clickReopen storyonce the story is closed. Both are shown only to principals holdingrepos:write.Decisions
state_reasondefaults tonot_planned. This endpoint represents the abandon / won't-do path. Completed work normally closes through a merged pull request, where GitHub already records the issue as completed. Usingnot_plannedby default keeps the API and UI semantics aligned with that workflow.repos:write, not a new permission. #102 asked for this to be settled explicitly.issues:writegoverns platform watchtower issues, a different concept, while this verb mutates a connected repository in the same way as the pull-request link routes.A direct verb, not a HITL proposal. As proposed in the issue, the human closing the story is already the gate.
GitHub remains the source of truth. The local mirror is updated only after the GitHub mutation succeeds. This departs from the issue's suggested optimistic mirror update: waiting for GitHub's response ensures the mirror cannot claim a close that did not happen.
Retries are safe. If the closing-reason comment is written but the state transition fails, a retry updates the marked comment instead of posting a duplicate. If the issue is already closed on GitHub, Facility reconciles the mirror and returns
changed: false.Known limitation
Stories closed as
not_plannedstill appear under theShippedpipeline stage for seven days because the mirror does not currently store GitHub'sstate_reason. That requires a separate schema / classification change and is intentionally out of scope here.Verification
pnpm --filter @facility/api test— 478 passed, 1 skipped (Docker-backed sandbox E2E)pnpm --filter @facility/web test— 66 passedpnpm --filter @facility/sdk test— 23 passed (route manifest and committed-contract drift guards)pnpm lint,pnpm typecheck,pnpm build:clean— cleanpnpm guards— 2 guards, 0 failedpackages/sdk/openapi.jsonandsrc/schema.d.tsregenerated withpnpm --filter @facility/api openapipnpm verifyis currently blocked by a pre-existing timing flake inrunner/test/workspace.test.ts(.facility-hang.pidnot written within the 100 ms deadline). I reproduced the same failure with this change fully stashed, while the affected test file passes standalone.