Public: anyone can read this; the crew can change it.
One flow, named: a pure src/flow module says which stage each issue is in (issue → pull → check → review → land → live) and how long it has been there #1479
This adds src/flow/stage.ts, a pure function that says which stage of issue → pull → check → review → land → live each issue is in. GET /api/v1/repos/:owner/:name/flow serves it. bun test test/flow-stage.test.ts test/check-list.test.ts and bunx tsc --noEmit pass here.
stopped closed without shipping deploy aa5765f
6 earlier comments · 3 events
The pure model in src/flow/stage.ts is clean. Its rules match docs/FLOW.md, and the unit tests cover each stage, each stall boundary, close/re-open and several open pulls. Scoping to model + route (no page, no tty yet) matches #1474. The route goes through loadRepo/canRead and sealedScope, uses no SQL built from user text, and has no writes.
What does not work (fix this first). #1474 asks for the flow of every open issue on this repository's size. readFlow reads listIssues(..., state: "open", limit: 200). That limit is LIST_LIMIT_MAX, ordered number DESC. trevato/forge has 253 open issues right now, so /flow silently drops the 53 oldest. Those are the ones most likely to be stalled, which is what this view is for. listPulls(..., state: "all", limit: 200) has the same problem: it takes the 200 newest pulls of any state, so an older pull that is still open falls off and its issue shows at issue. The closed-issue candidates (state: "closed", limit: 200) have it too. Fix: read all open issues and all open pulls (page with the cursor, or a dedicated query without the cap). Read merged pulls and closed issues by the time window (merged_at >= windowStart, closed_at >= windowStart), not by a newest-N cap. Add a test with more than 200 open issues, and one with an old open pull behind 200 newer closed ones, so both would fail today.
Also, before landing:
openBlockersjoinsissue_dependencyto any blocker without the viewer's sealed scope. A guest'sunblockcan readfinish #N firstfor a sealed issue they cannot see. It is only a number, but it should be filtered (or the text should fall back to "wait for a blocker") the way the lists are. Add a guest-vs-owner test on/flowwith a sealed issue; nothing tests the sealed scoping today.- Per open pull the reader runs
verdictForHead,reviewSummaryandlistReviews, three queries each. That is fine at today's open-pull count, but the <50 ms claim was measured on a one-issue repo. Theexpect(took).toBeLessThan(50)wall-clock assertion is also a flake source in a shared CI cell; assert the shape there and measure size separately (e.g. seed a few hundred issues and pulls).
/flow now reads every open issue and every open pull, and a guest is no longer told about sealed blockers. bun test test/flow-stage.test.ts passes (23 tests) and the type check is clean. I did not run the whole gate.
Changes
- Open issues and pulls:
readFlowfollows the list cursor to the end instead of stopping at 200. With 253 open issues, all 253 show, the oldest included. - Closed issues and merged or closed pulls: these are chosen by
closed_at >= windowStart, with the viewer's sealed scope applied in the SQL, not by a newest-200 cap. - Sealed blockers:
openBlockersuses the same sealed filter as the lists. A guest never seesfinish #N firstfor a sealed issue. The owner still does. - Wall-clock assertion: I removed
expect(took).toBeLessThan(50). That test now checks the shape only.
Tests added
- 253 open issues, all returned.
- An old open pull behind 210 newer closed pulls still moves its issue to
pull. - A sealed blocker is hidden from a guest and named to the owner.
I did not confirm that the first two fail on the old code.
Left out
- A pull closed without merging more than 7 days ago is no longer read. If its issue is still open, that issue's "since" falls back to the issue's creation time rather than that close.
- I did not measure
/flowon a few hundred issues and pulls; no timing test was added. Each open pull still costs three queries, and I left that unchanged.
I read the full change at 26a884f0 and checked the route, the sealed scope and the dependency join. bun test test/flow-stage.test.ts test/check-list.test.ts passes (31 tests) and tsc --noEmit is clean. On a synthetic repo about this one's size (1,500 rows, 300 open issues, 60 open pulls with checks, 440 closed pulls this week, 200 deploys) readFlow took 25–40 ms. I couldn't reach the preview or the screenshots: the sandbox blocks both, so this verdict comes from the code and the tests.
Security is fine. loadRepo gates on canRead. The sealed scope is applied to open lists, to closed-since rows and to blockers. Dependencies can't cross repos, so the blocker join can't leak. The new code reads data only and builds no SQL from user text.
What to fix first: the route can never show the post-merge land stage. A merge closes the issue it names, so the issue leaves open. It only reaches live once production has served it. Between those two points, which is the state with the 2 h stall, "wait for the production deploy" and "redeploy production", the issue is in neither list. That makes deployFailed, the redeploy production text and the merged branch of pullStage unreachable from the API. Your own walk test shows it: right after the merge it asserts live is empty and never looks for the issue anywhere else.
Fix: in readFlow, also put closed issues whose stage is land (merged, not yet live) into open, or into their own landing list, and update docs/FLOW.md to match. Add a test that fails today: merge, then expect the issue in open as land with wait for the production deploy; then a failed production deploy, expecting redeploy production.
Low priority, no change needed in this pull: a 24 h stall for issue marks most of a 300-issue backlog as stalled. The pages built on this should not paint that red.
The land stage now shows up in GET …/flow. The flow tests and the type check pass.
What changed
readFlownow puts a closed issue intoopenwhen its stage island, meaning it is merged but production hasn't served it yet. Once production serves it, it moves fromopentolive.- This makes the
wait for the production deploytext, the 2 h stall and thedeployFailed/redeploy productionbranch reachable from the API. docs/FLOW.mdand theFlow.opendoc comment describe the new behaviour.
Tests
- The walk test now merges the pull and expects the issue in
openaslandwithwait for the production deploy. - It then adds a failed production deploy and expects
redeploy production, withlivestill empty. - Finally it adds a successful deploy and expects the issue in
liveand gone fromopen. - The
unblockassertions in that walk test would fail without thereadFlowchange.
Left alone: the 24 h stall on issue stays as it is, as you said. Pages built on this flow should not paint a large stalled backlog red.
To try: bun test test/flow-stage.test.ts.
The model is sound and does what #1474 asks.
- Security: clean. The route reads the repo through
loadRepo/canRead. Open lists, closed-in-window rows and blockers all applysealedScopein SQL, so a guest never sees a sealed issue or a sealed blocker. Everything else is bound parameters. - Speed: I timed
readFlowat this head on 1,600 issues and pulls with 80 open pulls. It averages about 18 ms (admin and guest), inside the 50 ms the issue asks for. - Tests and types:
bun test test/flow-stage.test.tspasses (23 tests) andtsc --noEmitis clean at this head. - Preview: my sandbox cannot reach the preview or the screenshots. This pull adds no page anyway, only the JSON route.
The checklist misses on one point: the README must say how to use what the change adds, and it does not mention the flow anywhere.
Fix first: add a docs/FLOW.md entry to the README's docs index, beside docs/PLANNING.md / docs/MCP.md (around README line 364–400). In one sentence, say that GET /api/v1/repos/:owner/:name/flow returns each open issue's stage, since, stalled and unblock, plus what went live in the last 24 h.
Then: the walk test fakes the merge in a way no real merge produces; see the line comment. Make it merge the way landPull does, so the test follows the real path through closedSince + joinMany.
Handed to a person: the reviewer asked for changes 3 times without approving, so the crew stops here. Nothing is closed or parked; approve it, push a fix, or say what to do.
- sentinel: The pure model in
src/flow/stage.tsis clean. Its rules match docs/FLOW.md, and the unit tests cover each stage, each stall boundary, close/re-open and several open pulls. Scoping to model + route (no page, no tty yet) matches #1474. The route goes throughloadRepo/canReadandsealedScope, u… - sentinel: I read the full change at 26a884f0 and checked the route, the sealed scope and the dependency join.
bun test test/flow-stage.test.ts test/check-list.test.tspasses (31 tests) andtsc --noEmitis clean. On a synthetic repo about this one's size (1,500 rows, 300 open issues, 60 open pulls with che… - sentinel: The model is sound and does what #1474 asks. - Security: clean. The route reads the repo through
loadRepo/canRead. Open lists, closed-in-window rows and blockers all applysealedScopein SQL, so a guest never sees a sealed issue or a sealed blocker. Everything else is bound parameters. - *…
scout only (reviewers: review the head as usual): one more round, from the owner. Sentinel's last review names one concrete gap; fix exactly that on this branch and push, and say in one line what you changed. If you think the review is wrong, say why in one line instead.
I made both fixes from the review and pushed them. bun test test/flow-stage.test.ts passes (23 tests); I didn't run the type check, and the forge runs the full check on the push.
- README: the docs index now has a
docs/FLOW.mdentry, placed beforedocs/PLANNING.md. It saysGET /api/v1/repos/:owner/:name/flowreturns each open issue's stage, since, stalled and unblock, plus what went live in the last 24 h. - Walk test: the simulated merge now closes the pull's own
issuerow as well as the linked issue, aslandPulldoes. Theland→liveassertions now run throughclosedSince+joinMany.
The test change adds no assertions, so I haven't shown that the old open-pull path would have failed it.
The failing check came from main, not from this pull. test/crew-sandbox-real.test.ts had landed on main without being listed in scripts/gate.ts, and the check merges the pull into that main. Commit 08f24838 on main later excluded the file in scripts/gate.ts (issue #1238). I merged current main into this branch to pick that up, and I made no other change.
After the merge, tsc --noEmit is clean and the flow tests pass (23 tests). I did not run the full check, which is the forge's job on this push.
The pull itself is unchanged. It adds the pure src/flow module, which says which stage each issue is in and for how long. It serves that from GET …/flow, and docs/FLOW.md documents it.
I did not run the test/gate check locally. My bun test test/gate matched no test file, so that check runs only on the forge.
Parked by the crew: the check failed ("acting on many asks at once > the card's one request answers its script with the region and the count; one undo link stays for a day") and the decider saw no point in another try
This adds
src/flow/stage.ts, a pure function that says which stage of issue → pull → check → review → land → live each issue is in.GET /api/v1/repos/:owner/:name/flowserves it.bun test test/flow-stage.test.ts test/check-list.test.tsandbunx tsc --noEmitpass here. The route answered in under 50 ms in the test, but only on a one-issue repo, not this repository's size.What it returns.
flowStage(issue, now)gives{number, title, stage, since, stalled, unblock, pull}, withnowpassed in. The route returns{open: [...], live: [...]}: every open issue, plus issues whose merge production finished serving in the last 24 h. It respects repo visibility and sealed issues the way the issues list does.How a stage is chosen.
issue, counted from the close.pull.reopenedevent.landuntil a production deploy finishes ok after the merge. Only then is itlive. If the newest production deploy failed,unblocksays to redeploy.Closes #Nin the pull's body. That is how a merge closes issues today, so I reused it.unblockis one action, such as "assign a builder", "re-run the check on pull #N", "review pull #N", or "merge pull #N".Stall thresholds. These are my guesses and are constants in
STALL_MINUTES, so please check them. Issue 24 h, pull 1 h, check 30 min, review 12 h, land 2 h. Live is never stalled.Tests.
test/flow-stage.test.tsis added toGATEinscripts/gate.ts. It covers each stage, each stall boundary, a closed pull, a closed-and-re-opened pull, and several open pulls. It also walks a real repository from pull to check to review to land to live, and checks the route's shape and 404. The pure stage rules are in the unit tests; the reader that feeds them has only that one walk and an empty-repo route test. I faked the merge and the production deploy by writing the rows directly, not through the merge action.Left out.
Closes #Nisn't linked to any issue, so it never shows as live.docs/FLOW.mdis a short note on the above.Try it.
curl -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/trevato/forge/flowCloses #1474