@nanocollective/roster 0.1.0-alpha.8 → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.js +4084 -1936
  3. package/dist/worker/assets/assets/css/base.css +312 -0
  4. package/dist/worker/assets/assets/css/brain.css +116 -0
  5. package/dist/worker/assets/assets/css/diff.css +33 -0
  6. package/dist/worker/assets/assets/css/graph.css +39 -0
  7. package/dist/worker/assets/assets/css/health.css +75 -0
  8. package/dist/worker/assets/assets/css/home.css +101 -0
  9. package/dist/worker/assets/assets/css/inbox.css +199 -0
  10. package/dist/worker/assets/assets/css/layout.css +175 -0
  11. package/dist/worker/assets/assets/css/markdown.css +96 -0
  12. package/dist/worker/assets/assets/css/runs.css +13 -0
  13. package/dist/worker/assets/assets/css/search.css +48 -0
  14. package/dist/worker/assets/assets/css/setup.css +194 -0
  15. package/dist/worker/assets/assets/js/api.js +161 -0
  16. package/dist/worker/assets/assets/js/app.js +465 -0
  17. package/dist/worker/assets/assets/js/dialog.js +196 -0
  18. package/dist/worker/assets/assets/js/dom.js +131 -0
  19. package/dist/worker/assets/assets/js/homesort.js +174 -0
  20. package/dist/worker/assets/assets/js/icons.js +142 -0
  21. package/dist/worker/assets/assets/js/inflight.js +18 -0
  22. package/dist/worker/assets/assets/js/lightbox.js +273 -0
  23. package/dist/worker/assets/assets/js/md.js +406 -0
  24. package/dist/worker/assets/assets/js/mdedit.js +84 -0
  25. package/dist/worker/assets/assets/js/mention.js +264 -0
  26. package/dist/worker/assets/assets/js/readiness.js +70 -0
  27. package/dist/worker/assets/assets/js/refresh.js +197 -0
  28. package/dist/worker/assets/assets/js/router.js +20 -0
  29. package/dist/worker/assets/assets/js/search.js +366 -0
  30. package/dist/worker/assets/assets/js/state.js +213 -0
  31. package/dist/worker/assets/assets/js/textdiff.js +96 -0
  32. package/dist/worker/assets/assets/js/views/app.js +145 -0
  33. package/dist/worker/assets/assets/js/views/brain.js +260 -0
  34. package/dist/worker/assets/assets/js/views/changed.js +157 -0
  35. package/dist/worker/assets/assets/js/views/checklist.js +115 -0
  36. package/dist/worker/assets/assets/js/views/credential.js +84 -0
  37. package/dist/worker/assets/assets/js/views/docs.js +174 -0
  38. package/dist/worker/assets/assets/js/views/files.js +139 -0
  39. package/dist/worker/assets/assets/js/views/graph.js +436 -0
  40. package/dist/worker/assets/assets/js/views/health.js +304 -0
  41. package/dist/worker/assets/assets/js/views/hire.js +593 -0
  42. package/dist/worker/assets/assets/js/views/home.js +585 -0
  43. package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
  44. package/dist/worker/assets/assets/js/views/memory.js +150 -0
  45. package/dist/worker/assets/assets/js/views/org.js +195 -0
  46. package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
  47. package/dist/worker/assets/assets/js/views/paste.js +216 -0
  48. package/dist/worker/assets/assets/js/views/prompt.js +457 -0
  49. package/dist/worker/assets/assets/js/views/repos.js +97 -0
  50. package/dist/worker/assets/assets/js/views/runonce.js +94 -0
  51. package/dist/worker/assets/assets/js/views/runs.js +182 -0
  52. package/dist/worker/assets/assets/js/views/setup.js +557 -0
  53. package/dist/worker/assets/assets/js/views/staff.js +291 -0
  54. package/dist/worker/assets/assets/js/views/todo.js +62 -0
  55. package/dist/worker/assets/assets/js/yaml.js +134 -0
  56. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  57. package/dist/worker/assets/docs-images/home.jpg +0 -0
  58. package/dist/worker/assets/docs-images/org.jpg +0 -0
  59. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  60. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  61. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  62. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  63. package/dist/worker/assets/index.html +82 -0
  64. package/dist/worker/index.js +4430 -0
  65. package/docs/README.md +2 -2
  66. package/docs/architecture.md +1 -1
  67. package/docs/charters/analyst.md +65 -0
  68. package/docs/charters/community.md +63 -0
  69. package/docs/charters/designer.md +65 -0
  70. package/docs/charters/devops.md +65 -0
  71. package/docs/charters/pm.md +70 -0
  72. package/docs/charters/qa.md +65 -0
  73. package/docs/charters/writer.md +63 -0
  74. package/docs/commands.md +13 -3
  75. package/docs/concepts.md +33 -20
  76. package/docs/cost.md +3 -3
  77. package/docs/developing.md +27 -9
  78. package/docs/doctor-codes.md +3 -1
  79. package/docs/export.md +2 -0
  80. package/docs/getting-started.md +44 -27
  81. package/docs/hosting.md +89 -43
  82. package/docs/images/brain.jpg +0 -0
  83. package/docs/images/home.jpg +0 -0
  84. package/docs/images/org.jpg +0 -0
  85. package/docs/images/prompt.jpg +0 -0
  86. package/docs/images/staff.jpg +0 -0
  87. package/docs/manual-steps.md +3 -2
  88. package/docs/org-yaml.md +3 -0
  89. package/docs/portal.md +143 -45
  90. package/docs/prompts.md +6 -0
  91. package/docs/security.md +57 -11
  92. package/docs/session-workflow.md +14 -0
  93. package/docs/staff-yaml.md +17 -1
  94. package/docs/upgrading.md +3 -3
  95. package/docs/writing-a-charter.md +19 -6
  96. package/package.json +4 -3
  97. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
  98. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
  99. package/templates/brain/staff.yaml +4 -1
  100. package/templates/briefs/amend.md +4 -3
  101. package/templates/briefs/priorities.md +46 -0
  102. package/templates/ops/.github/workflows/session.yaml +137 -3
  103. package/templates/ops/compose.mjs +35 -8
  104. package/templates/ops/org/operating.md +29 -10
  105. package/templates/ops/prompts/daily.md +23 -4
  106. package/templates/ops/prompts/mention.md +19 -0
  107. package/templates/ops/run-record.mjs +5 -3
  108. package/templates/portal/css/base.css +34 -0
  109. package/templates/portal/css/health.css +14 -1
  110. package/templates/portal/css/home.css +101 -0
  111. package/templates/portal/css/inbox.css +21 -4
  112. package/templates/portal/css/layout.css +29 -3
  113. package/templates/portal/css/markdown.css +19 -0
  114. package/templates/portal/css/search.css +48 -0
  115. package/templates/portal/css/setup.css +79 -4
  116. package/templates/portal/index.html +15 -9
  117. package/templates/portal/js/api.js +30 -4
  118. package/templates/portal/js/app.js +90 -7
  119. package/templates/portal/js/dialog.js +36 -0
  120. package/templates/portal/js/homesort.js +174 -0
  121. package/templates/portal/js/icons.js +41 -0
  122. package/templates/portal/js/inflight.js +18 -0
  123. package/templates/portal/js/md.js +5 -2
  124. package/templates/portal/js/mdedit.js +84 -0
  125. package/templates/portal/js/readiness.js +70 -0
  126. package/templates/portal/js/refresh.js +10 -2
  127. package/templates/portal/js/search.js +366 -0
  128. package/templates/portal/js/state.js +11 -5
  129. package/templates/portal/js/views/app.js +1 -2
  130. package/templates/portal/js/views/brain.js +1 -1
  131. package/templates/portal/js/views/checklist.js +19 -4
  132. package/templates/portal/js/views/credential.js +42 -51
  133. package/templates/portal/js/views/health.js +11 -6
  134. package/templates/portal/js/views/hire.js +593 -0
  135. package/templates/portal/js/views/home.js +585 -0
  136. package/templates/portal/js/views/inbox.js +237 -68
  137. package/templates/portal/js/views/org.js +31 -111
  138. package/templates/portal/js/views/orgedit.js +240 -0
  139. package/templates/portal/js/views/paste.js +111 -66
  140. package/templates/portal/js/views/prompt.js +94 -40
  141. package/templates/portal/js/views/repos.js +10 -10
  142. package/templates/portal/js/views/runs.js +21 -4
  143. package/templates/portal/js/views/setup.js +130 -163
  144. package/templates/portal/js/views/staff.js +181 -301
  145. package/templates/portal/js/views/todo.js +62 -0
@@ -6,12 +6,25 @@ name: %%STAFF_UPPER%% daily run
6
6
  #
7
7
  # NOTE: %%TOKENS%% are filled by `roster hire`; GitHub's own ${{ }} are left alone.
8
8
 
9
+ # The trigger and the date, as the Actions list shows it. The daily limit counts follow-on runs
10
+ # by this name.
11
+ run-name: "%%STAFF%% ${{ github.event_name == 'schedule' && 'daily' || inputs.trigger || 'manual' }}"
12
+
9
13
  on:
10
14
  schedule:
11
15
  - cron: "%%SCHEDULE%%"
16
+ # By hand, from Run once now, or as a follow-on: a daily run that ended with the next step
17
+ # ready starts one more, up to max_runs_per_day.
12
18
  workflow_dispatch:
19
+ inputs:
20
+ trigger:
21
+ description: "manual | follow-on"
22
+ required: false
23
+ default: manual
24
+ type: string
13
25
 
14
- # A second run while one is in flight would fight it over the tracker and the branch state.
26
+ # A second run while one is in flight would fight it over the tracker and the branch state. A
27
+ # follow-on is started from inside the run before it, so it waits here until that one ends.
15
28
  concurrency:
16
29
  group: %%STAFF%%-session
17
30
  cancel-in-progress: false
@@ -21,13 +34,19 @@ jobs:
21
34
  # The ceiling on what session.yaml's job token may do: reading the checkout, and the one
22
35
  # comment that says a run failed when the App that would normally say so is what broke.
23
36
  # A called workflow cannot raise these, so they have to be granted here.
37
+ #
38
+ # `actions` is for the daily limit, which reads this repo's runs, and for starting a
39
+ # follow-on run, which the job token may do: a workflow_dispatch it sends still starts a run.
24
40
  permissions:
25
41
  contents: read
26
42
  issues: write
43
+ actions: write
27
44
  uses: %%OPS_REPO%%/.github/workflows/session.yaml@main
28
45
  with:
29
46
  staff: %%STAFF%%
30
47
  kind: daily
48
+ trigger: ${{ github.event_name == 'schedule' && 'daily' || inputs.trigger || 'manual' }}
49
+ max_runs_per_day: %%MAX_RUNS%%
31
50
  ops_repo: %%OPS_REPO%%
32
51
  model: %%MODEL%%
33
52
  timeout_minutes: %%TIMEOUT%%
@@ -3,11 +3,28 @@ name: %%STAFF_UPPER%% on a mention
3
3
  # Generated by roster. The body lives in %%OPS_REPO%%/.github/workflows/session.yaml.
4
4
  #
5
5
  # "%%MENTION%% ..." in a comment on this tracker, or in the body of a new issue, wakes a focused
6
- # run in about 30 seconds. It is a task, not a session: no boot ritual, no handoff, and the reply
6
+ # run in about 30 seconds. So does another staff member filing an issue here with their
7
+ # `from-<handle>` label. It is a task, not a session: no boot ritual, no handoff, and the reply
7
8
  # goes in the thread.
8
9
  #
9
10
  # NOTE: %%TOKENS%% are filled by `roster hire`. GitHub's own ${{ }} expressions are left alone.
10
11
 
12
+ # What the run is and what started it, as the Actions list shows it. The portal reads this back
13
+ # to link a live run to the request behind it, and the daily limit counts peer runs by it.
14
+ # Most events here are nobody asking (a comment without the mention, this staff member's own
15
+ # reply), and those are named `ignored`, so nothing reads one as work while it waits to be
16
+ # skipped.
17
+ run-name: >-
18
+ %%STAFF%% ${{
19
+ (contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.sender.login) &&
20
+ (contains(github.event.comment.body, '%%MENTION%%') ||
21
+ (github.event_name == 'issues' && contains(github.event.issue.body, '%%MENTION%%'))))
22
+ && 'mention'
23
+ || ((github.event_name == 'issues' && github.event.action == 'opened' &&
24
+ endsWith(github.event.sender.login, '[bot]') &&
25
+ github.event.sender.login != '%%APP%%[bot]') && 'peer' || 'ignored')
26
+ }} #${{ github.event.issue.number }}
27
+
11
28
  on:
12
29
  # A mention in the body of a brand new issue, which is often the faster route: one box, rather
13
30
  # than a "create, then comment" round trip. `edited` doubles as the way to re-ask without
@@ -22,12 +39,6 @@ on:
22
39
  issue_comment:
23
40
  types: [created, edited]
24
41
 
25
- # Per issue, not global. Several comments in a row are the normal case and a shared group would
26
- # silently drop all but one of them.
27
- concurrency:
28
- group: %%STAFF%%-mention-${{ github.event.issue.number }}
29
- cancel-in-progress: false
30
-
31
42
  jobs:
32
43
  answer:
33
44
  # Only a human this org answers to, only on a real mention. A bot quoting the phrase must
@@ -44,25 +55,54 @@ jobs:
44
55
  #
45
56
  # One spelling of the mention is enough: GitHub's `contains` is documented as not case
46
57
  # sensitive, so this already matches an uppercase mention at the start of a sentence.
58
+ #
59
+ # The second route is a peer's ask: a new issue opened by an App, never this staff member's
60
+ # own, carrying a `from-<handle>` label. Only `opened`, so the peer editing its own issue
61
+ # later wakes nobody. It names no peer, so a later hire needs no regenerated caller: the only
62
+ # accounts that can open an issue on a private tracker are the people and Apps it is
63
+ # installed for. A peer run may not file on another peer, and session.yaml holds peer runs
64
+ # to the day's limit, so two staff cannot wake each other forever.
65
+ # Per issue, not global: several comments in a row are the normal case, and a shared group
66
+ # would silently drop all but one of them. On the job rather than the workflow, so the
67
+ # condition below is decided first. At workflow level every event queued here, including
68
+ # this staff member's own replies, and GitHub keeps one waiting run per group, so a reply
69
+ # waiting to be skipped could knock out a real mention waiting behind a run.
70
+ concurrency:
71
+ group: %%STAFF%%-mention-${{ github.event.issue.number }}
72
+ cancel-in-progress: false
47
73
  if: >-
48
- contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.sender.login) &&
49
74
  (
50
- (github.event_name == 'issue_comment' &&
51
- contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.comment.user.login) &&
52
- contains(github.event.comment.body, '%%MENTION%%')) ||
53
- (github.event_name == 'issues' &&
54
- contains(github.event.issue.body, '%%MENTION%%'))
75
+ contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.sender.login) &&
76
+ (
77
+ (github.event_name == 'issue_comment' &&
78
+ contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.comment.user.login) &&
79
+ contains(github.event.comment.body, '%%MENTION%%')) ||
80
+ (github.event_name == 'issues' &&
81
+ contains(github.event.issue.body, '%%MENTION%%'))
82
+ )
83
+ ) || (
84
+ github.event_name == 'issues' && github.event.action == 'opened' &&
85
+ endsWith(github.event.sender.login, '[bot]') &&
86
+ github.event.sender.login != '%%APP%%[bot]' &&
87
+ contains(join(github.event.issue.labels.*.name, ','), 'from-')
55
88
  )
56
89
  # The ceiling on what session.yaml's job token may do: reading the checkout, and the one
57
90
  # comment that says a run failed when the App that would normally say so is what broke.
58
91
  # A called workflow cannot raise these, so they have to be granted here.
92
+ #
93
+ # `actions` is for the daily limit, which counts this repo's runs today. It is `write`
94
+ # because session.yaml's job asks for that (a daily run starts its follow-on with it), and a
95
+ # called job asking for more than its caller granted fails before it starts.
59
96
  permissions:
60
97
  contents: read
61
98
  issues: write
99
+ actions: write
62
100
  uses: %%OPS_REPO%%/.github/workflows/session.yaml@main
63
101
  with:
64
102
  staff: %%STAFF%%
65
103
  kind: mention
104
+ trigger: ${{ contains(fromJSON('%%HUMAN_LOGINS%%'), github.event.sender.login) && 'mention' || 'peer' }}
105
+ max_runs_per_day: %%MAX_RUNS%%
66
106
  ops_repo: %%OPS_REPO%%
67
107
  model: %%MODEL%%
68
108
  timeout_minutes: %%MENTION_TIMEOUT%%
@@ -13,6 +13,9 @@ schedule: "%%SCHEDULE%%"
13
13
  model: %%MODEL%%
14
14
  timeout_minutes: %%TIMEOUT%%
15
15
  mention_timeout_minutes: %%MENTION_TIMEOUT%%
16
+ # Runs a day that start without a person asking: a peer's ask, or a follow-on to a daily run.
17
+ # Mentions never count against it.
18
+ max_runs_per_day: %%MAX_RUNS%%
16
19
 
17
20
  bot: %%APP%%[bot]
18
21
  public_bot: %%PUBLIC_APP%%[bot]
@@ -40,4 +43,4 @@ surfaces:
40
43
 
41
44
  labels:
42
45
  owner: [%%HUMAN_MARKER%%, %%STAFF%%]
43
- kind: [decision, setup, build, blocked]
46
+ kind: [decision, review, chore, keep-open, build, blocked]
@@ -44,7 +44,8 @@ If what is wanted needs one of these, say so and stop. Do not work around it.
44
44
 
45
45
  1. **Say which file, and why that one.** Prefer the narrowest file that achieves it. If the
46
46
  change is about %%NAME%% specifically, it does not belong in `org/`.
47
- 2. **Show a diff, not a rewritten file.** %%HUMAN%% has to be able to see exactly what moved.
47
+ 2. **Hand back the whole file you changed**, in the block described at the end. The tool
48
+ %%HUMAN%% pastes your answer into shows them the diff, so they see exactly what moved.
48
49
  3. **Do not restate.** Every layer is already in the composed text below. A rule added to
49
50
  `org/voice.md` that `org/operating.md` already states makes the prompt longer and no
50
51
  clearer.
@@ -56,5 +57,5 @@ If what is wanted needs one of these, say so and stop. Do not work around it.
56
57
 
57
58
  ## Then
58
59
 
59
- Give %%HUMAN%% the diff, the one-line reason for the file you chose, and what you cut. They
60
- apply it: in the portal's Prompt screen, or by editing the file and committing it.
60
+ Outside the block: the one-line reason for the file you chose, and what you cut. Inside it:
61
+ the whole changed file. Nothing is saved until %%HUMAN%% has seen the diff and pressed Save.
@@ -0,0 +1,46 @@
1
+ Write `org/priorities.md` for %%ORG_NAME%%.
2
+
3
+ You are helping %%HUMAN%% decide what their AI staff should work on this month. Every staff
4
+ member reads this file at the start of every run and picks work that serves it, so a vague
5
+ priority produces scattered work.
6
+
7
+ ## Where you are
8
+
9
+ - `%%OPS_REPO_DIR%%/org/business.md`: what the business is. **Read it first**, and don't ask
10
+ anything it already answers.
11
+ - `%%OPS_REPO_DIR%%/org/priorities.md`: the current file, which you are replacing.
12
+
13
+ If you cannot read files where you are running, ask %%HUMAN%% to paste `org/business.md`.
14
+
15
+ ## Interview
16
+
17
+ Ask one question at a time. You are after:
18
+
19
+ - **The one outcome that matters most this month**, and how they will know it happened.
20
+ - **At most two more**, in order. Push back on a fourth: past three it is a wish list.
21
+ - **What is out of scope this month**: work that is tempting but not now. Naming it is what
22
+ stops the staff doing it.
23
+
24
+ Prefer outcomes ("a stranger pays for it") to activities ("improve the landing page"). If an
25
+ answer is an activity, ask what it is for.
26
+
27
+ ## Write it
28
+
29
+ Use exactly this shape:
30
+
31
+ ```
32
+ ## What matters this month
33
+
34
+ ### Priorities, in order
35
+
36
+ 1. The first outcome, and how you will know it happened.
37
+ 2. The second.
38
+ 3. The third.
39
+
40
+ ### Out of scope this month
41
+
42
+ - One thing per line.
43
+ ```
44
+
45
+ Keep each priority to a sentence or two. Don't add anything %%HUMAN%% didn't say without
46
+ listing it after the file so they can check it.
@@ -19,6 +19,16 @@ on:
19
19
  required: false
20
20
  default: daily
21
21
  type: string
22
+ # What started the run: daily | manual | follow-on | mention | peer. Peer and follow-on
23
+ # runs start without a person asking, so they are the ones held to max_runs_per_day.
24
+ trigger:
25
+ required: false
26
+ default: ""
27
+ type: string
28
+ max_runs_per_day:
29
+ required: false
30
+ default: 6
31
+ type: number
22
32
  ops_repo:
23
33
  description: "owner/name of the ops repo holding org.yaml and the prompts"
24
34
  required: true
@@ -65,20 +75,81 @@ permissions:
65
75
  contents: read
66
76
 
67
77
  jobs:
78
+ # Two staff can ask each other things, and a daily run can start a follow-on, so runs can start
79
+ # runs. This is what stops that at max_runs_per_day. A mention is a person asking and is never
80
+ # held back, so only peer and follow-on runs are counted, and only the ones that ran: a caller
81
+ # whose condition did not match leaves a skipped run behind under the same name.
82
+ budget:
83
+ runs-on: ubuntu-latest
84
+ permissions:
85
+ actions: read
86
+ issues: write
87
+ outputs:
88
+ go: ${{ steps.count.outputs.go }}
89
+ steps:
90
+ - name: Count today's runs nobody asked for
91
+ id: count
92
+ env:
93
+ GH_TOKEN: ${{ github.token }}
94
+ TRIGGER: ${{ inputs.trigger }}
95
+ STAFF: ${{ inputs.staff }}
96
+ LIMIT: ${{ inputs.max_runs_per_day }}
97
+ ISSUE: ${{ inputs.issue_number }}
98
+ run: |
99
+ set -uo pipefail
100
+ case "$TRIGGER" in
101
+ peer|follow-on) ;;
102
+ *) echo "go=true" >> "$GITHUB_OUTPUT"; exit 0 ;;
103
+ esac
104
+ today=$(date -u +%F)
105
+ # Includes this run, which is in progress and named like the rest.
106
+ filter="[.workflow_runs[]
107
+ | select(.display_title | test(\"^$STAFF (peer|follow-on)( |\$)\"))
108
+ | select(.conclusion != \"skipped\")] | length"
109
+ # One count per page, summed. pipefail makes a failed read fail the whole line.
110
+ if ! n=$(gh api --paginate "repos/${{ github.repository }}/actions/runs?created=>=$today&per_page=100" \
111
+ --jq "$filter" | awk '{s += $1} END {print s + 0}'); then
112
+ # Unknown is not under the limit. A run held back costs a day; a loop costs a bill.
113
+ echo "::warning::could not count today's runs, so this one does not start"
114
+ n=999999
115
+ fi
116
+ echo "$n of $LIMIT runs today that nobody asked for, this one included"
117
+ if [ "$n" -le "$LIMIT" ]; then
118
+ echo "go=true" >> "$GITHUB_OUTPUT"
119
+ exit 0
120
+ fi
121
+ echo "go=false" >> "$GITHUB_OUTPUT"
122
+ msg="Not started: $STAFF has had $LIMIT runs today that nobody asked for, which is max_runs_per_day. The next daily run picks this up, or mention them to start one now."
123
+ echo "$msg" >> "$GITHUB_STEP_SUMMARY"
124
+ if [ -n "$ISSUE" ]; then
125
+ gh issue comment "$ISSUE" --repo "${{ github.repository }}" --body "$msg" || true
126
+ fi
127
+
68
128
  session:
129
+ needs: budget
130
+ if: needs.budget.outputs.go == 'true'
69
131
  runs-on: ubuntu-latest
70
132
  timeout-minutes: ${{ inputs.timeout_minutes }}
71
133
 
72
134
  # `issues: write` is for the failure notice alone, which falls back to this job's own token
73
- # when the App's cannot be minted. A called workflow cannot raise what its caller granted, so
74
- # the callers ask for the same.
135
+ # when the App's cannot be minted. `actions: write` starts a follow-on run. A called workflow
136
+ # cannot raise what its caller granted, so the callers ask for the same.
75
137
  permissions:
76
138
  contents: read
77
139
  issues: write
140
+ actions: write
78
141
 
79
142
  # secrets are not usable in a step-level `if`, so the presence check is hoisted here.
80
143
  env:
81
144
  HAS_PUBLIC_APP: ${{ secrets.PUBLIC_APP_ID != '' }}
145
+ # Nothing is listening once the agent ends its turn: the session is over and a background
146
+ # job dies with the runner. Claude Code moves any command past its timeout (ten minutes by
147
+ # default) into the background, and an agent told "you will be notified" ends its turn to
148
+ # wait, so a slow test suite cost the whole run, unpushed, reported as a success. With
149
+ # background tasks off a slow command stays in the foreground, and the higher cap lets a
150
+ # long gate finish inside the turn. timeout-minutes is still the real bound.
151
+ CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: "1"
152
+ BASH_MAX_TIMEOUT_MS: "2700000"
82
153
 
83
154
  steps:
84
155
  # For the run record at the end. A job has no start time of its own to read back.
@@ -248,7 +319,8 @@ jobs:
248
319
  {"issue_number":"${{ inputs.issue_number }}",
249
320
  "comment_id":"${{ inputs.comment_id }}",
250
321
  "repo":"${{ github.repository }}",
251
- "actor":"${{ github.actor }}"}
322
+ "actor":"${{ github.actor }}",
323
+ "trigger":"${{ inputs.trigger }}"}
252
324
  run: |
253
325
  node roster-ops/compose.mjs --staff "${{ inputs.staff }}" --kind "${{ inputs.kind }}" --ops roster-ops --brains . > .roster-prompt.txt
254
326
  {
@@ -285,6 +357,13 @@ jobs:
285
357
  PUBLIC_TOKEN: ${{ steps.public.outputs.token }}
286
358
  with:
287
359
  claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN || secrets.AGENT_TOKEN }}
360
+ # The action refuses to run for a bot unless it is named here. A peer's ask is opened
361
+ # by that peer's App, so on a peer run, and only then, the one bot that opened it is
362
+ # allowed. The caller has already checked it is an App, not this staff member's own,
363
+ # and that the issue carries a from- label. A follow-on run is dispatched by the job token
364
+ # of the run before it, so its actor is github-actions[bot], and only that bot is allowed.
365
+ # Every other run allows no bots.
366
+ allowed_bots: ${{ inputs.trigger == 'peer' && github.actor || inputs.trigger == 'follow-on' && 'github-actions[bot]' || '' }}
288
367
  # These repos are private and single-user, so the usual reason to hide a run's output does
289
368
  # not apply, and hiding it turns any failure into "is_error: true" with no message.
290
369
  # Registered secrets are still masked by the runner.
@@ -341,6 +420,56 @@ jobs:
341
420
  fi
342
421
  eval "$RUN"
343
422
 
423
+ # A session can exit cleanly without doing what it was asked: the success above only means
424
+ # the agent stopped. A mention is answered by a reply in its thread, or by the issue being
425
+ # closed when the request said to answer somewhere else. When neither happened the job
426
+ # fails, so the notice below tells the human instead of leaving them waiting.
427
+ #
428
+ # Never fails on its own account: if the issue cannot be read, nothing is claimed.
429
+ - name: Check the request was answered
430
+ id: answered
431
+ if: >-
432
+ inputs.kind == 'mention' && inputs.issue_number != ''
433
+ && (steps.session_action.outcome == 'success' || steps.session_cli.outcome == 'success')
434
+ env:
435
+ GH_TOKEN: ${{ steps.private.outputs.token }}
436
+ BOT: ${{ steps.private.outputs.app-slug }}[bot]
437
+ ISSUE: ${{ inputs.issue_number }}
438
+ run: |
439
+ set -uo pipefail
440
+ since=$(date -u -d "@$ROSTER_STARTED" +%Y-%m-%dT%H:%M:%SZ)
441
+ if ! state=$(gh api "repos/${{ github.repository }}/issues/$ISSUE" --jq .state) ||
442
+ ! replies=$(gh api --paginate "repos/${{ github.repository }}/issues/$ISSUE/comments?since=$since" \
443
+ --jq ".[] | select(.user.login == \"$BOT\" and .created_at >= \"$since\") | .id"); then
444
+ echo "::warning::could not read #$ISSUE, so whether it was answered is unknown"
445
+ exit 0
446
+ fi
447
+ if [ "$state" = "closed" ] || [ -n "$replies" ]; then
448
+ exit 0
449
+ fi
450
+ echo "unanswered=true" >> "$GITHUB_OUTPUT"
451
+ echo "::error::the session ended without replying on #$ISSUE or closing it"
452
+ exit 1
453
+
454
+ # A daily run that ended with the next step ready says so in .roster-run/continue, and one
455
+ # more run starts once this one ends: it waits on the caller's concurrency group. Only
456
+ # after a run that finished, and the budget job above holds the chain to the day's limit.
457
+ # The job token can do this: a workflow_dispatch it sends still starts a run.
458
+ - name: Start a follow-on run
459
+ if: >-
460
+ inputs.kind == 'daily' && success()
461
+ && (steps.session_action.outcome == 'success' || steps.session_cli.outcome == 'success')
462
+ && hashFiles('.roster-run/continue') != ''
463
+ continue-on-error: true
464
+ env:
465
+ GH_TOKEN: ${{ github.token }}
466
+ CALLER: ${{ github.workflow_ref }}
467
+ run: |
468
+ set -uo pipefail
469
+ file=$(basename "${CALLER%@*}")
470
+ gh workflow run "$file" --repo "${{ github.repository }}" -f trigger=follow-on
471
+ { echo "Started a follow-on run:"; head -c 300 .roster-run/continue; echo; } >> "$GITHUB_STEP_SUMMARY"
472
+
344
473
  # What this run was and what it cost, in the job summary and as an artifact with a stable
345
474
  # name, which is what the portal's Runs screen and `roster doctor` read back. Never fatal:
346
475
  # a missing record costs a row in a table, and failing the job over it would cost the run.
@@ -354,6 +483,7 @@ jobs:
354
483
  MODEL: ${{ steps.agent.outputs.model || inputs.model }}
355
484
  AGENT_OUTCOME: ${{ steps.session_action.outcome != 'skipped' && steps.session_action.outcome || steps.session_cli.outcome }}
356
485
  JOB_STATUS: ${{ job.status }}
486
+ UNANSWERED: ${{ steps.answered.outputs.unanswered }}
357
487
  RESULT_FILE: ${{ steps.session_action.outputs.execution_file || format('{0}/.roster-run/agent-result.json', github.workspace) }}
358
488
  run: node roster-ops/run-record.mjs --out .roster-run/run.json
359
489
 
@@ -383,6 +513,7 @@ jobs:
383
513
  BRAIN_DIR: ${{ steps.plan.outputs.brain_dir }}
384
514
  BRAIN_REPO: ${{ steps.plan.outputs.brain_repo || github.repository }}
385
515
  ISSUE: ${{ inputs.issue_number }}
516
+ UNANSWERED: ${{ steps.answered.outputs.unanswered }}
386
517
  RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
387
518
  run: |
388
519
  set -uo pipefail
@@ -402,6 +533,9 @@ jobs:
402
533
  fi
403
534
 
404
535
  body="This run did not finish, so there is no answer coming. [Run ${GITHUB_RUN_ID}]($RUN_URL) has the error."
536
+ if [ "$UNANSWERED" = "true" ]; then
537
+ body="This run stopped without replying here or closing the issue, so there is no answer coming. [Run ${GITHUB_RUN_ID}]($RUN_URL) shows where it stopped."
538
+ fi
405
539
  if [ -n "$APP_TOKEN" ] && GH_TOKEN="$APP_TOKEN" gh issue comment "$issue" --repo "$BRAIN_REPO" --body "$body"; then
406
540
  exit 0
407
541
  fi
@@ -11,12 +11,10 @@
11
11
  //
12
12
  // Usage: node compose.mjs --staff cmo --kind daily [--ops .] [--brains ..]
13
13
 
14
- import { readFileSync, existsSync } from "node:fs";
14
+ import * as nodeFs from "node:fs";
15
15
  import { join, dirname, resolve } from "node:path";
16
16
  import { fileURLToPath } from "node:url";
17
17
 
18
- const HERE = dirname(fileURLToPath(import.meta.url));
19
-
20
18
  // ---------------------------------------------------------------------------
21
19
  // A strict, tiny YAML subset: nested maps, lists of scalars, lists of inline
22
20
  // maps ({a: 1, b: 2}), and scalars. Anything else is an error rather than a
@@ -288,7 +286,18 @@ function defaultMarker(name) {
288
286
  // Composition
289
287
  // ---------------------------------------------------------------------------
290
288
 
291
- export function compose({ opsDir, brainsDir, staff, kind, runDir }) {
289
+ // `fs` and `context` are for the portal, which composes from a copy of the repos held in memory
290
+ // rather than from a checkout, for a preview rather than a run. A workflow passes neither.
291
+ export function compose({
292
+ opsDir,
293
+ brainsDir,
294
+ staff,
295
+ kind,
296
+ runDir,
297
+ fs = nodeFs,
298
+ context = process.env.ROSTER_CONTEXT,
299
+ }) {
300
+ const { readFileSync, existsSync } = fs;
292
301
  const org = parseYaml(readFileSync(join(opsDir, "org.yaml"), "utf8"), "org.yaml");
293
302
 
294
303
  const entry = (org.staff ?? []).find((s) => s.handle === staff);
@@ -310,9 +319,9 @@ export function compose({ opsDir, brainsDir, staff, kind, runDir }) {
310
319
  // JSON in the environment rather than as arguments, so a workflow never has to quote a
311
320
  // comment body onto a command line.
312
321
  let event = {};
313
- if (process.env.ROSTER_CONTEXT) {
322
+ if (context) {
314
323
  try {
315
- event = JSON.parse(process.env.ROSTER_CONTEXT);
324
+ event = JSON.parse(context);
316
325
  } catch (err) {
317
326
  throw new Error(`ROSTER_CONTEXT is not valid JSON: ${err.message}`);
318
327
  }
@@ -323,6 +332,16 @@ export function compose({ opsDir, brainsDir, staff, kind, runDir }) {
323
332
  // sends it to a 404 before it has read anything. So the absence is a value of its own.
324
333
  if (Object.keys(event).length) event = { ...event, no_comment: !event.comment_id };
325
334
 
335
+ // Who started this run, as flags: the prompt language has `{{#if}}` and nothing to compare
336
+ // with. A peer's ask reads differently from a person's, and a follow-on picks up mid-task.
337
+ const trigger = String(event.trigger ?? "");
338
+ event = {
339
+ ...event,
340
+ from_peer: trigger === "peer",
341
+ from_human: trigger !== "peer",
342
+ follow_on: trigger === "follow-on",
343
+ };
344
+
326
345
  // What people have open on the product repos, gathered by inflight.mjs just before this runs.
327
346
  // Read as a value and never rendered as a template: it is PR titles, which are a person's
328
347
  // words, and a `{{` in one must not be able to break composition.
@@ -345,6 +364,11 @@ export function compose({ opsDir, brainsDir, staff, kind, runDir }) {
345
364
  // The repo this role contributes to but does not own. Named explicitly in the
346
365
  // prompt because "a repo you do not own" is vaguer than an agent needs.
347
366
  product: (self.works_in ?? [])[0] ?? null,
367
+ // Absent from manifests written before it existed; the callers fall back to the same.
368
+ max_runs_per_day: self.max_runs_per_day ?? 6,
369
+ // One staff member drafts next month's org/priorities.md, so there is one draft rather
370
+ // than one per person: whoever org.yaml lists first.
371
+ drafts_priorities: (org.staff ?? [])[0]?.handle === staff,
348
372
  },
349
373
  peers,
350
374
  peer: peers[0] ?? null,
@@ -388,12 +412,15 @@ function main(argv) {
388
412
  console.error("usage: node compose.mjs --staff <handle> --kind <daily|mention> [--ops DIR] [--brains DIR]");
389
413
  process.exit(2);
390
414
  }
391
- const opsDir = resolve(args.ops ?? HERE);
415
+ const opsDir = resolve(args.ops ?? dirname(fileURLToPath(import.meta.url)));
392
416
  const brainsDir = resolve(args.brains ?? join(opsDir, ".."));
393
417
  process.stdout.write(compose({ opsDir, brainsDir, staff: args.staff, kind: args.kind }));
394
418
  }
395
419
 
396
- if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
420
+ // Run as a script, and only as itself: bundled into another program (the portal's), this file's
421
+ // URL is that program's, and `node <program>` must not be taken for `node compose.mjs`.
422
+ const self = import.meta.url ? fileURLToPath(import.meta.url) : "";
423
+ if (process.argv[1] && self.endsWith("compose.mjs") && resolve(process.argv[1]) === resolve(self)) {
397
424
  try {
398
425
  main(process.argv.slice(2));
399
426
  } catch (err) {
@@ -9,11 +9,16 @@ question instead of doing work has wasted its slot.
9
9
  - **A question is an issue, never a stopped run.** When you hit something genuinely load-bearing,
10
10
  open a `decision` issue on your own tracker, assign `{{human.github}}`, @-mention them, **then move
11
11
  to the next item.** The body: the ask as the first line, your recommendation, the argument stripped
12
- to what they need to rule, and **the default if they say nothing**. They are ruling from a phone.
12
+ to what they need to rule, and the default with a date, as its own last line: **"If I hear nothing
13
+ by <YYYY-MM-DD>, I'll <do X>."** At least two working days out. They are ruling from a phone.
13
14
  - **Filing an issue does not stop the run.** "This needs a human" means open the issue and carry on,
14
15
  not stand still.
15
16
  - **Never end a run blocked.** If everything on the list is genuinely blocked, do the most useful
16
17
  unblocked thing you can find and say so in the report.
18
+ - **Finish inside the run.** Once you stop, the run is over: nothing will wake you, and anything
19
+ left running dies with it. Never end a turn to wait for a command; wait for it in the same call.
20
+ **Push your branch before a slow check** such as a full test suite, so the work survives if the
21
+ run is cut short, and push again once it passes.
17
22
 
18
23
  ## Choosing work
19
24
 
@@ -25,12 +30,21 @@ question instead of doing work has wasted its slot.
25
30
 
26
31
  ## Keeping your tracker clean
27
32
 
28
- {{human.name}} should never have to ask whether an issue can be closed.
29
-
30
- - **Close your own issues** when the work is done or superseded, with one line naming what closed
31
- it: the PR, the commit, or the issue that replaced it. Do not leave one open "in case".
32
- - **Sweep them on every daily run.** Read every open issue you opened; close what is finished or
33
- stale, and fold duplicates into one.
33
+ {{human.name}} should never have to ask whether an issue can be closed, or close one themselves.
34
+
35
+ - **Close any issue on your tracker once nothing is left to do on it**, whoever opened it, including
36
+ {{human.name}}'s requests. One line naming what closed it: the PR, the commit, the answer, or the
37
+ issue that replaced it. If a request needs nothing, say why in that line and close it. Do not leave
38
+ one open "in case".
39
+ - **Sweep your tracker on every daily run.** Every open issue on it, not only the ones you opened:
40
+ close it, do it, or put it in your plan. Fold duplicates into one.
41
+ - **Never close an issue labelled `keep-open`, or your pinned status issue.** Those are standing
42
+ threads.
43
+ - **Every ask on {{human.name}} carries the `{{human.marker}}` label and exactly one kind**, and is
44
+ assigned to `{{human.github}}`:
45
+ - `decision`: they rule on something. Carries the default and date above.
46
+ - `review`: they read or approve something you made.
47
+ - `chore`: something only they can do, such as a setting, an account or a key.
34
48
  - **Ideas live in your brain, not on the tracker.** Park a speculative idea as one line in
35
49
  `strategy/ideas.md`. Open an `IDEA:` issue only when it needs a ruling, and never more than one
36
50
  at a time.
@@ -41,7 +55,9 @@ question instead of doing work has wasted its slot.
41
55
  mechanical rather than a promise: protected branches mean you open a PR and their merge is the
42
56
  approval. **Do not look for a way around it.** Being unable to ship unreviewed is what earns the
43
57
  autonomy.
44
- - **Never close a `decision` issue**, even in a sweep. Those are {{human.name}}'s rulings to close.
58
+ - **Close a `decision` only once it is settled.** Either {{human.name}} answered: act on it, then
59
+ close it quoting the ruling. Or the date passed with no answer: act on the default, then close it
60
+ saying you did. Never before one of those.
45
61
  - **Never `git add -A` in another staff member's repo, or in a repo where a human may have work in
46
62
  flight.** Stage explicit paths. Doing otherwise has swept someone else's uncommitted work into an
47
63
  unrelated commit.
@@ -65,6 +81,8 @@ overhead.**
65
81
  `log/decisions.md`. A memory that only grows is a memory nobody reads.
66
82
  - Mark every fact with where it came from: `[{{human.marker}}]` for a ruling, `[measured]` for
67
83
  something with an `n` and a date, `[derived]` for your own inference.
84
+ - **Another run of yours may be working at the same time**: a mention, or a peer's ask. If a push
85
+ is rejected, `git pull --rebase` and push again. Never force-push.
68
86
 
69
87
  `log/decisions.md` is **not** boot context. It is the audit trail: read it when you need to know why
70
88
  something was decided, or before reversing a call somebody already made.
@@ -76,9 +94,10 @@ Other staff members are peers, not subordinates and not tools. **Write to them f
76
94
  team updated is always fine, and over-communicating is the right default.
77
95
 
78
96
  **Comms are issues, not file drops:** open an issue on their tracker labelled `from-{{staff.handle}}`.
79
- A file in their inbox works for them and is invisible to {{human.name}}, and he needs to be able to
97
+ A file in their inbox works for them and is invisible to {{human.name}}, who needs to be able to
80
98
  read the whole conversation in one place. Genuinely long-form output can still be a file, with the
81
- issue linking to it.
99
+ issue linking to it. **Filing one wakes them within a minute**, so file what they can act on now
100
+ and put everything else in one issue rather than several.
82
101
 
83
102
  **An ask of a peer stays an ask.** They own their own priorities. Anything that needs
84
103
  {{human.name}}'s money or public sign-off still goes through them.