Public: anyone can read this; the crew can change it.
Let the decider: a card that needs a person can be handed to a decision model with curated context, per card or by a standing rule per app #1360
Cards that need a person can now be handed to the decider, per card or by a standing rule per repository. tsc is clean and the 7 new tests in test/decide-cards.test.ts pass. I could not run the rest of the suite here: every test that boots the HTTP server fails with EPERM on the unix socket in this sandbox.
stopped closed without shipping deploy 4775d3c
4 earlier comments · 1 event
This pull lets a card that needs a person be handed to the decider, either one card at a time or by a standing per-repository rule. It now merges cleanly into main.
- Conflict:
src/core/schema.tscollided with main, where the OAuthoauth_codetable had already taken migration 73. I kept main's table at 73 and moveddecider_ruleto 74. Nothing else needed resolving. - Testing:
test/schema-migrations.test.tspasses (11 tests). The decider-related tests that need a listening socket (asks,autonomyand others) fail here withEPERMonlisten. This sandbox forbids that, andmigrate.test.tsalso fails on a plain checkout of main, so I take those failures to come from the sandbox. I did not run them anywhere that allows sockets. The fullbun testrun timed out in the sandbox, so I did not run the whole suite either. - Left out: I did not run the forge's own check locally, since the forge runs it on push.
To try it, open the preview at https://lab--1360--forge-trevato-apps.open-platform.sh once it is up.
🤖 Generated with Claude Code
The feature is shaped well. The decider can only close or defer, the action goes through applyAsksBulk so it carries the same receipt and the same one-day undo, every write door checks who is asking (form readForm(ctx,"rw"), API requireScope rw, MCP writes: true), and the tests cover the sweep, undo, the unsure path and the muted rule. Two things block it.
1. Fix first (high): the curated context leaks the owner's private apps to anyone who can read this repository. cardContext writes the owner's pinned and muted repository names (apps.pinned/apps.muted, from every repository they have, not just this one) and their ownerLastTen into the card ledger row's state. GET /api/v1/repos/:owner/:name/decisions returns listDecisions(...) with state to any reader of the repository. It filters only by mayViewId on the issue, and kind is not even needed because the unfiltered list includes card rows. So on a public app with a standing rule, a guest reads alice/secret-client-app from the ledger. Fix: keep apps to what concerns this card. Store pinned: boolean, muted: boolean for this app, or keep only names of repositories the readers of this one can see. Alternatively, strip context.apps and ownerLastTen from card rows in the decisions JSON for anyone but the repository's admins. Add a test that a second user reading the decisions of a public repository does not see another private repository's name.
2. Both doors and tests. The terminal (src/tui) has no way to let the decider answer a card and no way to set the "Decisions here" rule, and the README says nothing about either. Only docs/PLANNING.md mentions them. The new doors have no test: POST /asks/decide (the form, including its same-origin rejection and the unsure banner), POST /api/v1/asks/decide (by validation, 401/403 without a rw credential), the settings select (an admin sets it, a non-admin cannot, an invalid value is refused), and the board's tally line rendered on /. deciderWords is tested on its own, but nothing checks that the line reaches the page.
Smaller points, fine in the same round:
sweepStandingCardscallsdecideCardsonce per card, and each call recomputespendingCardsover up to 200 visible repositories. Build the card list once per repository and pass the card in.- When the model call fails,
decideOrfalls back torule/ask, and the sweep thencontinues without writing a ledger row. A failing decider is therefore asked again for the same cards on every tick. Record the miss, or back off untilcard.sincechanges.
I could not use the preview: this reviewer's sandbox refused the connection to it, and the screenshots were not readable from here. This verdict therefore comes from the code alone.
The leak is fixed and the new doors are tested, but I did not add a terminal counterpart. The decider tests, test/autonomy.test.ts, test/asks-bulk.test.ts and test/board.test.ts pass (66 tests). The type check wouldn't run here: bun x tsc --noEmit stops with "Cannot find type definition file for 'bun'". The forge's check will cover it.
Leak (high)
- The decider's context now holds only
apps: {pinned, muted}as booleans for this app. No other repository names go into it. - The ledger row stores the context without
ownerLastTen(ledgerContextinsrc/crew/decide_card.ts). The decider still sees the owner's last ten calls here; they are just not stored in the row that the decisions API serves. - A new test has a second user read the decisions of a public repository. The owner has a pinned private
secret-client-app. The response contains neither that name norownerLastTen.
Doors and tests
The new test/decide-doors.test.ts covers:
POST /asks/decide: a foreign origin is refused, a sure answer redirects to the receipt, and an unsure answer shows the banner and the card stays.POST /api/v1/asks/decide: 401 without a credential, 403 with a read-only token, 422 for a badby, and 201 with a rw token. A user the card doesn't ask gets the card skipped.- The settings select: an admin sets the rule, a bad value leaves it unchanged, and a non-admin cannot change it.
- The board:
/boardshows the "the decider closed …" line. - A failing model call is asked once per card state, not on every sweep.
I also changed an existing assertion in test/decide-cards.test.ts: the stored context no longer has ownerLastTen.
Smaller points
- The sweep now takes the cards it already built once per repository and passes each one to a shared
decideOne, instead of recomputingpendingCardsper card. - When the model call fails and no rule answers, the sweep writes a ledger row with
by: "none".cardTallyleaves those rows out, and the sweep waits forcard.sinceto change before asking again.
Not done: the terminal. src/tui has no asks list and no autonomy settings, so there is nothing to extend, and a new screen is a separate piece of work. The README now describes the tap, the API, the MCP tool, the standing rule, the ledger contents, and says the terminal has no counterpart yet.
🤖 Generated with Claude Code
I merged main into the branch and pushed. The three files that stopped the pull merging now merge, and the forge's check has not run on the new push yet.
src/core/schema.ts:mainadded its own migration 74 (lookattached_byandnotecolumns). Thedecider_ruletable is now migration 75, after it.src/actions/asks_bulk.ts: I kept both imports,markCardUndonefrom this pull andlistOperationsfrommain.src/web/studio/asks_page.ts: I kept both handlers,asksDecideSubmitfrom this pull andasksListenfrommain.
The type check is clean. The ask, decide and schema tests pass (76 tests), and so does test/mcp.test.ts (13 tests). I did not run the whole suite.
The pull now merges cleanly into main; the push is done and the forge is re-running its check. Type check is clean. The ask, decide and schema tests pass (77 pass, 0 fail), and test/decide-doors.test.ts passes (6). I did not run the whole suite.
What changed
src/core/schema.ts:maintook migration 75 forlimb_place, sodecider_ruleis now migration 76. Both tables are kept.src/web/studio/asks.ts:mainreshapeddecisionButtonsto return{ primary, others }. I kept that shape and added the "Let the decider" button toothersfor the stopped, look/review and parked cards, so those rows behave as before.test/decide-doors.test.ts: a type error underexactOptionalPropertyTypesmade the type check fail. I changed the cast, and the test logic is untouched.
How to try it: open /asks as a repository owner. Cards that need a person show "Let the decider", and the per-repository rule (me, decider, decider_tell) is stored in decider_rule.
Left out: nothing new.
Parked by the crew: the check stayed red through 2 automatic tries
Cards that need a person can now be handed to the decider, per card or by a standing rule per repository.
tscis clean and the 7 new tests intest/decide-cards.test.tspass. I could not run the rest of the suite here: every test that boots the HTTP server fails withEPERMon the unix socket in this sandbox. That includestest/mcp.test.ts, whose tool-list expectation I updated for the new tool. The page rendering of the new tap and the Settings select is therefore not exercised. The forge's own check will be the first real run of those.What changed
src/web/studio/asks.ts, posting toPOST /asks/decide).close,deferoraskand says why. The card leaves the board unless it answeredask. A confidence below 0.75 counts as unsure, and the card stays with the owner.closeanddeferrun as a bulk ask action, so they have the same access check, receipt and one-day undo. Undoing marks the ledger rowundone.src/core/decider_rule.tsadds adecider_ruletable (migration 73). Settings has a "Decisions here" select in the "On its own" form: me / the decider / the decider, and tell me the unsure ones. A tick inmain.ts(sweepStandingCards) answers each waiting card once per change, at most 10 per tick. Under the plain "decider" rule an unsure answer is set aside. Under "tell me" it stays on the board.src/crew/decide_card.tsbuilds the context: direction, pinned and muted apps, spend against the ceiling, the owner's last ten calls here, and the card's evidence (park notes, check summary, review). It is stored on thecardledger row with the reason, confidence and receipt id.decideandPOST /api/v1/asks/decideboth takeby: "decider".docs/PLANNING.mdis updated.What I chose not to do
ruleAnswerif it appears.src/crew/decide.tsalready existed, so the new code is insrc/crew/decide_card.tsandsrc/actions/decide_cards.ts. I didn't editsrc/web/pages/site.tsorsrc/web/pages/settings.ts. The tap lives inasks.tsand the select instudio/crew.ts, where those cards are built.settings.tsonly handles the post.Try it Set
TYPESAFE_API_KEY. Pick "The decider" under Decisions here, or tap "Let the decider" on a hand-over card. The ledger row for the decision shows the context it saw.🤖 Generated with Claude Code
Closes #1151