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.
- package/ADAPTATION.md +29 -31
- package/README.md +69 -122
- package/docs/architecture.md +103 -124
- package/docs/design-decisions.md +128 -228
- package/docs/formal-verification.md +48 -52
- package/docs/operator-guide.md +101 -89
- package/formal/README.md +20 -20
- package/package.json +1 -1
package/docs/operator-guide.md
CHANGED
|
@@ -1,68 +1,80 @@
|
|
|
1
1
|
# Operator guide
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
7
|
+
## Ask for work
|
|
6
8
|
|
|
7
|
-
Open an issue
|
|
8
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
##
|
|
105
|
+
## When several issues arrive at once
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
108
|
-
`grep eval.decided ~/.pi/superagent/engine.log | tail
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
113
|
-
their login
|
|
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
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
**
|
|
128
|
-
|
|
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
|
-
**
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
**
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
#
|
|
1
|
+
# TLA+ models
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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 |
|
|
7
|
-
| --- | --- |
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
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
|
|
13
|
-
|
|
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
|
-
##
|
|
17
|
+
## Run the checks
|
|
17
18
|
|
|
18
|
-
`scripts/check-formal
|
|
19
|
-
To
|
|
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
|
-
##
|
|
27
|
+
## Update a model
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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.
|
|
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",
|