Public: anyone can read this; the crew can change it.

A run shows which account it took and why, and Settings shows each account's place in the order #17837

opened this

Merged 4h 7m ago, live in production

A crew run now records which account it took, its place in the order, and why. Settings and the terminal number each account by that same order. It's pushed, but the full-suite check hasn't run yet.

Notes

opened this

A crew run now records which account it took, its place in the order, and why. Settings and the terminal number each account by that same order. It's pushed, but the full-suite check hasn't run yet.

What changed

  • pickSubscription in src/core/subscriptions.ts returns an order for the picked account: its place, how many accounts were in the order, and each account passed over with the reason. A resting account reads "resting: <provider's words>", a spent one "its $N budget is spent", a full plan "its weekly window is full for the crew".
  • settleSpend writes one log line from it, for example account: second, 2nd of 2 in order: first passed over (resting: usage cap reached). A run that took the first account in order says first in order. The wording is in the new src/crew/account_choice.ts.
  • The run page shows that line as "Account", under the run's facts. The terminal run view shows it as Account:. Both show it only to someone who may read the log, so account names don't reach people who can't see the log.
  • Settings → Subscriptions and the terminal's Crew subscriptions screen number each account by its place (accountPlaces: an admin's rank first, a plan before a key, then name).
  • docs/features/crew-accounts.md has a how-to section.

Tests: test/account-choice.test.ts has a run that skipped account 1 for a cap ("usage cap reached") and names it as the reason. It also covers the first-in-order case, the Settings places and the ordinals. That test and about ten related suites pass, and so does tsc. A first gate run (before the rewrap commit) flagged accountPlaces, which the gate says is 0.65 like readLevels in src/flow/valve_store.ts; I read it as a false positive, since the two do different things.

Not done

  • The line is stored in the run's log, not in a new database column. Runs made before this show nothing.
  • The place shown in Settings is the static order; it doesn't account for per-repository grants or which accounts a given run could reach.
  • I didn't add a test that renders the run page itself; the log line and the Settings places are tested directly.
  • The commit lines say No look: and No door: because no page in app.looks shows these two pages, and the doors are runlog.ts and subscriptions.ts.

Try: open a crew run's page on the preview and read the Account line. Then open /settings/subscriptions and read each account's "Nth in order".

[
  {"go": "/settings/subscriptions", "look": "each account's title row", "expect": "a small 'Nth in order' next to the name, 1st for the first account a run tries"},
  {"go": "a crew run's page, /<owner>/<name>/runs/<id>", "look": "under the run's facts", "expect": "an 'Account: <name>, Nth of M in order: …' line, naming what was passed over and why; absent on runs made before this change"}
]

Closes #17828

2 earlier comments
commented

A crew run now records which account it took, its place in the order, and why. Settings and the terminal number each account by that same order. It's pushed, but the full-suite check hasn't run yet.

What changed

  • pickSubscription in src/core/subscriptions.ts returns an order for the picked account: its place, how many accounts were in the order, and each account passed over with the reason. A resting account reads "resting: <provider's words>", a spent one "its $N budget is spent", a full plan "its weekly window is full for the crew".
  • settleSpend writes one log line from it, for example account: second, 2nd of 2 in order: first passed over (resting: usage cap reached). A run that took the first account in order says first in order. The wording is in the new src/crew/account_choice.ts.
  • The run page shows that line as "Account", under the run's facts. The terminal run view shows it as Account:. Both show it only to someone who may read the log, so account names don't reach people who can't see the log.
  • Settings → Subscriptions and the terminal's Crew subscriptions screen number each account by its place (accountPlaces: an admin's rank first, a plan before a key, then name).
  • docs/features/crew-accounts.md has a how-to section.

Tests: test/account-choice.test.ts has a run that skipped account 1 for a cap ("usage cap reached") and names it as the reason. It also covers the first-in-order case, the Settings places and the ordinals. That test and about ten related suites pass, and so does tsc. A first gate run (before the rewrap commit) flagged accountPlaces, which the gate says is 0.65 like readLevels in src/flow/valve_store.ts; I read it as a false positive, since the two do different things.

Not done

  • The line is stored in the run's log, not in a new database column. Runs made before this show nothing.
  • The place shown in Settings is the static order; it doesn't account for per-repository grants or which accounts a given run could reach.
  • I didn't add a test that renders the run page itself; the log line and the Settings places are tested directly.
  • The commit lines say No look: and No door: because no page in app.looks shows these two pages, and the doors are runlog.ts and subscriptions.ts.

Try: open a crew run's page on the preview and read the Account line. Then open /settings/subscriptions and read each account's "Nth in order".

[
  {"go": "/settings/subscriptions", "look": "each account's title row", "expect": "a small 'Nth in order' next to the name, 1st for the first account a run tries"},
  {"go": "a crew run's page, /<owner>/<name>/runs/<id>", "look": "under the run's facts", "expect": "an 'Account: <name>, Nth of M in order: …' line, naming what was passed over and why; absent on runs made before this change"}
]
commented

I fixed the failing check by updating one stale test assertion, and I've pushed the fix. test/run-steps.test.ts now passes: 34 tests, 0 failures. I did not run bun x tsc --noEmit or the rest of the suite.

The test "a granted account > is the account the run works on, noted on the run and the meter" expected only "subscription: work plan". This pull makes a run also note which account it took and its place in the order, so it now reports a second line, "account: work plan, 1st of 1 in order: first in order". The test was wrong, not the code. I added that line to the expected list.

  • Gate: the --fix run changed nothing. It still notes four files with comment lines over 100 columns and leaves the rewrap to the nightly run. It also flags accountPlaces in src/core/subscriptions.ts as similar to readLevels in src/flow/valve_store.ts. I left both alone.
  • Commit: it carries No door: test-only change.
commented

A run now shows which account it took, its place in the order and why, and Settings numbers each account in the forge's order. I ran the three affected test files (account-choice, run-page-links, run-steps), tsc, the design lint and the dead-code tests. All pass. The account-choice and run-page-links tests are the new ones. I haven't looked at the preview myself, so box 1 is still unseen there.

Changes

  • Fact row. runFacts takes an account input and emits an "Account" fact. The run page draws it in the dl with the other facts, and the terminal prints it as Account: … from the same fact. I removed the muted #run-account div and the extra terminal line. A viewer who may not read the log gets no account fact.
  • Tests.
    • The run page for a log holding an account line shows <dt>Account</dt> to a writer.
    • The same page, fetched by a stranger who may read the run but not its log, has neither the fact nor the cap text.
    • The terminal run view prints Account:.
    • The Settings page shows "1st in the forge's order" and "2nd in the forge's order".

    Each asserts something that wasn't there before. I didn't revert the change to watch them fail.

  • Order, option 1. Settings' number is now labelled "Nth in the forge's order", with the unread data-place hook removed. accountPlaces is documented as the forge-wide order that a run's place narrows to what it can reach. I did not merge the two into one ordering function. A run's order depends on the repository, the scope tier, last use and the crew fallback, so a single shared order would be wrong for one side. If you want the shared function anyway, say so.
  • Passed list. A new passedInOrder builds it in the order the pick tries accounts. A full-window plan stands where the reach list put it, not ahead of the resting ones. I did not add a test for a full-window plan sitting between accounts, so that case is untested.
  • Terminal. An account with no place shows its plain name, with no - prefix.
  • Docs and commit. docs/features/crew-accounts.md is updated, and the commit has a Direction: … (#17828) line.

The gate still notes four files with comment lines over 100 columns, and it left the rewrap to the nightly run. It also still flags the accountPlaces / readLevels similarity, which I read as a false positive.

[
  {"go": "/<owner>/<repo>/runs/<a crew run's id>", "look": "the run's facts list, as a person who may read its log", "expect": "an \"Account\" row with the same label style as Branch and Started, reading e.g. \"work plan, 2nd of 3 in order: first passed over (resting: usage cap reached)\""},
  {"go": "/<owner>/<repo>/runs/<the same run>", "look": "the facts list while signed out, on a public repository", "expect": "no Account row and no account words anywhere on the page", "ask": "Is hiding it from non-readers of the log what you want?"},
  {"go": "/settings/subscriptions", "look": "each account's name", "expect": "a small muted \"1st in the forge's order\", \"2nd …\" beside each account"}
]
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs