pi-superagent 0.1.0 → 0.1.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.
@@ -1,68 +1,80 @@
1
1
  # Operator guide
2
2
 
3
- Everything you need to ask for work, watch it happen, and set it right when it goes wrong.
3
+ Most of the time, the issue is the only window you need. Ask for a change there, answer any questions
4
+ in the thread, and review the pull request when it arrives. If you want to see a command run or help
5
+ a worker past a snag, its terminal is open to you too.
4
6
 
5
- ## Asking for work
7
+ ## Ask for work
6
8
 
7
- Open an issue on the watched repository (`PI_SUPERAGENT_GITHUB_REPO`) and say plainly what you want
8
- done:
9
+ Open an issue in the repository you configured with `superagent init`. A sentence about the outcome
10
+ and one detail that matters to you usually give the worker a good place to start.
9
11
 
12
+ > **Show the export shortcut in the Help menu**
13
+ >
14
+ > I always forget how to export from the keyboard. Could you show the existing shortcut beside
15
+ > Export in the Help menu? Please use the same wording as the File menu.
16
+
17
+ The **judge** reads new requests and decides which ones call for action. When it accepts yours,
18
+ the router acknowledges it on the issue. Look for a tab with that issue number in the
19
+ `superagent` herdr workspace. Inside is the **worker**, the pi session doing the work.
20
+
21
+ An aside to a teammate can stay an aside. If the judge passes over a comment, you can find its
22
+ reason in the engine log. Once your issue has an open ticket, further comments go to the worker.
23
+
24
+ ### Who can start work
25
+
26
+ By default the router accepts authors whose GitHub association is `OWNER`, `MEMBER` or
27
+ `COLLABORATOR`. The panel counts requests from other authors as filtered. To choose the permitted
28
+ accounts yourself, set `PI_SUPERAGENT_ALLOWED` to their logins. This list replaces the default rule.
29
+
30
+ ### Follow up and review changes
31
+
32
+ Comment on the issue to steer an active worker. If it needs a decision, it posts a question on
33
+ the thread and the panel lists it under *Needs a person*. Reply there to continue.
34
+
35
+ For a code change, the worker opens a pull request and the router links it on the issue. The panel
36
+ shows `review of #N` while the PR is open. Comments and reviews on that PR reach the same worker.
37
+ Merging ends the ticket as merged. Closing the PR unmerged also ends the ticket, and you can
38
+ comment on the issue to ask for another attempt. The router checks PRs in other repositories every
39
+ two minutes. An answer, investigation or operation can finish with the worker’s ready report.
40
+
41
+ A comment or submitted review on a PR without a ticket goes to the judge. The router replies in
42
+ that PR’s conversation.
43
+
44
+ ### Choose the GitHub accounts
45
+
46
+ Workers open PRs as the account signed in through the local `gh` CLI. Blocking `gh` with
47
+ `PI_SUPERAGENT_BLOCKED` disables that workflow. By default the router uses the same account and
48
+ adds a hidden marker to its comments so it can distinguish them from yours.
49
+
50
+ To have the router reply under its own name, give that account access to the watched repository.
51
+ Save its token in a file only you can read, set `PI_SUPERAGENT_GITHUB_TOKEN_FILE` to the path and
52
+ `PI_SUPERAGENT_GITHUB_SELF` to the login, then restart. Look for `githubAs="token file"` in the
53
+ `router.start` log entry. Workers still use the local CLI account, which the router also uses to
54
+ read their PRs.
55
+
56
+ ### Stop a ticket
57
+
58
+ Close the issue to stop its ticket on the next poll. When a ticket is waiting for its own PR,
59
+ merge or close that PR to record the review outcome. Reopen the issue to request work again.
60
+ You can also stop a ticket through the local panel API.
61
+
62
+ ```sh
63
+ curl -X POST -H 'x-superagent-request: 1' "http://127.0.0.1:8788/api/tickets/<id>/stop"
10
64
  ```
11
- Title: Rename the Export button to "Ship"
12
- Body: The primary button in the header should say Ship instead of Export. Keep the keyboard shortcut.
13
- ```
14
65
 
15
- Within about a minute the judge's acknowledgement appears on the issue, and a tab named for the issue
16
- opens in the `superagent` herdr workspace with the worker inside. When the worker finishes, its report
17
- arrives on the issue as a reply.
18
-
19
- The judge accepts a concrete action someone asks the agent to take, even one that calls itself a test.
20
- It ignores chatter, notes addressed to other people, and new requests on a thread that already has an
21
- open ticket. An ignore posts nothing on the issue; the reason is in the engine log.
22
-
23
- - **Who can ask.** People with write access to the repository: its owner, members of the organization
24
- that owns it, and collaborators. Anyone else's issues, comments and reviews are dropped before the judge
25
- sees them, and the panel counts them as filtered. To hear someone else, add them as a collaborator. To
26
- hear fewer people, list the logins in `PI_SUPERAGENT_ALLOWED`; the list then replaces the rule.
27
- - **Follow-ups.** Comment on the same issue. While its ticket is open, your comments go straight to its
28
- worker.
29
- - **Pull requests.** When the work changes a repository, the worker opens a pull request and names it in
30
- its report, and the receipt on the issue links it. The ticket then waits for review, shown on the panel
31
- as `review of #N`: your comments and reviews on the pull request go to the same worker. Merge it, and
32
- the ticket ends and the issue says it is done. Close it unmerged, and the ticket ends too; a comment on
33
- the issue starts the work again. A pull request in another repository works the same way, checked every
34
- two minutes. A request that changes no repository, such as a question, an investigation or an
35
- operation, ends with its report.
36
- - **Who opens the pull request.** The worker, with the `gh` on this machine, so the pull request's author
37
- is whoever `gh` is signed in as. Blocking `gh` for workers (`PI_SUPERAGENT_BLOCKED`) turns pull requests
38
- off: workers then report without one.
39
- - **The agent's own account.** By default the router reads and replies as the account `gh` is signed in
40
- as, so its comments look like yours apart from a hidden marker. To give it an account of its own, put a
41
- token for that account in a file only you can read, set `PI_SUPERAGENT_GITHUB_TOKEN_FILE` to the file
42
- and `PI_SUPERAGENT_GITHUB_SELF` to the account's login, give the account access to the watched
43
- repository, and restart. The engine log's `router.start` line then says `githubAs="token file"`.
44
- Workers still act as `gh`'s account, so their pull requests are yours, and the router reads those pull
45
- requests as that account too.
46
- - **Pull requests no ticket opened.** A comment or a submitted review on one reaches the judge like any
47
- other request, and the answer lands in the pull request's conversation.
48
- - **Questions from a worker.** A worker that needs you reports *blocked* with one question. The question
49
- is posted on the issue (and listed on the panel under *Needs a person*); answer it with a comment.
50
- - **Stopping.** Close the issue. Within one poll the ticket stops and says so on the thread. A ticket
51
- waiting on its own pull request ends with that pull request instead, as above. Reopen the issue to run the request again. Without GitHub, the panel
52
- API stops a ticket too:
53
- `curl -X POST -H 'x-superagent-request: 1' http://127.0.0.1:8788/api/tickets/<id>/stop`.
54
-
55
- ## Watching
56
-
57
- - **The herdr workspace `superagent`.** The `engine log` tab streams every poll, judgement, launch and
58
- receipt. Each worker has its own tab, labelled `#<issue> · <title>`; it is an ordinary pi session, so
59
- you can read along, type into it, or press Esc to interrupt it.
60
- - **The panel** at <http://127.0.0.1:8788/>. It shows what needs a person, what is running and queued,
61
- and what the judge decided.
62
- - **The log itself:** `tail -F ~/.pi/superagent/engine.log`. Each line is one event with its fields, so
63
- `grep eval.decided` lists every judgement with its reason.
64
-
65
- ## Running it
66
+ ## Watch a worker
67
+
68
+ To see the work itself, open the herdr tab labeled `#<issue> · <title>`. It’s an ordinary pi
69
+ session. You can read the output, type a suggestion or press Esc to interrupt a command. For a
70
+ view across all your issues, open the local panel. It shows what’s running, what’s queued and
71
+ which workers need an answer. [Open the panel](http://127.0.0.1:8788/)
72
+
73
+ The **engine log** tab tells the other half of the story. It records when the router checked
74
+ GitHub, what the judge decided and when a worker started. To follow the same log from another
75
+ terminal, run `tail -F ~/.pi/superagent/engine.log`.
76
+
77
+ ## Manage the router
66
78
 
67
79
  ```sh
68
80
  superagent status # 0 healthy · 1 down · 2 a part is failing · 3 waiting for setup
@@ -90,48 +102,48 @@ The job finds `superagent`, `pi` and `herdr` on its own PATH: Homebrew's directo
90
102
  `~/.npm-global/bin`. If `command -v superagent` or `command -v pi` prints a directory outside those, as nvm's
91
103
  do, add it to the job's PATH. From a checkout, replace `superagent` in the job with the script's full path.
92
104
 
93
- ## Capacity
105
+ ## When several issues arrive at once
94
106
 
95
- Up to four workers can be on a run at once (`PI_SUPERAGENT_MAX_WORKERS`); further tickets wait their
96
- turn, queued on the panel. A worker between runs, waiting on your answer or simply done, is *parked*: it
97
- keeps its tab and everything it knows, but gives up its slot, so the queue keeps moving. A reply puts it
98
- back on a run. The judge answers one request at a time. Every worker's brief says the machine is shared:
99
- sequential builds, bounded parallel jobs, nothing left running after the report.
107
+ By default, four workers can run at once. If you open a fifth issue while all four are busy, its
108
+ ticket waits in the queue on the panel. A worker waiting for your answer can **park**. It keeps
109
+ its tab and its conversation history, and another ticket can use the free slot. When you reply,
110
+ the parked worker picks up where it left off. Set `PI_SUPERAGENT_MAX_WORKERS` to change the limit.
100
111
 
101
- A worker on a run that emits nothing for 15 minutes is flagged on the panel, and only there, under *Needs a
102
- person*: steer it, stop it, or accept its work. The flag does not stop the worker. If it is only running a
103
- long build, let it be; the flag clears when the worker reports.
112
+ The judge reads one request at a time. Workers can build and test side by side, so their
113
+ instructions ask them to limit parallel jobs and clean up any processes they start. If a worker
114
+ goes quiet for 15 minutes, it appears under *Needs a person* on the panel. A long build can be
115
+ quiet, too. Take a look in the tab before interrupting it.
104
116
 
105
117
  ## When something goes wrong
106
118
 
107
- **No acknowledgement after a few minutes.** Run `status` first. Then
108
- `grep eval.decided ~/.pi/superagent/engine.log | tail`: `kind=ignore` comes with the judge's reason, and a
109
- clearer comment or a reopened issue asks again. A `judge.prompt` line with no `eval.decided` after it
110
- means the judge is wedged; `restart` fixes it.
119
+ **No acknowledgement after a few minutes.** Run `superagent status`, then inspect the most recent
120
+ decisions with `grep eval.decided ~/.pi/superagent/engine.log | tail`. For `kind=ignore`, read the
121
+ reason before posting a clearer request. If the log stays at `judge.prompt` without a decision,
122
+ restart the router with `superagent restart`.
111
123
 
112
- **Someone else's issue gets no acknowledgement.** Check that they can write to the repository, or that
113
- their login is in `PI_SUPERAGENT_ALLOWED` when that is set. The panel's count of filtered triggers rises
124
+ **Someone else's issue gets no acknowledgement.** Check their GitHub author association, or look for
125
+ their login in `PI_SUPERAGENT_ALLOWED` if you configured a list. The panel's count of filtered triggers rises
114
126
  by one for each request it dropped this way.
115
127
 
116
- **A ticket stays open after its worker reported ready.** It is waiting for its pull request: the panel
117
- shows `review of #N`. Merge or close the pull request; the ticket ends within one poll, or within two
118
- minutes for a pull request in another repository.
128
+ **A ticket stays open after a ready report.** Look for `review of #N` on the panel. Merge or close
129
+ that PR to finish the ticket. The router checks the watched repository on each poll and other
130
+ repositories every two minutes.
119
131
 
120
- **`status` exits 2.** Read `~/.pi/superagent/health.json`. A failing `source` means the router cannot
121
- reach GitHub; check `gh auth status`. The error clears on the next good poll.
132
+ **Status exits 2.** Read `~/.pi/superagent/health.json` to identify the failing component. For a
133
+ GitHub source error, check `gh auth status`. The next successful poll clears the error.
122
134
 
123
- **`status` exits 3.** Read `~/.pi/superagent/setup.json`: it names what is missing and where to fix it.
135
+ **Status exits 3.** Read `~/.pi/superagent/setup.json` for the missing prerequisite and its location.
124
136
 
125
- **A worker looks stuck.** Open its tab and read it. Type into it to steer, or press Esc to interrupt.
137
+ **A worker looks stuck.** Open its herdr tab to inspect the current command. Type a message to steer
138
+ the worker or press Esc to interrupt it.
126
139
 
127
- **The issue says the worker stopped without reporting a result.** It ended a run without calling
128
- `ticket_report`, so whatever it concluded is still in its tab. The worker is still open: a reply on the
129
- issue steers it, and closing the issue drops the ticket.
140
+ **A run ended without a report.** Inspect the worker’s tab for its last output. The session stays
141
+ open. Reply on the issue to continue or close the issue to drop the ticket.
130
142
 
131
- **The issue says the worker crashed.** The router has already started a fresh worker on it, once, and the
132
- new worker's brief says what happened. If the issue says the fresh worker crashed too, nothing runs the
133
- ticket until `superagent restart`, and closing the issue drops it.
143
+ **A worker crashed.** The router retries the first crash automatically and tells the replacement
144
+ what happened. After a second crash, inspect the failure and run `superagent restart` to retry,
145
+ or close the issue to stop.
134
146
 
135
- **The issue says a worker could not start.** The notice quotes the error, usually from the setup script
136
- (`PI_SUPERAGENT_PREPARE`). The router retries on every poll, without posting again, until the cause is
137
- fixed or the issue is closed.
147
+ **A worker could not start.** Read the error on the issue. Check repository access if the clone
148
+ failed, or inspect `PI_SUPERAGENT_PREPARE` if you use a custom setup command. The router retries
149
+ on each poll and posts the launch failure once.
package/formal/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # formal/
1
+ # TLA+ models
2
2
 
3
- TLA+ specifications of the three places in pi-superagent where a bad ordering would quietly lose or
4
- duplicate work. TLC, the TLA+ model checker, explores every reachable state of each one.
3
+ A worker finishes just as the router restarts. Should the router start another worker, adopt the
4
+ one it finds, or close the tab? Small differences in timing matter here. These three models let
5
+ TLC, the TLA+ model checker, explore the possible orderings within a set of bounds. Start with
6
+ the model closest to the code you’re changing.
5
7
 
6
- | Specification | Models | Distinct states |
7
- | --- | --- | --- |
8
- | `Ticket.tla` | the engine's ticket lifecycle (`src/core`) | 1,398,882 |
9
- | `Intake.tla` | the GitHub source (`src/pi/source-github.ts`) | 113,281 |
10
- | `Workers.tla` | worker records, tabs and agents (`src/pi/herdr-workers.ts`) | 94 |
8
+ | Specification | Code it models | Distinct states |
9
+ | --- | --- | ---: |
10
+ | [Ticket.tla](Ticket.tla) | Ticket lifecycle in `src/core/` | 1,398,882 |
11
+ | [Intake.tla](Intake.tla) | GitHub polling in `src/pi/source-github.ts` | 113,281 |
12
+ | [Workers.tla](Workers.tla) | Worker records and herdr tabs in `src/pi/herdr-workers.ts` | 94 |
11
13
 
12
- Each `.cfg` file names its specification's constants and lists the invariants and properties TLC checks.
13
- What every claim means, and what none of them say, is in
14
- [docs/formal-verification.md](../docs/formal-verification.md).
14
+ Each accompanying `.cfg` file sets the bounds and selects the properties to check.
15
+ [Property definitions and assumptions](../docs/formal-verification.md)
15
16
 
16
- ## Running
17
+ ## Run the checks
17
18
 
18
- `scripts/check-formal` checks all three in about five minutes and exits 0 only when every one completes.
19
- To check one by hand, from this directory:
19
+ From the repository root, run `scripts/check-formal`. All three checks take about five minutes and
20
+ require a JDK. The script downloads the TLC jar on first use. To rerun just the intake model, run
21
+ this command from the `formal/` directory.
20
22
 
21
23
  ```sh
22
24
  java -XX:+UseParallelGC -Xmx4g -cp ~/.cache/tla2tools/tla2tools.jar tlc2.TLC -config Intake.cfg Intake.tla
23
25
  ```
24
26
 
25
- ## Changing a specification
27
+ ## Update a model
26
28
 
27
- - Every action names the function whose guards it mirrors. When that function changes, change the action
28
- and run the check again.
29
- - Every header lists what its model leaves out. A claim covers a left-out feature only as far as that
30
- feature's code passes through the same guards, so keep the list current.
31
- - Keep the bounds small. A check that takes hours stops being run, and a check nobody runs proves nothing.
29
+ Each action names the implementation function it represents. When you change a transition or its
30
+ guards, update the corresponding action and rerun TLC. Keep the scope and exclusions in the model
31
+ header current. Choose bounds small enough to explore exhaustively during development.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-superagent",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Open a GitHub issue; a pi worker does the work and replies there. The dsh-superagent ticket engine bound to pi, herdr, GitHub and SQLite.",
5
5
  "type": "module",
6
6
  "license": "MIT",