Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a014e75101 | |||
| 55f87fb34e | |||
| 6df7bed25b | |||
| dc8504e4ca | |||
| 1ace7ee8d9 | |||
| 1ca2c8efe0 | |||
| 20c83f861f | |||
| 6baab24efc |
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Renamed `loop-claude` to `build-release`, with no alias. Before you update, finish your open chunks, since a chunk left open under `loop-claude` starts a fresh session, and stop every running `loop-claude`, since a loop that runs across the update can't reload and hands its workers variables the new rule-hook ignores. Then remove `~/.local/bin/loop-claude`, link the new name with `ln -s ~/.claude/bin/build-release ~/.local/bin/build-release`, and rename each `LOOP_CLAUDE_*` variable you set, in your shell profile and in your crontab, to `BUILD_RELEASE_*`, such as `BUILD_RELEASE_TRANSCRIPTS`. The folders and the file it keeps, `~/.claude/loop-claude-transcripts`, `~/.claude/loop-claude-models.json` and `~/.local/state/loop-claude`, keep their names for now.
|
- Renamed `loop-claude` to `build-release`, with no alias. Before you update, finish your open chunks, since a chunk left open under `loop-claude` starts a fresh session, and stop every running `loop-claude`, since a loop that runs across the update can't reload and hands its workers variables the new rule-hook ignores. Then remove `~/.local/bin/loop-claude`, link the new name with `ln -s ~/.claude/bin/build-release ~/.local/bin/build-release`, and rename each `LOOP_CLAUDE_*` variable you set, in your shell profile and in your crontab, to `BUILD_RELEASE_*`, such as `BUILD_RELEASE_TRANSCRIPTS`.
|
||||||
- A claude that build-release, do-epic or `task-bench gather` starts has the release's tools first on its `PATH`, and the rules, the skills and each tool's help and errors name a tool bare, as in `todo-item`. In your own shell, and in a claude you start from it yourself, call a tool other than `build-release` by its path, `~/.claude/bin/<tool>`.
|
- A claude that build-release, do-epic or `task-bench gather` starts has the release's tools first on its `PATH`, and the rules, the skills and each tool's help and errors name a tool bare, as in `todo-item`. In your own shell, and in a claude you start from it yourself, call a tool other than `build-release` by its path, `~/.claude/bin/<tool>`.
|
||||||
- do-epic runs `chunk-pr clean` itself for a chunk whose pull request merged, finishes the chunk and closes its window, without a running slot or a worker, where it used to wait for a free slot and a worker for that.
|
- do-epic runs `chunk-pr clean` itself for a chunk whose pull request merged, finishes the chunk and closes its window, without a running slot or a worker, where it used to wait for a free slot and a worker for that.
|
||||||
- Make `task-bench` commit the copy it runs each side's tests in, so a project's tests that call git, such as `git ls-files`, pass the baseline instead of failing with "not a git repository".
|
- Make `task-bench` commit the copy it runs each side's tests in, so a project's tests that call git, such as `git ls-files`, pass the baseline instead of failing with "not a git repository".
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, are th
|
|||||||
4. A review rules the work below standard: systems-architect's BLOCK, a finding against the review standards' `quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` §3 → "Rung up"). It doesn't fire where the fix changes only prose (`larv-review` §3 says what is prose): fix that on your own rung.
|
4. A review rules the work below standard: systems-architect's BLOCK, a finding against the review standards' `quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` §3 → "Rung up"). It doesn't fire where the fix changes only prose (`larv-review` §3 says what is prose): fix that on your own rung.
|
||||||
|
|
||||||
When one fires, hand the hard part, edits included, to a subagent on the rung build-release's prompt names, one above yours. Open the subagent's prompt with the marker build-release's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung build-release's prompt names. Ask the human before going higher. Where build-release's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread.
|
When one fires, hand the hard part, edits included, to a subagent on the rung build-release's prompt names, one above yours. Open the subagent's prompt with the marker build-release's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung build-release's prompt names. Ask the human before going higher. Where build-release's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread.
|
||||||
- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. A reviewer under `~/.claude/agents/` writes only its report, under `~/.local/state/larv-review/`, and rule-hook refuses it every other Write, every Edit and every MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to a folder it makes under the chunk's review folder (`larv-review review-folder` prints it), and removes no image or file it did not create.
|
- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. A reviewer under `~/.claude/agents/` writes only its report, under `~/.local/state/build-release/larv-review/` (under `$XDG_STATE_HOME` instead of `~/.local/state`, where that holds an absolute path), and rule-hook refuses it every other Write, every Edit and every MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to a folder it makes under the chunk's review folder (`larv-review review-folder` prints it), and removes no image or file it did not create.
|
||||||
- Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer.
|
- Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer.
|
||||||
- Where `rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest or a `docker run` line, pin a container image to its full patch version and a GitHub Action to a semver tag.
|
- Where `rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest or a `docker run` line, pin a container image to its full patch version and a GitHub Action to a semver tag.
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, are th
|
|||||||
- PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title).
|
- PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title).
|
||||||
- Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`.
|
- Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`.
|
||||||
- Branch for a plan item without a ticket: `item-<ID>`, in the worktree `<checkout>-item-<ID>` beside the checkout, as `chunk-preflight` makes them. Under a `branch` template, `chunk-preflight` names both by the template.
|
- Branch for a plan item without a ticket: `item-<ID>`, in the worktree `<checkout>-item-<ID>` beside the checkout, as `chunk-preflight` makes them. Under a `branch` template, `chunk-preflight` names both by the template.
|
||||||
- Where the project's config keeps a file in the config's folder, `~/.claude-projects/<key>/`, such as the plan or a record, commit each change you make to that file in the folder's own git repo, on its only branch. Two chunks may commit there at once, so commit only that file: `git commit -m <title> -- <file>`, after `git add <file>` where it is new. Where git finds `index.lock` held, the other chunk is committing: try again. Title that commit as you would title the change in the checkout: where a commit in the checkout goes with it, give it the same title.
|
- Where the project's config keeps a file in the config's folder, `~/.config/build-release/<key>/` (under `$XDG_CONFIG_HOME` instead of `~/.config`, where that holds an absolute path), such as the plan or a record, commit each change you make to that file in the folder's own git repo, on its only branch. Two chunks may commit there at once, so commit only that file: `git commit -m <title> -- <file>`, after `git add <file>` where it is new. Where git finds `index.lock` held, the other chunk is committing: try again. Title that commit as you would title the change in the checkout: where a commit in the checkout goes with it, give it the same title.
|
||||||
- Use `gh` on GitHub remotes and `tea` on Gitea remotes (e.g. `gitea.larvit.se`) — same command shape: `tea pr list|create`, `tea issue`, `tea release`, `tea api`. Everything in this section applies to both.
|
- Use `gh` on GitHub remotes and `tea` on Gitea remotes (e.g. `gitea.larvit.se`) — same command shape: `tea pr list|create`, `tea issue`, `tea release`, `tea api`. Everything in this section applies to both.
|
||||||
- On GitHub and Gitea, open a chunk's pull request as a draft, mark it ready and merge it with `chunk-pr`, which picks `gh` or `tea` from the remote; `chunk-pr --help` says how. Once it has merged, run `chunk-pr clean` in the chunk's worktree: it removes the worktree and the branch and fast-forwards the main checkout.
|
- On GitHub and Gitea, open a chunk's pull request as a draft, mark it ready and merge it with `chunk-pr`, which picks `gh` or `tea` from the remote; `chunk-pr --help` says how. Once it has merged, run `chunk-pr clean` in the chunk's worktree: it removes the worktree and the branch and fast-forwards the main checkout.
|
||||||
|
|
||||||
|
|||||||
@@ -83,29 +83,28 @@ Then pick a model with `/model`.
|
|||||||
|
|
||||||
Link `build-release` onto `PATH`: `ln -s ~/.claude/bin/build-release ~/.local/bin/build-release`. Every claude it starts, the interactive ones included, skips every permission prompt. build-release runs each chunk in its own window of a tmux session per project, so it needs tmux 3.2 or later.
|
Link `build-release` onto `PATH`: `ln -s ~/.claude/bin/build-release ~/.local/bin/build-release`. Every claude it starts, the interactive ones included, skips every permission prompt. build-release runs each chunk in its own window of a tmux session per project, so it needs tmux 3.2 or later.
|
||||||
|
|
||||||
Back up these four folders and one file:
|
The setup keeps each project's config, and what you choose for a project, in the config folder, `~/.config/build-release/`. Everything else its tools write is in the state folder, `~/.local/state/build-release/`. Where `XDG_CONFIG_HOME` holds an absolute path, the config folder is `build-release/` under that path instead, and likewise the state folder under `XDG_STATE_HOME`; this README spells the defaults. Set such a variable in the environment Claude Code starts in, since rule-hook reads it there. `settings.json` names only the default review folder, `~/.local/state/build-release/larv-review`, in `additionalDirectories`: where `XDG_STATE_HOME` moves that folder, add it there yourself, or an interactive session asks before a reviewer writes its report. Back up these four folders:
|
||||||
|
|
||||||
- `~/.claude-projects/`: each project's config, and a client project's plan and records. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
|
- `~/.config/build-release/`: each project's config, a client project's plan and records, and `models.json`, the model of each project, which build-release and do-epic write. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
|
||||||
- `~/.claude/loop-claude-models.json`: the model of each project, which build-release and do-epic write.
|
- `~/.local/state/build-release/transcripts`: every transcript build-release keeps. Where you set `BUILD_RELEASE_TRANSCRIPTS`, back up the folder it names instead.
|
||||||
- `~/.claude/loop-claude-transcripts`: every transcript build-release keeps. Where you set `BUILD_RELEASE_TRANSCRIPTS`, back up the folder it names instead.
|
- `~/.local/state/build-release/do-epic-transcripts`: the transcripts of do-epic's chunks.
|
||||||
- `~/.claude/do-epic-transcripts`: the transcripts of do-epic's chunks.
|
- `~/.local/state/build-release/larv-review`: each chunk's review reports.
|
||||||
- `~/.local/state/larv-review`: each chunk's review reports.
|
|
||||||
|
|
||||||
Leave out Claude Code's memory files in `~/.claude/projects/<folder>/memory/`: Claude Code writes them, so they aren't part of this setup.
|
Leave out Claude Code's memory files in `~/.claude/projects/<folder>/memory/`: Claude Code writes them, so they aren't part of this setup.
|
||||||
|
|
||||||
To keep build-release's transcripts and the reports small, add a crontab line that gzips each transcript and review file 30 days after it last changed, and logs each run with its date:
|
To keep build-release's transcripts and the reports small, add a crontab line that gzips each transcript and review file 30 days after it last changed, and logs each run with its date:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
17 4 * * * { date; $HOME/.claude/bin/compress-archives; } >> $HOME/.local/state/compress-archives.log 2>&1
|
17 4 * * * mkdir -p $HOME/.local/state/build-release && { date; $HOME/.claude/bin/compress-archives; } >> $HOME/.local/state/build-release/compress-archives.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
Cron runs it with its own `PATH` and environment. Where the `python3` on cron's `PATH` is older than 3.14, or you set `BUILD_RELEASE_TRANSCRIPTS`, set `PATH` or that variable in the crontab too.
|
Cron runs it with its own `PATH` and environment. Where the `python3` on cron's `PATH` is older than 3.14, or you set `BUILD_RELEASE_TRANSCRIPTS` or `XDG_STATE_HOME`, set `PATH` or that variable in the crontab too. With `XDG_STATE_HOME`, write its folder in place of `$HOME/.local/state` in the line as well.
|
||||||
|
|
||||||
To get build-release's questions and stops as DMs from a bot, write the bot's token, your username or member ID and, for Mattermost, the server into `~/.claude-projects/<key>.env`, in the keys `~/.claude/bin/notify --help` names, run `chmod 600` on it, and add `env-file = "~/.claude-projects/<key>.env"` and `notifier = "mattermost"` (or `"slack"`) to the project's config, as Install → "Set up a project" describes.
|
To get build-release's questions and stops as DMs from a bot, write the bot's token, your username or member ID and, for Mattermost, the server into `~/.config/build-release/<key>.env`, in the keys `~/.claude/bin/notify --help` names, run `chmod 600` on it, and add `env-file = "~/.config/build-release/<key>.env"` and `notifier = "mattermost"` (or `"slack"`) to the project's config, as Install → "Set up a project" describes.
|
||||||
|
|
||||||
### Set up a project
|
### Set up a project
|
||||||
|
|
||||||
Each project the loop runs in has a folder, `~/.claude-projects/<key>/`, where `<key>` is the project's name, and a config in it, `config.toml`. The folder is a git repo of its own, so the config has a history and a client's files never enter this repo. The loop commits each change it makes to a file there, such as the plan, in that repo, titled as its commits in the checkout. A project is a whole git checkout, never a subfolder of one.
|
Each project the loop runs in has a folder, `~/.config/build-release/<key>/`, where `<key>` is the project's name, and a config in it, `config.toml`. The folder is a git repo of its own, so the config has a history and a client's files never enter this repo. The loop commits each change it makes to a file there, such as the plan, in that repo, titled as its commits in the checkout. A project is a whole git checkout, never a subfolder of one.
|
||||||
|
|
||||||
The config names the project's main checkout and the path of every file the loop keeps for it. No path setting has a default: `project-config` fails and names each setting a config leaves out. A path is `checkout:<path>` inside the checkout, `folder:<path>` inside the config's folder, or one that starts with `/` or `~/`. Every tool reads and writes each file at the path its setting gives, and `chunk-preflight` and `todo-item` print those paths for the agents. Five of the settings name the project's records: `decisions`, `score-anchors`, `comprehension-history`, `reading-cost` and `changelog`. Keep each file's name, such as `todo.md`: the rules for a file load by its name. A project of your own keeps every file but the principles and the review standards in its checkout:
|
The config names the project's main checkout and the path of every file the loop keeps for it. No path setting has a default: `project-config` fails and names each setting a config leaves out. A path is `checkout:<path>` inside the checkout, `folder:<path>` inside the config's folder, or one that starts with `/` or `~/`. Every tool reads and writes each file at the path its setting gives, and `chunk-preflight` and `todo-item` print those paths for the agents. Five of the settings name the project's records: `decisions`, `score-anchors`, `comprehension-history`, `reading-cost` and `changelog`. Keep each file's name, such as `todo.md`: the rules for a file load by its name. A project of your own keeps every file but the principles and the review standards in its checkout:
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ standards = "~/.claude/skills/larv-review/standards"
|
|||||||
|
|
||||||
`principles` and `standards` name the folders the reviewers hold the project to: the technical principles and the review standards. Both ship with this setup, at the paths above. A folder of your own replaces the shipped one. A standards folder must hold `quality.md`, `prose.md`, `comments.md` and `readme.md`, since the reviewers and the rules name those files.
|
`principles` and `standards` name the folders the reviewers hold the project to: the technical principles and the review standards. Both ship with this setup, at the paths above. A folder of your own replaces the shipped one. A standards folder must hold `quality.md`, `prose.md`, `comments.md` and `readme.md`, since the reviewers and the rules name those files.
|
||||||
|
|
||||||
A project may also set `env-file`, the file of `KEY=value` credentials its tools read, such as `env-file = "~/.claude-projects/log.env"`. It is a path that starts with `/` or `~/`, outside the checkout and the config's folder, so that no git remote receives it. A tool that needs a key fails and names each one the file lacks. No failure message, prompt, log line or archived loop output holds a token from the file. rule-hook refuses a Read or a Grep of the file and a Bash command that names it or searches a folder holding it with `ag`, `grep -r` or `rg`, unless the tool skips the file as hidden or ignored, so a worker doesn't read it in passing; `rule-hook --help` says which calls it checks. A project without the setting has no credentials, and never reads another project's. `project-config env-file` prints the path.
|
A project may also set `env-file`, the file of `KEY=value` credentials its tools read, such as `env-file = "~/.config/build-release/log.env"`. It is a path that starts with `/` or `~/`, outside the checkout and the config's folder, so that no git remote receives it. A tool that needs a key fails and names each one the file lacks. No failure message, prompt, log line or archived loop output holds a token from the file. rule-hook refuses a Read or a Grep of the file and a Bash command that names it or searches a folder holding it with `ag`, `grep -r` or `rg`, unless the tool skips the file as hidden or ignored, so a worker doesn't read it in passing; `rule-hook --help` says which calls it checks. A project without the setting has no credentials, and never reads another project's. `project-config env-file` prints the path.
|
||||||
|
|
||||||
A project may also set `touch-predictions`, a path spelt as `changelog`'s is, such as `touch-predictions = "checkout:docs/touch-predictions.md"`. `touch-predictions record` appends each chunk's predicted files and parts there, beside those it touched. A project that leaves it out keeps no such record.
|
A project may also set `touch-predictions`, a path spelt as `changelog`'s is, such as `touch-predictions = "checkout:docs/touch-predictions.md"`. `touch-predictions record` appends each chunk's predicted files and parts there, beside those it touched. A project that leaves it out keeps no such record.
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ A client that keeps its goals and audience in an epic's description names that e
|
|||||||
To name a chunk's branch, worktree, commits and pull request by the issue key, as in `ABC-123` and `ABC-123 - …`, set these three templates, with your Jira project's key in place of `ABC`: `branch = "ABC-{id}"`, `commit-title = "ABC-{id} - {summary}"` and `pull-request-title = "ABC-{id} - {summary}"`. `project-config --help` says how the templates work.
|
To name a chunk's branch, worktree, commits and pull request by the issue key, as in `ABC-123` and `ABC-123 - …`, set these three templates, with your Jira project's key in place of `ABC`: `branch = "ABC-{id}"`, `commit-title = "ABC-{id} - {summary}"` and `pull-request-title = "ABC-{id} - {summary}"`. `project-config --help` says how the templates work.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p ~/.claude-projects/acme && cd ~/.claude-projects/acme
|
mkdir -p ~/.config/build-release/acme && cd ~/.config/build-release/acme
|
||||||
git init
|
git init
|
||||||
$EDITOR config.toml
|
$EDITOR config.toml
|
||||||
git add config.toml && git commit -m "Add the config"
|
git add config.toml && git commit -m "Add the config"
|
||||||
@@ -176,9 +175,9 @@ cd ~/code/acme-billing && ~/.claude/bin/project-config
|
|||||||
|
|
||||||
The last line prints each setting's path once the config is complete.
|
The last line prints each setting's path once the config is complete.
|
||||||
|
|
||||||
`do-epic` keeps its settings per machine, not per project, in `~/.claude-projects/do-epic/`, two files for every epic:
|
`do-epic` keeps its settings per machine, not per project, in `~/.config/build-release/do-epic/`, two files for every epic:
|
||||||
|
|
||||||
- `config.toml` sets `jira-url`, the site, such as `https://acme.atlassian.net`; `env-file`, the file holding `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, a path that starts with `/` or `~/`, outside the clone folder and every folder of `~/.claude-projects`; and `repoless-model`, the model that works an item with no repo. It may also set `clone-folder`, where a missing repo is cloned, `~/code` if left out; `language`, the language of Jira text, English if left out; and `jira-finish-transition` with `jira-finish-status`, which name the workflow transition that moves a finished chunk's issue, and closes a finished epic, and the status it leads to, such as `"Mark as done"` and `"Done"`. Set both or neither: without them do-epic moves no issue to done and closes no epic, and a chunk that finishes stops with that reason.
|
- `config.toml` sets `jira-url`, the site, such as `https://acme.atlassian.net`; `env-file`, the file holding `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, a path that starts with `/` or `~/`, outside the clone folder and every folder of `~/.config/build-release`; and `repoless-model`, the model that works an item with no repo. It may also set `clone-folder`, where a missing repo is cloned, `~/code` if left out; `language`, the language of Jira text, English if left out; and `jira-finish-transition` with `jira-finish-status`, which name the workflow transition that moves a finished chunk's issue, and closes a finished epic, and the status it leads to, such as `"Mark as done"` and `"Done"`. Set both or neither: without them do-epic moves no issue to done and closes no epic, and a chunk that finishes stops with that reason.
|
||||||
- `config.toml` fits do-epic to a team whose own automation moves issues, such as a CI job that moves an issue when its pull request merges. Two settings do:
|
- `config.toml` fits do-epic to a team whose own automation moves issues, such as a CI job that moves an issue when its pull request merges. Two settings do:
|
||||||
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks, and `--status` names the statuses beside each blocker. A status Jira counts as done always does both. The release reviews, which are the epic's last chunk, still wait until Jira counts every issue done: run `do-epic <EPIC-KEY>` then, to start them.
|
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks, and `--status` names the statuses beside each blocker. A status Jira counts as done always does both. The release reviews, which are the epic's last chunk, still wait until Jira counts every issue done: run `do-epic <EPIC-KEY>` then, to start them.
|
||||||
- `jira-automation-moves-issues = true` keeps do-epic from moving the issue of a finished chunk in a repo: the automation moves it, and do-epic waits for that move before it starts what the issue blocks. An issue without a repo has no pull request, so do-epic still moves it, with `jira-finish-transition`. The setting needs `jira-unblocking-statuses`, which names the status the automation gives an issue whose pull request merged.
|
- `jira-automation-moves-issues = true` keeps do-epic from moving the issue of a finished chunk in a repo: the automation moves it, and do-epic waits for that move before it starts what the issue blocks. An issue without a repo has no pull request, so do-epic still moves it, with `jira-finish-transition`. The setting needs `jira-unblocking-statuses`, which names the status the automation gives an issue whose pull request merged.
|
||||||
@@ -194,7 +193,7 @@ An epic's description states the formula that puts its issues in order: once und
|
|||||||
|
|
||||||
Each repo an epic changes has a project config of its own, as in the rest of this section. `do-epic` fails and names each setting or file that is missing or invalid.
|
Each repo an epic changes has a project config of its own, as in the rest of this section. `do-epic` fails and names each setting or file that is missing or invalid.
|
||||||
|
|
||||||
A project runs on the routing ladder this setup ships, `bin/model_routing/routing-ladder.json`: the rungs, least competent first, each a model at an effort, that build-release routes workers, subagents and reviews to. To run one project on other rungs, as when an outage or a client's account leaves it fewer models, copy that file to `~/.claude-projects/<key>/routing-ladder.json` and cut or change its rungs. Keep one model for each family, such as opus: Claude Code launches a subagent by its family's name. The project's file replaces the shipped ladder whole. build-release reads it as each cycle starts, and `subagent-rung` and rule-hook each time they run. The loop never commits it, so commit it in the folder's repo yourself only where it should last. Set the project's models to ones its ladder holds, for example with `BUILD_RELEASE_WORKER_MODEL` and `BUILD_RELEASE_JUDGE_MODEL`. A model off the ladder is not routed: every worker runs on that model, at the effort Claude Code's `settings.json` gives. Each cycle of a project on a ladder of its own says so on stderr, naming the file, and says where the worker's model is off it. `build-release --help` shows the file's shape.
|
A project runs on the routing ladder this setup ships, `bin/model_routing/routing-ladder.json`: the rungs, least competent first, each a model at an effort, that build-release routes workers, subagents and reviews to. To run one project on other rungs, as when an outage or a client's account leaves it fewer models, copy that file to `~/.config/build-release/<key>/routing-ladder.json` and cut or change its rungs. Keep one model for each family, such as opus: Claude Code launches a subagent by its family's name. The project's file replaces the shipped ladder whole. build-release reads it as each cycle starts, and `subagent-rung` and rule-hook each time they run. The loop never commits it, so commit it in the folder's repo yourself only where it should last. Set the project's models to ones its ladder holds, for example with `BUILD_RELEASE_WORKER_MODEL` and `BUILD_RELEASE_JUDGE_MODEL`. A model off the ladder is not routed: every worker runs on that model, at the effort Claude Code's `settings.json` gives. Each cycle of a project on a ladder of its own says so on stderr, naming the file, and says where the worker's model is off it. `build-release --help` shows the file's shape.
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
@@ -216,7 +215,7 @@ Once the next release holds no item in `todo.md` and its release review has land
|
|||||||
bin/deploy-release --cut
|
bin/deploy-release --cut
|
||||||
```
|
```
|
||||||
|
|
||||||
It renames `## Unreleased` in `CHANGELOG.md` to the version and merges that through a pull request, since nobody can push to `main`. Then it tags the merged commit `v<version>`, pushes the tag, and moves this machine's `~/.claude` to it. Where a step fails it stops with the reason, and a rerun continues where it stopped. A cut keeps each step it finished, with its time in UTC, in a file of its own under `~/.local/state/deploy-release/`. `deploy-release --help` lists the steps. Each other machine takes the release with Update.
|
It renames `## Unreleased` in `CHANGELOG.md` to the version and merges that through a pull request, since nobody can push to `main`. Then it tags the merged commit `v<version>`, pushes the tag, and moves this machine's `~/.claude` to it. Where a step fails it stops with the reason, and a rerun continues where it stopped. A cut keeps each step it finished, with its time in UTC, in a file of its own under `~/.local/state/build-release/deploy-release/`. `deploy-release --help` lists the steps. Each other machine takes the release with Update.
|
||||||
|
|
||||||
A fix that must ship before `main`'s other unreleased work goes out as a patch release, such as 0.15.2 after v0.15.1. File its item under that release, merge its chunk, then cut it at once with the commits the chunk merged, as a range or one commit. A range leaves out its first commit, as git's `..` does, so start it at the commit before the chunk's first:
|
A fix that must ship before `main`'s other unreleased work goes out as a patch release, such as 0.15.2 after v0.15.1. File its item under that release, merge its chunk, then cut it at once with the commits the chunk merged, as a range or one commit. A range leaves out its first commit, as git's `..` does, so start it at the commit before the chunk's first:
|
||||||
|
|
||||||
|
|||||||
@@ -272,14 +272,14 @@ def not_slept(seconds):
|
|||||||
def test_a_heavy_slot_is_held_until_the_block_ends(tmp_path):
|
def test_a_heavy_slot_is_held_until_the_block_ends(tmp_path):
|
||||||
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path)}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path)}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
||||||
assert held is None
|
assert held is None
|
||||||
assert slots.taken_slot(tmp_path / "run-heavy", 1, fcntl.flock) is None
|
assert slots.taken_slot(tmp_path / "build-release" / "run-heavy", 1, fcntl.flock) is None
|
||||||
slot, fd = slots.taken_slot(tmp_path / "run-heavy", 1, fcntl.flock)
|
slot, fd = slots.taken_slot(tmp_path / "build-release" / "run-heavy", 1, fcntl.flock)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
|
|
||||||
def test_a_process_under_run_heavy_takes_no_second_slot(tmp_path):
|
def test_a_process_under_run_heavy_takes_no_second_slot(tmp_path):
|
||||||
(tmp_path / "run-heavy").mkdir()
|
(tmp_path / "build-release" / "run-heavy").mkdir(parents=True)
|
||||||
slot, fd = slots.taken_slot(tmp_path / "run-heavy", 1, fcntl.flock)
|
slot, fd = slots.taken_slot(tmp_path / "build-release" / "run-heavy", 1, fcntl.flock)
|
||||||
try:
|
try:
|
||||||
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path), slots.HELD: "0"}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path), slots.HELD: "0"}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
||||||
assert held is None
|
assert held is None
|
||||||
@@ -288,9 +288,10 @@ def test_a_process_under_run_heavy_takes_no_second_slot(tmp_path):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_heavy_slot_folder_that_cannot_be_made_yields_a_failure(tmp_path):
|
def test_a_heavy_slot_folder_that_cannot_be_made_yields_a_failure(tmp_path):
|
||||||
(tmp_path / "run-heavy").write_text("a file where the folder goes")
|
(tmp_path / "build-release").mkdir()
|
||||||
|
(tmp_path / "build-release" / "run-heavy").write_text("a file where the folder goes")
|
||||||
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path)}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
with convert.heavy_slot({"XDG_STATE_HOME": str(tmp_path)}, tmp_path, 1, not_said, not_slept, fcntl.flock) as held:
|
||||||
assert isinstance(held, Failure) and held.reason.startswith(f"cannot take a heavy slot in {tmp_path / 'run-heavy'}: ")
|
assert isinstance(held, Failure) and held.reason.startswith(f"cannot take a heavy slot in {tmp_path / 'build-release' / 'run-heavy'}: ")
|
||||||
|
|
||||||
|
|
||||||
def test_container_run_runs_the_image_on_the_text(tmp_path):
|
def test_container_run_runs_the_image_on_the_text(tmp_path):
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Interrupts(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.home = pathlib.Path(tempfile.mkdtemp())
|
self.home = pathlib.Path(tempfile.mkdtemp())
|
||||||
self.addCleanup(shutil.rmtree, self.home)
|
self.addCleanup(shutil.rmtree, self.home)
|
||||||
self.paths = paths.paths_from(self.home)
|
self.paths = paths.paths_from(self.home, {})
|
||||||
self.transcript = self.home / "t.jsonl"
|
self.transcript = self.home / "t.jsonl"
|
||||||
self.transcript.write_text(json.dumps(human("a")) + "\n")
|
self.transcript.write_text(json.dumps(human("a")) + "\n")
|
||||||
self.session = interrupt.WorkerSession(str(self.home), uuid.uuid7(), Rung("m", "high"), Rung("m", "high"), str(self.transcript), {"BUILD_RELEASE_WORKER_RUNG": "m at high effort"})
|
self.session = interrupt.WorkerSession(str(self.home), uuid.uuid7(), Rung("m", "high"), Rung("m", "high"), str(self.transcript), {"BUILD_RELEASE_WORKER_RUNG": "m at high effort"})
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Cycles(unittest.TestCase):
|
|||||||
temp = tempfile.TemporaryDirectory()
|
temp = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(temp.cleanup)
|
self.addCleanup(temp.cleanup)
|
||||||
self.home = pathlib.Path(temp.name)
|
self.home = pathlib.Path(temp.name)
|
||||||
self.paths = paths.paths_from(self.home)
|
self.paths = paths.paths_from(self.home, {})
|
||||||
self.session = session.session_named("A proj a-driver", self.paths.claude_code_transcripts)
|
self.session = session.session_named("A proj a-driver", self.paths.claude_code_transcripts)
|
||||||
self.archive = project_archive(str(self.home / "code" / "proj"), self.home, {})
|
self.archive = project_archive(str(self.home / "code" / "proj"), self.home, {})
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from branch_chunks.fixes import blamed, fixing_changes, FixingChange, removed_work, Traced, with_fixes
|
from branch_chunks.fixes import blamed, fixing_changes, FixingChange, removed_work, Traced, with_fixes
|
||||||
@@ -15,9 +16,9 @@ from project_config import templates
|
|||||||
READ_AT = {"plan": NOT_WORK[0], "comprehension-history": NOT_WORK[1], "reading-cost": NOT_WORK[2]}
|
READ_AT = {"plan": NOT_WORK[0], "comprehension-history": NOT_WORK[1], "reading-cost": NOT_WORK[2]}
|
||||||
|
|
||||||
|
|
||||||
def unsupported(checkout: str | None, home: pathlib.Path, run: Git = git) -> str | None:
|
def unsupported(checkout: str | None, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> str | None:
|
||||||
"""Why branch_chunks cannot tell what the chunks of checkout's project shipped, else the current directory's: its config under home puts the plan or a record where their commits are not read. None where it can, as for a checkout no config names."""
|
"""Why branch_chunks cannot tell what the chunks of checkout's project shipped, else the current directory's: its config under home puts the plan or a record where their commits are not read. None where it can, as for a checkout no config names."""
|
||||||
config = located(checkout, home, run)
|
config = located(checkout, home, env, run)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return None
|
return None
|
||||||
elsewhere = [label for name, path in READ_AT.items() for label, tracked in [held(config, name)] if tracked != path]
|
elsewhere = [label for name, path in READ_AT.items() for label, tracked in [held(config, name)] if tracked != path]
|
||||||
|
|||||||
@@ -207,13 +207,13 @@ class Unsupported(unittest.TestCase):
|
|||||||
def test_says_which_files_the_config_puts_where_no_commits_are_read(self):
|
def test_says_which_files_the_config_puts_where_no_commits_are_read(self):
|
||||||
checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())).resolve()
|
checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())).resolve()
|
||||||
run = functools.partial(git, env=isolated_env())
|
run = functools.partial(git, env=isolated_env())
|
||||||
self.assertIsNone(unsupported(str(checkout), checkout, run), "no git checkout, so no config names it")
|
self.assertIsNone(unsupported(str(checkout), checkout, {}, run), "no git checkout, so no config names it")
|
||||||
folder = configured(self, checkout)
|
folder = configured(self, checkout)
|
||||||
home = folder.parents[1]
|
home = folder.parents[2]
|
||||||
self.assertIsNone(unsupported(str(checkout), home, run))
|
self.assertIsNone(unsupported(str(checkout), home, {}, run))
|
||||||
config = folder / "config.toml"
|
config = folder / "config.toml"
|
||||||
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"').replace('"checkout:docs/reading-cost.md"', '"checkout:records/reading-cost.md"'))
|
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"').replace('"checkout:docs/reading-cost.md"', '"checkout:records/reading-cost.md"'))
|
||||||
self.assertEqual(unsupported(str(checkout), home, run), f"the project's config puts {folder}/todo.md, {checkout}/records/reading-cost.md elsewhere than todo.md, docs/comprehension-history.md, docs/reading-cost.md in the checkout, the only paths whose commits are read so far")
|
self.assertEqual(unsupported(str(checkout), home, {}, run), f"the project's config puts {folder}/todo.md, {checkout}/records/reading-cost.md elsewhere than todo.md, docs/comprehension-history.md, docs/reading-cost.md in the checkout, the only paths whose commits are read so far")
|
||||||
|
|
||||||
|
|
||||||
class TracedTo(unittest.TestCase):
|
class TracedTo(unittest.TestCase):
|
||||||
|
|||||||
+1
-1
@@ -10,4 +10,4 @@ from loop_effects import effects
|
|||||||
from build_release.loop import main
|
from build_release.loop import main
|
||||||
from loop_state import paths
|
from loop_state import paths
|
||||||
|
|
||||||
sys.exit(main.main(sys.argv[1:], os.environ, paths.paths_from(pathlib.Path.home()), LAUNCHER, pathlib.Path.cwd(), effects.system_effects(pathlib.Path.home(), os.environ)))
|
sys.exit(main.main(sys.argv[1:], os.environ, paths.paths_from(pathlib.Path.home(), os.environ), LAUNCHER, pathlib.Path.cwd(), effects.system_effects(pathlib.Path.home(), os.environ)))
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def chunk_facts(loop: Loop) -> str:
|
|||||||
|
|
||||||
def fetched_plan(loop: Loop, announce: bool = True) -> DefaultPlan | Failure:
|
def fetched_plan(loop: Loop, announce: bool = True) -> DefaultPlan | Failure:
|
||||||
"""What the default branch, as last fetched, holds for routing; the plan and the changelog as they stand where the project's config puts them outside the checkout. Where announce is True, as when a chunk starts, it says UNSEEN_RELEASES for such a plan, so the human reads it once per chunk, not every cycle."""
|
"""What the default branch, as last fetched, holds for routing; the plan and the changelog as they stand where the project's config puts them outside the checkout. Where announce is True, as when a chunk starts, it says UNSEEN_RELEASES for such a plan, so the human reads it once per chunk, not every cycle."""
|
||||||
config = located(loop.root, loop.paths.home)
|
config = located(loop.root, loop.paths.home, loop.env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
if announce and config.tracked("plan") is None:
|
if announce and config.tracked("plan") is None:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from plan.touches import overlaps, predicted, Touches
|
|||||||
from loop_state.paths import Paths
|
from loop_state.paths import Paths
|
||||||
from transcript_archive.project_key import project_key
|
from transcript_archive.project_key import project_key
|
||||||
from release_plan.release_standing import project_plan
|
from release_plan.release_standing import project_plan
|
||||||
|
from project_config.settings import ProjectConfig
|
||||||
from claude_code.transcript import read_transcript
|
from claude_code.transcript import read_transcript
|
||||||
from claude_code.session import Session, session_named, transcript_file
|
from claude_code.session import Session, session_named, transcript_file
|
||||||
from agent_cycle import tmux
|
from agent_cycle import tmux
|
||||||
@@ -100,11 +101,8 @@ def clear_of(ours: Touches | Failure | None, theirs: list[Touches | Failure | No
|
|||||||
return not theirs or (isinstance(ours, dict) and all(isinstance(touches, dict) and not overlaps(ours, touches) for touches in theirs))
|
return not theirs or (isinstance(ours, dict) and all(isinstance(touches, dict) and not overlaps(ours, touches) for touches in theirs))
|
||||||
|
|
||||||
|
|
||||||
def next_plan(root: str, home: pathlib.Path, effects: Effects) -> NextChunk | NoItem | Failure:
|
def next_plan(root: str, config: ProjectConfig, effects: Effects) -> NextChunk | NoItem | Failure:
|
||||||
"""The plan on the default branch, fetched now where origin answers, with its next item, as chunk-preflight reads it."""
|
"""The plan config names, on the default branch of the checkout root, fetched now where origin answers, with its next item, as chunk-preflight reads it."""
|
||||||
config = located(root, home)
|
|
||||||
if isinstance(config, Failure):
|
|
||||||
return config
|
|
||||||
# A chunk that just merged left the plan on origin. A fetch that fails leaves the plan as last fetched, which chunk-preflight then reads too.
|
# A chunk that just merged left the plan on origin. A fetch that fails leaves the plan as last fetched, which chunk-preflight then reads too.
|
||||||
effects.git("fetch", "--quiet", "origin", cwd=root, timeout=FETCH_TIMEOUT)
|
effects.git("fetch", "--quiet", "origin", cwd=root, timeout=FETCH_TIMEOUT)
|
||||||
ref = default_ref(root, FETCH_TIMEOUT, run=effects.git)
|
ref = default_ref(root, FETCH_TIMEOUT, run=effects.git)
|
||||||
@@ -116,18 +114,18 @@ def next_plan(root: str, home: pathlib.Path, effects: Effects) -> NextChunk | No
|
|||||||
|
|
||||||
def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Mapping[str, str], launcher: pathlib.Path, effects: Effects) -> list[str] | AwaitedMerges | Failure:
|
def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Mapping[str, str], launcher: pathlib.Path, effects: Effects) -> list[str] | AwaitedMerges | Failure:
|
||||||
"""Starts a build-release in a new window for each chunk of loop_run's project that may start now, and returns the chunks started. leaving says that loop_run's own chunk finished, so its window no longer counts as running; without it, the human started build-release. AwaitedMerges where chunks_to_start returns it. A Failure says why no chunk may start, or why one could not; those before it run."""
|
"""Starts a build-release in a new window for each chunk of loop_run's project that may start now, and returns the chunks started. leaving says that loop_run's own chunk finished, so its window no longer counts as running; without it, the human started build-release. AwaitedMerges where chunks_to_start returns it. A Failure says why no chunk may start, or why one could not; those before it run."""
|
||||||
config = located(loop_run.root, paths.home)
|
config = located(loop_run.root, paths.home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
session = loop_session(loop_run.root, paths.home)
|
session = loop_session(loop_run.root, paths.home)
|
||||||
handed = {name: value for name, value in env.items() if name.startswith(HANDED)}
|
handed = {name: value for name, value in env.items() if name.startswith(HANDED)}
|
||||||
with starting(project_lock(loop_run.root, paths.home)) as unlocked:
|
with starting(project_lock(loop_run.root, paths)) as unlocked:
|
||||||
if unlocked:
|
if unlocked:
|
||||||
return unlocked
|
return unlocked
|
||||||
windows = tmux.listed(session, effects.tmux)
|
windows = tmux.listed(session, effects.tmux)
|
||||||
if refused := refusal(session, windows, loop_run.root, effects.tmux):
|
if refused := refusal(session, windows, loop_run.root, effects.tmux):
|
||||||
return refused
|
return refused
|
||||||
chunks = chunks_to_start(windows, loop_run, leaving, config.parallel_chunks, paths, effects)
|
chunks = chunks_to_start(windows, loop_run, leaving, config, paths, effects)
|
||||||
if isinstance(chunks, AwaitedMerges):
|
if isinstance(chunks, AwaitedMerges):
|
||||||
return chunks
|
return chunks
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
@@ -147,12 +145,12 @@ def refusal(session: str, windows: list[tmux.Listed], root: str, run: tmux.Tmux)
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool, limit: int, paths: Paths, effects: Effects) -> list[str] | AwaitedMerges:
|
def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool, config: ProjectConfig, paths: Paths, effects: Effects) -> list[str] | AwaitedMerges:
|
||||||
"""The chunks to start beside windows, the session's: the stopped ones room_of restarts, then those of the plan that may_start picks. A plan that cannot be read starts NO_ITEM, as a plan without an item does. AwaitedMerges where no chunk runs or restarts and every item left awaits a person's merge."""
|
"""The chunks to start beside windows, the session's: the stopped ones room_of restarts, then those of the plan that may_start picks. A plan that cannot be read starts NO_ITEM, as a plan without an item does. AwaitedMerges where no chunk runs or restarts and every item left awaits a person's merge."""
|
||||||
room = room_of(windows, loop_run.chunk, leaving, limit)
|
room = room_of(windows, loop_run.chunk, leaving, config.parallel_chunks)
|
||||||
if not room.left:
|
if not room.left:
|
||||||
return room.restart
|
return room.restart
|
||||||
plan = next_plan(loop_run.root, paths.home, effects)
|
plan = next_plan(loop_run.root, config, effects)
|
||||||
if isinstance(plan, Failure):
|
if isinstance(plan, Failure):
|
||||||
# Such as in a checkout without a default branch, where chunk-preflight fails too: the worker is told why and finds the facts itself.
|
# Such as in a checkout without a default branch, where chunk-preflight fails too: the worker is told why and finds the facts itself.
|
||||||
say(f"starting a chunk without a plan item, since the plan cannot be read: {plan.reason}", effects)
|
say(f"starting a chunk without a plan item, since the plan cannot be read: {plan.reason}", effects)
|
||||||
@@ -166,12 +164,12 @@ def chunks_to_start(windows: list[tmux.Listed], loop_run: LoopRun, leaving: bool
|
|||||||
|
|
||||||
def held_beside(chunk: str, root: str, paths: Paths, effects: Effects) -> list[int]:
|
def held_beside(chunk: str, root: str, paths: Paths, effects: Effects) -> list[int]:
|
||||||
"""The plan items that the project's other chunks hold now, running or stopped, which a chunk starting as `chunk` leaves to them. It waits for a loop that is starting windows, so chunks started together see each other. Where the lock cannot be taken, it reads the windows without it."""
|
"""The plan items that the project's other chunks hold now, running or stopped, which a chunk starting as `chunk` leaves to them. It waits for a loop that is starting windows, so chunks started together see each other. Where the lock cannot be taken, it reads the windows without it."""
|
||||||
wait_for_starts(root, paths.home)
|
wait_for_starts(root, paths)
|
||||||
others = [window.name for window in tmux.listed(loop_session(root, paths.home), effects.tmux) if window.name != chunk]
|
others = [window.name for window in tmux.listed(loop_session(root, paths.home), effects.tmux) if window.name != chunk]
|
||||||
return sorted(held_items(others, project_key(root, paths.home), paths.claude_code_transcripts))
|
return sorted(held_items(others, project_key(root, paths.home), paths.claude_code_transcripts))
|
||||||
|
|
||||||
|
|
||||||
def wait_for_starts(root: str, home: pathlib.Path) -> None:
|
def wait_for_starts(root: str, paths: Paths) -> None:
|
||||||
"""Returns once no loop of the project is starting windows: start_chunks holds the lock file `claims.LOCK` names while it starts them. Where the lock cannot be taken, it returns at once."""
|
"""Returns once no loop of the project is starting windows: start_chunks holds the lock file `claims.LOCK` names while it starts them. Where the lock cannot be taken, it returns at once."""
|
||||||
with starting(project_lock(root, home)):
|
with starting(project_lock(root, paths)):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ def handed_on(loop_run: LoopRun, loop: Loop, start: StartChunks) -> Stop:
|
|||||||
|
|
||||||
def next_cycle(loop_run: LoopRun, loop: Loop) -> Cycle | Stop:
|
def next_cycle(loop_run: LoopRun, loop: Loop) -> Cycle | Stop:
|
||||||
"""The cycle loop_run runs next, from the premises, the records, the project's models and its routing ladder read afresh, and the route the chunk runs on; the stop where one of them cannot be read."""
|
"""The cycle loop_run runs next, from the premises, the records, the project's models and its routing ladder read afresh, and the route the chunk runs on; the stop where one of them cannot be read."""
|
||||||
premises = read_premises(loop.root, loop.paths.home)
|
premises = read_premises(loop.root, loop.paths.home, loop.env)
|
||||||
if isinstance(premises, Failure):
|
if isinstance(premises, Failure):
|
||||||
return Stop(1, premises.reason)
|
return Stop(1, premises.reason)
|
||||||
records = read_records(loop.root, loop.paths.home, loop.paths.claude_dir)
|
records = read_records(loop.root, loop.paths.home, loop.env, loop.paths.claude_dir)
|
||||||
if isinstance(records, Failure):
|
if isinstance(records, Failure):
|
||||||
return Stop(1, records.reason)
|
return Stop(1, records.reason)
|
||||||
routing = project_routing(loop, fresh_prompt.DRIVER)
|
routing = project_routing(loop, fresh_prompt.DRIVER)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Every state.CYCLES_PER_CHECK cycles across all projects, measure the archive's routing figures, keep them at its root, and interrupt the human with each call for a routing change not raised before: docs/decisions.md → `routing: build-release measures review rounds…`."""
|
"""Every state.CYCLES_PER_CHECK cycles across all projects, measure the archive's routing figures, keep them at its root, and interrupt the human with each call for a routing change not raised before: docs/decisions.md → `routing: build-release measures review rounds…`."""
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from routing_figures import archive
|
from routing_figures import archive
|
||||||
@@ -20,14 +21,14 @@ from text_files.utc_stamp import utc
|
|||||||
def check_routing(root: pathlib.Path, rung: Rung, loop: Loop) -> Stop | None:
|
def check_routing(root: pathlib.Path, rung: Rung, loop: Loop) -> Stop | None:
|
||||||
"""Stops only when claude cannot start for the calls; a figure it cannot measure or keep is said on stderr, and the loop goes on. root is the archive's, and rung is the rung of the claude that puts the calls to the human."""
|
"""Stops only when claude cannot start for the calls; a figure it cannot measure or keep is said on stderr, and the loop goes on. root is the archive's, and rung is the rung of the claude that puts the calls to the human."""
|
||||||
with archive.locked(root) as held:
|
with archive.locked(root) as held:
|
||||||
new = new_calls(root, loop.paths, loop.effects) if held else []
|
new = new_calls(root, loop.paths, loop.env, loop.effects) if held else []
|
||||||
if isinstance(new, Failure):
|
if isinstance(new, Failure):
|
||||||
say(f"routing figures: {new.reason}", loop.effects)
|
say(f"routing figures: {new.reason}", loop.effects)
|
||||||
return None
|
return None
|
||||||
return raise_calls(root, new, rung, loop) if new else None
|
return raise_calls(root, new, rung, loop) if new else None
|
||||||
|
|
||||||
|
|
||||||
def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[Call] | Failure:
|
def new_calls(root: pathlib.Path, paths: Paths, env: Mapping[str, str], effects: Effects) -> list[Call] | Failure:
|
||||||
"""Once due, measures and keeps the figures, and returns their calls not raised since the latest reset; none while not due."""
|
"""Once due, measures and keeps the figures, and returns their calls not raised since the latest reset; none while not due."""
|
||||||
cycle = archive.cycles(root)
|
cycle = archive.cycles(root)
|
||||||
if isinstance(cycle, Failure):
|
if isinstance(cycle, Failure):
|
||||||
@@ -39,7 +40,7 @@ def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[Call]
|
|||||||
if isinstance(raised, Failure):
|
if isinstance(raised, Failure):
|
||||||
return raised
|
return raised
|
||||||
say(f"\n=== cycle {cycle} across build-release's archive: measuring the routing figures ===", effects, stdout=True)
|
say(f"\n=== cycle {cycle} across build-release's archive: measuring the routing figures ===", effects, stdout=True)
|
||||||
measured = archive.measure_archive(root, str(paths.home), raised.since, effects.git)
|
measured = archive.measure_archive(root, str(paths.home), env, raised.since, effects.git)
|
||||||
if isinstance(measured, Failure):
|
if isinstance(measured, Failure):
|
||||||
return measured
|
return measured
|
||||||
# The shipped ladder, not the project's: the figures span every project.
|
# The shipped ladder, not the project's: the figures span every project.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from release_plan.release_standing import DefaultPlan, LastCut, UNSEEN_RELEASES
|
|||||||
from failure import Failure
|
from failure import Failure
|
||||||
from loop_effects.doubles import FakeEffects, ran, STAMP
|
from loop_effects.doubles import FakeEffects, ran, STAMP
|
||||||
from build_release.chunk import fresh_prompt
|
from build_release.chunk import fresh_prompt
|
||||||
|
from project_config.main import located
|
||||||
from build_release.doubles import NO_CUT, TODO
|
from build_release.doubles import NO_CUT, TODO
|
||||||
from loop_state import paths
|
from loop_state import paths
|
||||||
from plan_store.todo_md import plan_of
|
from plan_store.todo_md import plan_of
|
||||||
@@ -50,7 +51,7 @@ class RouteSources(unittest.TestCase):
|
|||||||
unread = Failure("no git")
|
unread = Failure("no git")
|
||||||
fake = FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread])
|
fake = FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread])
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||||
facts, held = chunk_start.chunk_start(a_loop(fake.effects(), root=root, session=opened, paths=paths.paths_from(folder.parents[1])))
|
facts, held = chunk_start.chunk_start(a_loop(fake.effects(), root=root, session=opened, paths=paths.paths_from(folder.parents[2], {})))
|
||||||
self.assertEqual((facts, held.plan), ("", plan_of(TODO)))
|
self.assertEqual((facts, held.plan), ("", plan_of(TODO)))
|
||||||
self.assertEqual([args for args in fake.made("git") if args[0] == "remote"], [["remote"]])
|
self.assertEqual([args for args in fake.made("git") if args[0] == "remote"], [["remote"]])
|
||||||
# An open session is no fresh chunk, so the human isn't told again of releases the plan cannot show.
|
# An open session is no fresh chunk, so the human isn't told again of releases the plan cannot show.
|
||||||
@@ -79,7 +80,7 @@ class RouteSources(unittest.TestCase):
|
|||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
folder = configured(self, pathlib.Path(root))
|
folder = configured(self, pathlib.Path(root))
|
||||||
effects = dataclasses.replace(FakeEffects().effects(), git=git)
|
effects = dataclasses.replace(FakeEffects().effects(), git=git)
|
||||||
held = chunk_start.fetched_plan(a_loop(effects, root=root, paths=paths.paths_from(folder.parents[1])))
|
held = chunk_start.fetched_plan(a_loop(effects, root=root, paths=paths.paths_from(folder.parents[2], {})))
|
||||||
self.assertEqual(held.cut.changelog, "what origin/main:CHANGELOG.md holds\n")
|
self.assertEqual(held.cut.changelog, "what origin/main:CHANGELOG.md holds\n")
|
||||||
|
|
||||||
def test_passes_over_an_item_whose_pull_request_awaits_a_persons_merge_as_the_loops_forge_lists_them(self):
|
def test_passes_over_an_item_whose_pull_request_awaits_a_persons_merge_as_the_loops_forge_lists_them(self):
|
||||||
@@ -96,33 +97,35 @@ class RouteSources(unittest.TestCase):
|
|||||||
folder = configured(self, pathlib.Path(root))
|
folder = configured(self, pathlib.Path(root))
|
||||||
(folder / "config.toml").write_text((folder / "config.toml").read_text() + 'merge = "human"\n')
|
(folder / "config.toml").write_text((folder / "config.toml").read_text() + 'merge = "human"\n')
|
||||||
fake = FakeEffects(forge=[f"12\thttps://github.com/o/r/pull/12\t{head}\tfalse\tfalse\n"] * 3)
|
fake = FakeEffects(forge=[f"12\thttps://github.com/o/r/pull/12\t{head}\tfalse\tfalse\n"] * 3)
|
||||||
held = chunk_start.fetched_plan(a_loop(dataclasses.replace(fake.effects(), git=git), root=root, paths=paths.paths_from(folder.parents[1])))
|
held = chunk_start.fetched_plan(a_loop(dataclasses.replace(fake.effects(), git=git), root=root, paths=paths.paths_from(folder.parents[2], {})))
|
||||||
self.assertEqual([(item.id, item.awaits_merge) for item in held.plan.items], [(7, ""), (3, "#12 https://github.com/o/r/pull/12"), (1, "")])
|
self.assertEqual([(item.id, item.awaits_merge) for item in held.plan.items], [(7, ""), (3, "#12 https://github.com/o/r/pull/12"), (1, "")])
|
||||||
self.assertEqual(fake.made("forge")[0][:4], [root, "gh", "pr", "list"])
|
self.assertEqual(fake.made("forge")[0][:4], [root, "gh", "pr", "list"])
|
||||||
self.assertIsNone(chunk_start.plan_item(held, None, fake.effects()), "items 7 and 3 wait, so no item of the next release routes the chunk")
|
self.assertIsNone(chunk_start.plan_item(held, None, fake.effects()), "items 7 and 3 wait, so no item of the next release routes the chunk")
|
||||||
window = chunk_windows.next_plan(root, folder.parents[1], dataclasses.replace(fake.effects(), git=git))
|
config = located(root, folder.parents[2], {})
|
||||||
|
assert not isinstance(config, Failure), config
|
||||||
|
window = chunk_windows.next_plan(root, config, dataclasses.replace(fake.effects(), git=git))
|
||||||
self.assertEqual((window.awaits_merge, fake.made("forge")[1][:4]), (True, [root, "gh", "pr", "list"]), "a window starts by the same pick")
|
self.assertEqual((window.awaits_merge, fake.made("forge")[1][:4]), (True, [root, "gh", "pr", "list"]), "a window starts by the same pick")
|
||||||
stopped = chunk_windows.chunks_to_start([], reload.LoopRun(1, root, "do it", ""), False, 1, paths.paths_from(folder.parents[1]), dataclasses.replace(fake.effects(), git=git))
|
stopped = chunk_windows.chunks_to_start([], reload.LoopRun(1, root, "do it", ""), False, config, paths.paths_from(folder.parents[2], {}), dataclasses.replace(fake.effects(), git=git))
|
||||||
self.assertEqual(stopped, chunk_windows.AwaitedMerges(window.why), "so the loop starts no chunk, and says which pull requests it waits on")
|
self.assertEqual(stopped, chunk_windows.AwaitedMerges(window.why), "so the loop starts no chunk, and says which pull requests it waits on")
|
||||||
|
|
||||||
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_stops_without_a_config(self):
|
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_stops_without_a_config(self):
|
||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
folder = configured(self, pathlib.Path(root))
|
folder = configured(self, pathlib.Path(root))
|
||||||
loop = a_loop(FakeEffects(git=[*ON_MAIN] * 2).effects(), root=root, paths=paths.paths_from(folder.parents[1]))
|
loop = a_loop(FakeEffects(git=[*ON_MAIN] * 2).effects(), root=root, paths=paths.paths_from(folder.parents[2], {}))
|
||||||
config = folder / "config.toml"
|
config = folder / "config.toml"
|
||||||
tracked = a_loop(FakeEffects(git=[*ON_MAIN, *[Failure("no git")] * 4]).effects(), root=root, paths=paths.paths_from(folder.parents[1]))
|
tracked = a_loop(FakeEffects(git=[*ON_MAIN, *[Failure("no git")] * 4]).effects(), root=root, paths=paths.paths_from(folder.parents[2], {}))
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||||
chunk_start.fetched_plan(tracked)
|
chunk_start.fetched_plan(tracked)
|
||||||
self.assertEqual(stderr.getvalue(), "", "a plan git tracks hides no release")
|
self.assertEqual(stderr.getvalue(), "", "a plan git tracks hides no release")
|
||||||
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||||
(folder / "todo.md").write_text(TODO)
|
(folder / "todo.md").write_text(TODO)
|
||||||
unread = Failure("no git")
|
unread = Failure("no git")
|
||||||
standing = a_loop(FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[1]))
|
standing = a_loop(FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[2], {}))
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||||
held = chunk_start.fetched_plan(standing)
|
held = chunk_start.fetched_plan(standing)
|
||||||
self.assertEqual((held.plan, held.cut.todos_since, held.cut.changelog), (plan_of(TODO), [], ""), "the plan as it stands, whatever git answers")
|
self.assertEqual((held.plan, held.cut.todos_since, held.cut.changelog), (plan_of(TODO), [], ""), "the plan as it stands, whatever git answers")
|
||||||
self.assertEqual(stderr.getvalue(), f"{STAMP} {UNSEEN_RELEASES}\n", "a release review build-release cannot call due is never skipped silently")
|
self.assertEqual(stderr.getvalue(), f"{STAMP} {UNSEEN_RELEASES}\n", "a release review build-release cannot call due is never skipped silently")
|
||||||
quiet = a_loop(FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[1]))
|
quiet = a_loop(FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[2], {}))
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||||
chunk_start.fetched_plan(quiet, announce=False)
|
chunk_start.fetched_plan(quiet, announce=False)
|
||||||
self.assertEqual(stderr.getvalue(), "", "said once per chunk, as it starts")
|
self.assertEqual(stderr.getvalue(), "", "said once per chunk, as it starts")
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class ChunkWindows(unittest.TestCase):
|
|||||||
def test_tells_a_chunk_the_items_the_projects_other_live_chunks_hold(self):
|
def test_tells_a_chunk_the_items_the_projects_other_live_chunks_hold(self):
|
||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
home = pathlib.Path(temp)
|
home = pathlib.Path(temp)
|
||||||
held = paths.paths_from(home)
|
held = paths.paths_from(home, {})
|
||||||
folder = held.claude_code_transcripts / "-r"
|
folder = held.claude_code_transcripts / "-r"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
lines = [assistant({"type": "text", "text": "Chunk items: 8 (L 1, E + I 2), 11 (L 2, E + I 3)"})]
|
lines = [assistant({"type": "text", "text": "Chunk items: 8 (L 1, E + I 2), 11 (L 2, E + I 3)"})]
|
||||||
@@ -118,13 +118,13 @@ class StartChunks(unittest.TestCase):
|
|||||||
made = tempfile.TemporaryDirectory()
|
made = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(made.cleanup)
|
self.addCleanup(made.cleanup)
|
||||||
self.root = pathlib.Path(made.name, "r")
|
self.root = pathlib.Path(made.name, "r")
|
||||||
self.home = configured(self, self.root).parents[1]
|
self.home = configured(self, self.root).parents[2]
|
||||||
self.session = "loop-" + str(self.root).lstrip("/").replace("/", "-").replace(".", "-")
|
self.session = "loop-" + str(self.root).lstrip("/").replace("/", "-").replace(".", "-")
|
||||||
# Items 1 and 2 overlap, so 2 waits; 3 runs beside 1.
|
# Items 1 and 2 overlap, so 2 waits; 3 runs beside 1.
|
||||||
self.plan = plan_text("a.py", "a.py", "c.py")
|
self.plan = plan_text("a.py", "a.py", "c.py")
|
||||||
|
|
||||||
def limit(self, chunks):
|
def limit(self, chunks):
|
||||||
config = self.home / ".claude-projects" / self.root.name / "config.toml"
|
config = self.home / ".config/build-release" / self.root.name / "config.toml"
|
||||||
config.write_text(config.read_text() + f"parallel-chunks = {chunks}\n")
|
config.write_text(config.read_text() + f"parallel-chunks = {chunks}\n")
|
||||||
|
|
||||||
def start(self, fake, chunk=None, leaving=False, plan=None, env=None, owner=None):
|
def start(self, fake, chunk=None, leaving=False, plan=None, env=None, owner=None):
|
||||||
@@ -134,7 +134,7 @@ class StartChunks(unittest.TestCase):
|
|||||||
ran = []
|
ran = []
|
||||||
effects = dataclasses.replace(fake.effects(), git=self.git_reading(self.plan if plan is None else plan, ran))
|
effects = dataclasses.replace(fake.effects(), git=self.git_reading(self.plan if plan is None else plan, ran))
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||||
started = chunk_windows.start_chunks(run, leaving, paths.paths_from(self.home), env or {}, self.LAUNCHER, effects)
|
started = chunk_windows.start_chunks(run, leaving, paths.paths_from(self.home, env or {}), env or {}, self.LAUNCHER, effects)
|
||||||
self.said = said.getvalue()
|
self.said = said.getvalue()
|
||||||
fetches = [args for args in ran if args[0] == "fetch"]
|
fetches = [args for args in ran if args[0] == "fetch"]
|
||||||
self.planned = len(fetches)
|
self.planned = len(fetches)
|
||||||
@@ -188,7 +188,7 @@ class StartChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_leaves_out_the_items_a_running_chunk_names_on_its_chunk_items_line(self):
|
def test_leaves_out_the_items_a_running_chunk_names_on_its_chunk_items_line(self):
|
||||||
self.limit(2)
|
self.limit(2)
|
||||||
transcripts = paths.paths_from(self.home).claude_code_transcripts
|
transcripts = paths.paths_from(self.home, {}).claude_code_transcripts
|
||||||
folder = transcripts / "-r"
|
folder = transcripts / "-r"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
opened = chunk_windows.chunk_session(str(self.root).lstrip("/"), "item-5", transcripts)
|
opened = chunk_windows.chunk_session(str(self.root).lstrip("/"), "item-5", transcripts)
|
||||||
@@ -232,7 +232,7 @@ class StartChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_a_finishing_chunk_leaves_a_stopped_chunk_and_its_items_to_the_human(self):
|
def test_a_finishing_chunk_leaves_a_stopped_chunk_and_its_items_to_the_human(self):
|
||||||
self.limit(2)
|
self.limit(2)
|
||||||
transcripts = paths.paths_from(self.home).claude_code_transcripts
|
transcripts = paths.paths_from(self.home, {}).claude_code_transcripts
|
||||||
folder = transcripts / "-r"
|
folder = transcripts / "-r"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
opened = chunk_windows.chunk_session(str(self.root).lstrip("/"), "item-5", transcripts)
|
opened = chunk_windows.chunk_session(str(self.root).lstrip("/"), "item-5", transcripts)
|
||||||
@@ -256,10 +256,11 @@ class StartChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_says_why_it_cannot_take_the_lock_on_starting_windows(self):
|
def test_says_why_it_cannot_take_the_lock_on_starting_windows(self):
|
||||||
(self.home / ".local" / "state").mkdir(parents=True)
|
(self.home / ".local" / "state").mkdir(parents=True)
|
||||||
(self.home / ".local" / "state" / "loop-claude").write_text("")
|
(self.home / ".local" / "state" / "build-release").mkdir(parents=True, exist_ok=True)
|
||||||
|
(self.home / ".local" / "state" / "build-release" / "claims").write_text("")
|
||||||
started = self.start(FakeEffects())
|
started = self.start(FakeEffects())
|
||||||
self.assertIsInstance(started, Failure)
|
self.assertIsInstance(started, Failure)
|
||||||
self.assertTrue(started.reason.startswith(f"cannot lock {self.home}/.local/state/loop-claude/"), started.reason)
|
self.assertTrue(started.reason.startswith(f"cannot lock {self.home}/.local/state/build-release/claims/"), started.reason)
|
||||||
|
|
||||||
def test_an_error_raised_under_the_lock_is_not_reported_as_the_locks(self):
|
def test_an_error_raised_under_the_lock_is_not_reported_as_the_locks(self):
|
||||||
with self.assertRaisesRegex(OSError, "the plan's disk is gone"):
|
with self.assertRaisesRegex(OSError, "the plan's disk is gone"):
|
||||||
@@ -267,9 +268,10 @@ class StartChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_a_chunk_reads_the_other_windows_where_it_cannot_take_the_lock(self):
|
def test_a_chunk_reads_the_other_windows_where_it_cannot_take_the_lock(self):
|
||||||
(self.home / ".local" / "state").mkdir(parents=True)
|
(self.home / ".local" / "state").mkdir(parents=True)
|
||||||
(self.home / ".local" / "state" / "loop-claude").write_text("")
|
(self.home / ".local" / "state" / "build-release").mkdir(parents=True, exist_ok=True)
|
||||||
|
(self.home / ".local" / "state" / "build-release" / "claims").write_text("")
|
||||||
fake = FakeEffects(windows="item-7\t0\t@1\nitem-9\t1\t@3\n")
|
fake = FakeEffects(windows="item-7\t0\t@1\nitem-9\t1\t@3\n")
|
||||||
self.assertEqual(chunk_windows.held_beside("item-7", str(self.root), paths.paths_from(self.home), fake.effects()), [9])
|
self.assertEqual(chunk_windows.held_beside("item-7", str(self.root), paths.paths_from(self.home, {}), fake.effects()), [9])
|
||||||
|
|
||||||
def test_a_chunk_holds_its_own_item_and_those_on_its_latest_chunk_items_line(self):
|
def test_a_chunk_holds_its_own_item_and_those_on_its_latest_chunk_items_line(self):
|
||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class WindowStarts(unittest.TestCase):
|
|||||||
return list(started) if isinstance(started, tuple) else started
|
return list(started) if isinstance(started, tuple) else started
|
||||||
|
|
||||||
with contextlib.redirect_stdout(io.StringIO()) as said:
|
with contextlib.redirect_stdout(io.StringIO()) as said:
|
||||||
stop = main.run_loop(argv, env or {}, paths.paths_from(self.HOME), pathlib.Path("/b/build-release"), CWD, fake.effects(), steps(start))
|
stop = main.run_loop(argv, env or {}, paths.paths_from(self.HOME, env or {}), pathlib.Path("/b/build-release"), CWD, fake.effects(), steps(start))
|
||||||
return stop, said.getvalue()
|
return stop, said.getvalue()
|
||||||
|
|
||||||
def test_refuses_to_start_anything_on_a_tmux_older_than_needed(self):
|
def test_refuses_to_start_anything_on_a_tmux_older_than_needed(self):
|
||||||
@@ -156,8 +156,8 @@ class WindowStarts(unittest.TestCase):
|
|||||||
effects, env, launcher = fake.effects(), {"BUILD_RELEASE_X": "1"}, pathlib.Path("/b/build-release")
|
effects, env, launcher = fake.effects(), {"BUILD_RELEASE_X": "1"}, pathlib.Path("/b/build-release")
|
||||||
asked = []
|
asked = []
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
main.run_loop(["do it"], env, paths.paths_from(self.HOME), launcher, CWD, effects, steps(lambda *args: asked.append(args) or ["item-3"]))
|
main.run_loop(["do it"], env, paths.paths_from(self.HOME, {}), launcher, CWD, effects, steps(lambda *args: asked.append(args) or ["item-3"]))
|
||||||
self.assertEqual(asked, [(main.LoopRun(0, "/r", "do it", ""), False, paths.paths_from(self.HOME), env, launcher, effects)])
|
self.assertEqual(asked, [(main.LoopRun(0, "/r", "do it", ""), False, paths.paths_from(self.HOME, {}), env, launcher, effects)])
|
||||||
|
|
||||||
def test_a_window_loop_runs_its_chunk_in_its_own_session_and_window_and_hands_on_once_it_finished(self):
|
def test_a_window_loop_runs_its_chunk_in_its_own_session_and_window_and_hands_on_once_it_finished(self):
|
||||||
fake = FakeEffects(git=["/r\n"])
|
fake = FakeEffects(git=["/r\n"])
|
||||||
@@ -171,8 +171,8 @@ class WindowStarts(unittest.TestCase):
|
|||||||
taken = steps(lambda *args: started.append(args) or [], fingerprint=lambda launcher: "", exec_if_edited=lambda *args: None, next_cycle=lambda *args: cycles.append(args) or cycle,
|
taken = steps(lambda *args: started.append(args) or [], fingerprint=lambda launcher: "", exec_if_edited=lambda *args: None, next_cycle=lambda *args: cycles.append(args) or cycle,
|
||||||
run_cycle=lambda cycle: concluded.pop(0), closed_cycle=lambda *args: closed.pop(0), check_routing=lambda *args: None)
|
run_cycle=lambda cycle: concluded.pop(0), closed_cycle=lambda *args: closed.pop(0), check_routing=lambda *args: None)
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
stop = main.run_loop(["--chunk", "item-3", "do it"], env, paths.paths_from(self.HOME), launcher, CWD, effects, taken)
|
stop = main.run_loop(["--chunk", "item-3", "do it"], env, paths.paths_from(self.HOME, {}), launcher, CWD, effects, taken)
|
||||||
loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".claude" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=paths.paths_from(self.HOME), env=env, launcher=launcher, effects=effects)
|
loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".claude" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=paths.paths_from(self.HOME, {}), env=env, launcher=launcher, effects=effects)
|
||||||
self.assertEqual(stop, Stop(0, ""))
|
self.assertEqual(stop, Stop(0, ""))
|
||||||
self.assertEqual(cycles, [(main.LoopRun(1, "/r", "do it", "", chunk="item-3"), loop), (main.LoopRun(2, "/r", "do it", "", chunk="item-3"), loop)])
|
self.assertEqual(cycles, [(main.LoopRun(1, "/r", "do it", "", chunk="item-3"), loop), (main.LoopRun(2, "/r", "do it", "", chunk="item-3"), loop)])
|
||||||
self.assertEqual(started, [(main.LoopRun(2, "/r", "do it", "", chunk="item-3"), True, loop.paths, env, launcher, effects)])
|
self.assertEqual(started, [(main.LoopRun(2, "/r", "do it", "", chunk="item-3"), True, loop.paths, env, launcher, effects)])
|
||||||
@@ -180,7 +180,7 @@ class WindowStarts(unittest.TestCase):
|
|||||||
def window_loop(self, cycles, env, **doubles):
|
def window_loop(self, cycles, env, **doubles):
|
||||||
"""run_loop's stop for item-3's window loop, and each step it took with what it handed that step. Each step answers as its double in `doubles` does, else as a cycle without a stop: next_cycle answers the next of `cycles`, run_cycle an unfinished verdict, and closed_cycle the run with one more unfinished verdict."""
|
"""run_loop's stop for item-3's window loop, and each step it took with what it handed that step. Each step answers as its double in `doubles` does, else as a cycle without a stop: next_cycle answers the next of `cycles`, run_cycle an unfinished verdict, and closed_cycle the run with one more unfinished verdict."""
|
||||||
fake, calls, cycles = FakeEffects(git=["/r\n"]), [], list(cycles)
|
fake, calls, cycles = FakeEffects(git=["/r\n"]), [], list(cycles)
|
||||||
effects, launcher, home = fake.effects(), pathlib.Path("/b/build-release"), paths.paths_from(self.HOME)
|
effects, launcher, home = fake.effects(), pathlib.Path("/b/build-release"), paths.paths_from(self.HOME, env or {})
|
||||||
self.unfinished = unittest.mock.Mock(verdict=unittest.mock.Mock(spec=Unfinished))
|
self.unfinished = unittest.mock.Mock(verdict=unittest.mock.Mock(spec=Unfinished))
|
||||||
answers = {"fingerprint": lambda *args: "print-1", "exec_if_edited": lambda *args: None, "next_cycle": lambda *args: cycles.pop(0), "run_cycle": lambda *args: self.unfinished,
|
answers = {"fingerprint": lambda *args: "print-1", "exec_if_edited": lambda *args: None, "next_cycle": lambda *args: cycles.pop(0), "run_cycle": lambda *args: self.unfinished,
|
||||||
"closed_cycle": lambda run, *args: dataclasses.replace(run, unfinished_run=run.unfinished_run + 1), "check_routing": lambda *args: None, **doubles}
|
"closed_cycle": lambda run, *args: dataclasses.replace(run, unfinished_run=run.unfinished_run + 1), "check_routing": lambda *args: None, **doubles}
|
||||||
@@ -246,7 +246,7 @@ class WindowStarts(unittest.TestCase):
|
|||||||
fake = FakeEffects(git=["/r\n"])
|
fake = FakeEffects(git=["/r\n"])
|
||||||
effects = dataclasses.replace(fake.effects(), tmux_on_terminal=lambda args: 1)
|
effects = dataclasses.replace(fake.effects(), tmux_on_terminal=lambda args: 1)
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
stop = main.run_loop(["do it"], {}, paths.paths_from(self.HOME), pathlib.Path("/b/build-release"), CWD, effects, steps(lambda *args: ["item-3"]))
|
stop = main.run_loop(["do it"], {}, paths.paths_from(self.HOME, {}), pathlib.Path("/b/build-release"), CWD, effects, steps(lambda *args: ["item-3"]))
|
||||||
self.assertEqual(stop, Stop(1, "`tmux attach-session -t =loop-r` failed; the chunks go on in the tmux session"))
|
self.assertEqual(stop, Stop(1, "`tmux attach-session -t =loop-r` failed; the chunks go on in the tmux session"))
|
||||||
|
|
||||||
def test_a_window_loop_outside_tmux_stops(self):
|
def test_a_window_loop_outside_tmux_stops(self):
|
||||||
@@ -273,7 +273,7 @@ class WindowStarts(unittest.TestCase):
|
|||||||
class StopDms(unittest.TestCase):
|
class StopDms(unittest.TestCase):
|
||||||
def run_main(self, argv, fake):
|
def run_main(self, argv, fake):
|
||||||
with tempfile.TemporaryDirectory() as home, contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()):
|
with tempfile.TemporaryDirectory() as home, contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()):
|
||||||
code = main.main(argv, {}, paths.paths_from(pathlib.Path(home)), pathlib.Path(home, "build-release"), CWD, fake.effects())
|
code = main.main(argv, {}, paths.paths_from(pathlib.Path(home), {}), pathlib.Path(home, "build-release"), CWD, fake.effects())
|
||||||
return code, said.getvalue()
|
return code, said.getvalue()
|
||||||
|
|
||||||
def exit_code(self, run, fake):
|
def exit_code(self, run, fake):
|
||||||
@@ -325,7 +325,7 @@ class StopDms(unittest.TestCase):
|
|||||||
|
|
||||||
class OwnLadder(unittest.TestCase):
|
class OwnLadder(unittest.TestCase):
|
||||||
def test_a_cycle_on_a_projects_own_ladder_names_its_file_and_says_where_the_workers_model_is_off_it(self):
|
def test_a_cycle_on_a_projects_own_ladder_names_its_file_and_says_where_the_workers_model_is_off_it(self):
|
||||||
file = pathlib.Path("/h/.claude-projects/acme/routing-ladder.json")
|
file = pathlib.Path("/h/.config/build-release/acme/routing-ladder.json")
|
||||||
self.assertEqual(main.own_ladder(file, "claude-fable-5-2", False), f"routing on the project's own ladder, {file}.")
|
self.assertEqual(main.own_ladder(file, "claude-fable-5-2", False), f"routing on the project's own ladder, {file}.")
|
||||||
self.assertEqual(main.own_ladder(file, "claude-opus-5-5", True), f"routing on the project's own ladder, {file}. claude-opus-5-5 is not on it, so the worker runs on claude-opus-5-5 unrouted; BUILD_RELEASE_WORKER_MODEL and BUILD_RELEASE_JUDGE_MODEL name other models for a run.")
|
self.assertEqual(main.own_ladder(file, "claude-opus-5-5", True), f"routing on the project's own ladder, {file}. claude-opus-5-5 is not on it, so the worker runs on claude-opus-5-5 unrouted; BUILD_RELEASE_WORKER_MODEL and BUILD_RELEASE_JUDGE_MODEL name other models for a run.")
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class RoutingCheck(unittest.TestCase):
|
|||||||
self.home = pathlib.Path(tempfile.mkdtemp())
|
self.home = pathlib.Path(tempfile.mkdtemp())
|
||||||
self.addCleanup(shutil.rmtree, self.home)
|
self.addCleanup(shutil.rmtree, self.home)
|
||||||
self.root = self.home / "archive"
|
self.root = self.home / "archive"
|
||||||
self.paths = paths.paths_from(self.home)
|
self.paths = paths.paths_from(self.home, {})
|
||||||
self.session = session.session_named("A log build-release", self.paths.claude_code_transcripts)
|
self.session = session.session_named("A log build-release", self.paths.claude_code_transcripts)
|
||||||
|
|
||||||
def loop(self, fake):
|
def loop(self, fake):
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ HELP = """Run a task as headless claude cycles; a judge interrupts only when a d
|
|||||||
usage: build-release <task>
|
usage: build-release <task>
|
||||||
|
|
||||||
Run it anywhere inside a project checkout whose goals file has ## Goals and ## Audience, the
|
Run it anywhere inside a project checkout whose goals file has ## Goals and ## Audience, the
|
||||||
premises. The goals file is the one the project's config, ~/.claude-projects/<key>/config.toml, sets
|
premises. The goals file is the one the project's config, ~/.config/build-release/<key>/config.toml,
|
||||||
as goals-and-audience: a file, or a Jira epic's description. `project-config goals-and-audience`
|
sets as goals-and-audience: a file, or a Jira epic's description.
|
||||||
prints where it is. The task runs at the checkout root. Each cycle a worker runs the task. A chunk's
|
`project-config goals-and-audience` prints where it is. The task runs at the checkout root. Each
|
||||||
|
cycle a worker runs the task. A chunk's
|
||||||
first worker prompt also quotes the premises. They, with code health (the setup's CLAUDE.md →
|
first worker prompt also quotes the premises. They, with code health (the setup's CLAUDE.md →
|
||||||
"Shared goal") ranked first unless the goals file voids it, choose between ways to deliver the
|
"Shared goal") ranked first unless the goals file voids it, choose between ways to deliver the
|
||||||
chunk's plan items, or else the task, and never widen them. A judge then reads the transcript's end,
|
chunk's plan items, or else the task, and never widen them. A judge then reads the transcript's end,
|
||||||
@@ -78,9 +79,9 @@ worker to find the facts itself.
|
|||||||
|
|
||||||
At every interrupt, and as every cycle ends, Ctrl-C and a failure included, the claude session's
|
At every interrupt, and as every cycle ends, Ctrl-C and a failure included, the claude session's
|
||||||
transcript is copied into a folder per chunk under $BUILD_RELEASE_TRANSCRIPTS/<key> (default root
|
transcript is copied into a folder per chunk under $BUILD_RELEASE_TRANSCRIPTS/<key> (default root
|
||||||
~/.claude/loop-claude-transcripts), named by its hash, with an outcomes file beside it: the task,
|
~/.local/state/build-release/transcripts), named by its hash, with an outcomes file beside it: the
|
||||||
then each verdict, quoted answer, rejected judge reply, step-up and stop, each opened by its UTC
|
task, then each verdict, quoted answer, rejected judge reply, step-up and stop, each opened by its
|
||||||
time. The layout, and when a copy is replaced, are in bin/transcript_archive/__init__.py.
|
UTC time. The layout, and when a copy is replaced, are in bin/transcript_archive/__init__.py.
|
||||||
|
|
||||||
A worker's claude can print its final result and then keep waiting on a background shell that
|
A worker's claude can print its final result and then keep waiting on a background shell that
|
||||||
never ends. Every 5 minutes without output from that claude after its final result, build-release
|
never ends. Every 5 minutes without output from that claude after its final result, build-release
|
||||||
@@ -110,7 +111,7 @@ characters to a file and see its path and the first 2,000 characters (BASH_MAX_O
|
|||||||
bin/claude_code/output_limits.py).
|
bin/claude_code/output_limits.py).
|
||||||
|
|
||||||
Every claude build-release starts runs the project's model, saved per <key> in
|
Every claude build-release starts runs the project's model, saved per <key> in
|
||||||
~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker,
|
~/.config/build-release/models.json and read each cycle, unless routing, below, puts the worker,
|
||||||
the session /talk opens and the judge on another rung, a model at an effort. A project without an
|
the session /talk opens and the judge on another rung, a model at an effort. A project without an
|
||||||
entry, as on its first run, is asked for one on the terminal. BUILD_RELEASE_JUDGE_MODEL overrides
|
entry, as on its first run, is asked for one on the terminal. BUILD_RELEASE_JUDGE_MODEL overrides
|
||||||
the model for the judge, BUILD_RELEASE_WORKER_MODEL for the worker and the session /talk opens; with
|
the model for the judge, BUILD_RELEASE_WORKER_MODEL for the worker and the session /talk opens; with
|
||||||
@@ -142,8 +143,8 @@ or max:
|
|||||||
|
|
||||||
It holds one model of each family, such as opus, since the Agent tool launches a subagent or a
|
It holds one model of each family, such as opus, since the Agent tool launches a subagent or a
|
||||||
review by its family's name. This setup ships one, bin/model_routing/routing-ladder.json. A project
|
review by its family's name. This setup ships one, bin/model_routing/routing-ladder.json. A project
|
||||||
that keeps a routing-ladder.json in its config's folder, ~/.claude-projects/<key>/, runs on that
|
that keeps a routing-ladder.json in its config's folder, ~/.config/build-release/<key>/, runs on
|
||||||
ladder instead, whole: write there every rung the project may run on. build-release reads the
|
that ladder instead, whole: write there every rung the project may run on. build-release reads the
|
||||||
project's ladder as each cycle starts, says on stderr where the project runs on its own, and never
|
project's ladder as each cycle starts, says on stderr where the project runs on its own, and never
|
||||||
commits the file. subagent-rung and rule-hook read the same ladder; the routing figures,
|
commits the file. subagent-rung and rule-hook read the same ladder; the routing figures,
|
||||||
judge-replay and review-replay, which span every project, read the shipped one.
|
judge-replay and review-replay, which span every project, read the shipped one.
|
||||||
@@ -206,4 +207,7 @@ Exit 2, when the human is needed to go on:
|
|||||||
anything typed
|
anything typed
|
||||||
- the judge rules a chunk unfinished 6 cycles running; rerun to give it 6 more
|
- the judge rules a chunk unfinished 6 cycles running; rerun to give it 6 more
|
||||||
Rerunning build-release <task> starts the chunks that may start, a stopped one first, and each
|
Rerunning build-release <task> starts the chunks that may start, a stopped one first, and each
|
||||||
resumes its claude session where it is open."""
|
resumes its claude session where it is open.
|
||||||
|
|
||||||
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path.
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path."""
|
||||||
|
|||||||
@@ -325,13 +325,13 @@ class Checkout:
|
|||||||
return self.home / ".claude.json"
|
return self.home / ".claude.json"
|
||||||
|
|
||||||
def models_file(self):
|
def models_file(self):
|
||||||
return self.home / ".claude" / "loop-claude-models.json"
|
return self.home / ".config/build-release" / "models.json"
|
||||||
|
|
||||||
def transcripts(self):
|
def transcripts(self):
|
||||||
return sorted((self.home / ".claude" / "projects").glob("*/*.jsonl"))
|
return sorted((self.home / ".claude" / "projects").glob("*/*.jsonl"))
|
||||||
|
|
||||||
def archive(self):
|
def archive(self):
|
||||||
return pathlib.Path(self.env.get("BUILD_RELEASE_TRANSCRIPTS", self.home / ".claude" / "loop-claude-transcripts"))
|
return pathlib.Path(self.env.get("BUILD_RELEASE_TRANSCRIPTS", self.home / ".local/state/build-release" / "transcripts"))
|
||||||
|
|
||||||
def archived(self):
|
def archived(self):
|
||||||
"""Each archived transcript's outcomes, with every UTC stamp replaced by <UTC> and every setup version by <config>, after checking the copy is named by its content hash."""
|
"""Each archived transcript's outcomes, with every UTC stamp replaced by <UTC> and every setup version by <config>, after checking the copy is named by its content hash."""
|
||||||
@@ -397,10 +397,10 @@ class Premises(unittest.TestCase):
|
|||||||
run = checkout.run([worker()])
|
run = checkout.run([worker()])
|
||||||
self.assertEqual((run.code, run.calls), (1, []))
|
self.assertEqual((run.code, run.calls), (1, []))
|
||||||
self.assertEqual(run.stderr.strip(), f"cannot read {checkout.root}/README.md: Is a directory - no premises.")
|
self.assertEqual(run.stderr.strip(), f"cannot read {checkout.root}/README.md: Is a directory - no premises.")
|
||||||
(checkout.home / ".claude-projects" / "proj" / "config.toml").unlink()
|
(checkout.home / ".config/build-release" / "proj" / "config.toml").unlink()
|
||||||
run = checkout.run([worker()])
|
run = checkout.run([worker()])
|
||||||
self.assertEqual((run.code, run.calls), (1, []))
|
self.assertEqual((run.code, run.calls), (1, []))
|
||||||
self.assertEqual(run.stderr.strip(), f"no config names the checkout {checkout.root}: write ~/.claude-projects/<key>/config.toml, as `project-config --help` shows - no premises.")
|
self.assertEqual(run.stderr.strip(), f"no config names the checkout {checkout.root}: write {checkout.home}/.config/build-release/<key>/config.toml, as `project-config --help` shows - no premises.")
|
||||||
(checkout.temp / "fake-bin" / "git").unlink()
|
(checkout.temp / "fake-bin" / "git").unlink()
|
||||||
run = checkout.run([worker()])
|
run = checkout.run([worker()])
|
||||||
self.assertEqual((run.code, run.calls), (1, []))
|
self.assertEqual((run.code, run.calls), (1, []))
|
||||||
@@ -512,7 +512,7 @@ class Cycles(unittest.TestCase):
|
|||||||
def test_routes_on_the_ladder_the_projects_config_folder_holds_in_place_of_the_shipped_one(self):
|
def test_routes_on_the_ladder_the_projects_config_folder_holds_in_place_of_the_shipped_one(self):
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
checkout.env["BUILD_RELEASE_WORKER_MODEL"] = "claude-fable-5-2"
|
checkout.env["BUILD_RELEASE_WORKER_MODEL"] = "claude-fable-5-2"
|
||||||
ladder = checkout.home / ".claude-projects" / "proj" / "routing-ladder.json"
|
ladder = checkout.home / ".config/build-release" / "proj" / "routing-ladder.json"
|
||||||
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "low"}, {"model": "claude-fable-5-2", "effort": "max"}]')
|
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "low"}, {"model": "claude-fable-5-2", "effort": "max"}]')
|
||||||
checkout.commit_plan(CHEAP)
|
checkout.commit_plan(CHEAP)
|
||||||
run = checkout.run([worker(), judge(), worker(), judge(), worker()])
|
run = checkout.run([worker(), judge(), worker(), judge(), worker()])
|
||||||
@@ -524,7 +524,7 @@ class Cycles(unittest.TestCase):
|
|||||||
def test_says_where_the_projects_own_ladder_leaves_out_the_workers_model_and_says_nothing_on_the_shipped_one(self):
|
def test_says_where_the_projects_own_ladder_leaves_out_the_workers_model_and_says_nothing_on_the_shipped_one(self):
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
self.assertNotIn("own ladder", checkout.run([worker()]).stderr)
|
self.assertNotIn("own ladder", checkout.run([worker()]).stderr)
|
||||||
ladder = checkout.home / ".claude-projects" / "proj" / "routing-ladder.json"
|
ladder = checkout.home / ".config/build-release" / "proj" / "routing-ladder.json"
|
||||||
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "low"}]')
|
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "low"}]')
|
||||||
run = checkout.run([worker()])
|
run = checkout.run([worker()])
|
||||||
self.assertIn(f"routing on the project's own ladder, {ladder}. worker-model is not on it, so the worker runs on worker-model unrouted; BUILD_RELEASE_WORKER_MODEL and BUILD_RELEASE_JUDGE_MODEL name other models for a run.\n", run.stderr)
|
self.assertIn(f"routing on the project's own ladder, {ladder}. worker-model is not on it, so the worker runs on worker-model unrouted; BUILD_RELEASE_WORKER_MODEL and BUILD_RELEASE_JUDGE_MODEL name other models for a run.\n", run.stderr)
|
||||||
@@ -533,7 +533,7 @@ class Cycles(unittest.TestCase):
|
|||||||
def test_reads_the_projects_ladder_afresh_each_cycle_and_exits_1_once_it_holds_a_fault(self):
|
def test_reads_the_projects_ladder_afresh_each_cycle_and_exits_1_once_it_holds_a_fault(self):
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
checkout.env["BUILD_RELEASE_WORKER_MODEL"] = "claude-fable-5-2"
|
checkout.env["BUILD_RELEASE_WORKER_MODEL"] = "claude-fable-5-2"
|
||||||
ladder = checkout.home / ".claude-projects" / "proj" / "routing-ladder.json"
|
ladder = checkout.home / ".config/build-release" / "proj" / "routing-ladder.json"
|
||||||
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "high"}]')
|
ladder.write_text('[{"model": "claude-fable-5-2", "effort": "high"}]')
|
||||||
checkout.env["FAKE_CLAUDE_EDIT"] = str(ladder.parent)
|
checkout.env["FAKE_CLAUDE_EDIT"] = str(ladder.parent)
|
||||||
run = checkout.run([worker(replace=["routing-ladder.json", '"high"}', '"high"},']), judge()])
|
run = checkout.run([worker(replace=["routing-ladder.json", '"high"}', '"high"},']), judge()])
|
||||||
@@ -672,7 +672,7 @@ class Cycles(unittest.TestCase):
|
|||||||
checkout.archive().write_text("in the way")
|
checkout.archive().write_text("in the way")
|
||||||
run = checkout.run([worker(say="landed-it"), judge(finished=True, evidence="landed-it")])
|
run = checkout.run([worker(say="landed-it"), judge(finished=True, evidence="landed-it")])
|
||||||
self.assertEqual((run.code, run.roles()), (1, ["worker", "judge"]))
|
self.assertEqual((run.code, run.roles()), (1, ["worker", "judge"]))
|
||||||
self.assertRegex(run.stderr.strip().splitlines()[-1], r"^could not archive the transcript: .*/loop-claude-transcripts/proj: Not a directory$")
|
self.assertRegex(run.stderr.strip().splitlines()[-1], r"^could not archive the transcript: .*/build-release/transcripts/proj: Not a directory$")
|
||||||
self.assertEqual(run.stderr.count("could not archive the transcript"), 1)
|
self.assertEqual(run.stderr.count("could not archive the transcript"), 1)
|
||||||
session = argument(run.calls[0], "--session-id")
|
session = argument(run.calls[0], "--session-id")
|
||||||
checkout.archive().unlink()
|
checkout.archive().unlink()
|
||||||
@@ -820,7 +820,7 @@ class Windows(unittest.TestCase):
|
|||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
checkout.commit_plan(BESIDE)
|
checkout.commit_plan(BESIDE)
|
||||||
if parallel:
|
if parallel:
|
||||||
config = checkout.home / ".claude-projects" / "proj" / "config.toml"
|
config = checkout.home / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(f"parallel-chunks = {parallel}\n" + config.read_text())
|
config.write_text(f"parallel-chunks = {parallel}\n" + config.read_text())
|
||||||
return checkout
|
return checkout
|
||||||
|
|
||||||
@@ -944,11 +944,11 @@ class Interrupt(unittest.TestCase):
|
|||||||
def test_sends_the_dm_through_the_notifier_and_env_file_the_config_names_and_no_credential_reaches_a_prompt_a_line_printed_or_a_file_written(self):
|
def test_sends_the_dm_through_the_notifier_and_env_file_the_config_names_and_no_credential_reaches_a_prompt_a_line_printed_or_a_file_written(self):
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
token = "tok-3f9a1c7e-sentinel"
|
token = "tok-3f9a1c7e-sentinel"
|
||||||
env_file = checkout.home / ".claude-projects" / "proj.env"
|
env_file = checkout.home / ".config/build-release" / "proj.env"
|
||||||
env_file.write_text(f"MATTERMOST_URL=https://127.0.0.1:1\nMATTERMOST_TOKEN={token}\nMATTERMOST_RECIPIENT=lilleman\n")
|
env_file.write_text(f"MATTERMOST_URL=https://127.0.0.1:1\nMATTERMOST_TOKEN={token}\nMATTERMOST_RECIPIENT=lilleman\n")
|
||||||
env_file.chmod(0o600)
|
env_file.chmod(0o600)
|
||||||
with (checkout.home / ".claude-projects" / "proj" / "config.toml").open("a") as config:
|
with (checkout.home / ".config/build-release" / "proj" / "config.toml").open("a") as config:
|
||||||
config.write('env-file = "~/.claude-projects/proj.env"\nnotifier = "mattermost"\n')
|
config.write('env-file = "~/.config/build-release/proj.env"\nnotifier = "mattermost"\n')
|
||||||
run = checkout.run([worker(say="Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?")])
|
run = checkout.run([worker(say="Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?")])
|
||||||
self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"]))
|
self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"]))
|
||||||
self.assertIn("could not DM you: cannot reach https://127.0.0.1:1", run.stderr)
|
self.assertIn("could not DM you: cannot reach https://127.0.0.1:1", run.stderr)
|
||||||
@@ -1054,7 +1054,7 @@ class Models(unittest.TestCase):
|
|||||||
def test_keeps_the_models_file_mode_and_other_projects_when_saving(self):
|
def test_keeps_the_models_file_mode_and_other_projects_when_saving(self):
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
del checkout.env["BUILD_RELEASE_JUDGE_MODEL"], checkout.env["BUILD_RELEASE_WORKER_MODEL"]
|
del checkout.env["BUILD_RELEASE_JUDGE_MODEL"], checkout.env["BUILD_RELEASE_WORKER_MODEL"]
|
||||||
checkout.models_file().parent.mkdir(parents=True)
|
checkout.models_file().parent.mkdir(parents=True, exist_ok=True)
|
||||||
checkout.models_file().write_text(json.dumps({"other": "model-x"}))
|
checkout.models_file().write_text(json.dumps({"other": "model-x"}))
|
||||||
checkout.models_file().chmod(0o640)
|
checkout.models_file().chmod(0o640)
|
||||||
def saved_elsewhere():
|
def saved_elsewhere():
|
||||||
@@ -1092,7 +1092,8 @@ class Models(unittest.TestCase):
|
|||||||
assert_not_root(self)
|
assert_not_root(self)
|
||||||
checkout = Checkout(self)
|
checkout = Checkout(self)
|
||||||
del checkout.env["BUILD_RELEASE_JUDGE_MODEL"], checkout.env["BUILD_RELEASE_WORKER_MODEL"]
|
del checkout.env["BUILD_RELEASE_JUDGE_MODEL"], checkout.env["BUILD_RELEASE_WORKER_MODEL"]
|
||||||
checkout.models_file().parent.mkdir(parents=True, mode=0o500)
|
checkout.models_file().parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
checkout.models_file().parent.chmod(0o500)
|
||||||
self.addCleanup(checkout.models_file().parent.chmod, 0o700)
|
self.addCleanup(checkout.models_file().parent.chmod, 0o700)
|
||||||
run = checkout.run([worker()], terminal_input="custom-model\n")
|
run = checkout.run([worker()], terminal_input="custom-model\n")
|
||||||
self.assertEqual((run.code, run.calls), (1, []))
|
self.assertEqual((run.code, run.calls), (1, []))
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ import pathlib
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
|
from loop_state.paths import Paths
|
||||||
from transcript_archive.project_key import project_key
|
from transcript_archive.project_key import project_key
|
||||||
from loop_state.paths import STATE_FOLDER
|
|
||||||
from agent_cycle import tmux
|
from agent_cycle import tmux
|
||||||
|
|
||||||
# Under the home folder, a folder per project key holds LOCK.
|
|
||||||
CLAIMS = f"{STATE_FOLDER}/loop-claude"
|
|
||||||
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and do-epic, which holds the same lock, never starts a chunk in a checkout while build-release does.
|
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and do-epic, which holds the same lock, never starts a chunk in a checkout while build-release does.
|
||||||
LOCK = "starting"
|
LOCK = "starting"
|
||||||
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
|
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
|
||||||
@@ -47,9 +45,14 @@ def locked(file: pathlib.Path) -> typing.Iterator[Failure | None]:
|
|||||||
yield None
|
yield None
|
||||||
|
|
||||||
|
|
||||||
def project_lock(root: str, home: pathlib.Path) -> pathlib.Path:
|
def claims_folder(state: pathlib.Path) -> pathlib.Path:
|
||||||
|
"""The folder, in the state folder, that holds a folder per project key for its LOCK."""
|
||||||
|
return state / "claims"
|
||||||
|
|
||||||
|
|
||||||
|
def project_lock(root: str, paths: Paths) -> pathlib.Path:
|
||||||
"""The folder of the LOCK that everything starting a chunk in the checkout root holds."""
|
"""The folder of the LOCK that everything starting a chunk in the checkout root holds."""
|
||||||
return home / CLAIMS / project_key(root, home)
|
return claims_folder(paths.state_folder) / project_key(root, paths.home)
|
||||||
|
|
||||||
|
|
||||||
def loop_session(root: str, home: pathlib.Path) -> str:
|
def loop_session(root: str, home: pathlib.Path) -> str:
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def project_routing(loop: Loop, driver: str) -> Routing | Stop:
|
|||||||
models = get_or_ask_models(project_key(loop.root, loop.paths.home), loop.paths, loop.env, driver, loop.effects)
|
models = get_or_ask_models(project_key(loop.root, loop.paths.home), loop.paths, loop.env, driver, loop.effects)
|
||||||
if isinstance(models, Stop):
|
if isinstance(models, Stop):
|
||||||
return models
|
return models
|
||||||
ladder_file = project_ladder_file(loop.root, loop.paths.home)
|
ladder_file = project_ladder_file(loop.root, loop.paths.home, loop.env)
|
||||||
return Stop(1, ladder_file.reason) if isinstance(ladder_file, Failure) else routing_on(models, ladder_file)
|
return Stop(1, ladder_file.reason) if isinstance(ladder_file, Failure) else routing_on(models, ladder_file)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ from agent_cycle.doubles import WINDOW
|
|||||||
def a_loop(effects: Effects, **fields: typing.Any) -> Loop:
|
def a_loop(effects: Effects, **fields: typing.Any) -> Loop:
|
||||||
"""A loop in /r on effects, with fields in place of its defaults."""
|
"""A loop in /r on effects, with fields in place of its defaults."""
|
||||||
home = pathlib.Path("/h")
|
home = pathlib.Path("/h")
|
||||||
defaults = {"root": "/r", "session": session.session_named("A proj a-driver", paths.paths_from(home).claude_code_transcripts), "paths": paths.paths_from(home), "env": {}, "launcher": pathlib.Path("/b/a-driver"), "window": WINDOW}
|
defaults = {"root": "/r", "session": session.session_named("A proj a-driver", paths.paths_from(home, {}).claude_code_transcripts), "paths": paths.paths_from(home, {}), "env": {}, "launcher": pathlib.Path("/b/a-driver"), "window": WINDOW}
|
||||||
return Loop(**{**defaults, **fields}, effects=effects)
|
return Loop(**{**defaults, **fields}, effects=effects)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import sys
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
from claude_code.model_catalog import catalog_models
|
from claude_code.model_catalog import catalog_models
|
||||||
from chunk_driver.claims import CLAIMS, locked
|
from chunk_driver.claims import claims_folder, locked
|
||||||
from loop_effects.effects import Effects, say
|
from loop_effects.effects import Effects, say
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from agent_cycle.stop import needs_human, needs_terminal, Stop
|
from agent_cycle.stop import needs_human, needs_terminal, Stop
|
||||||
@@ -21,7 +21,7 @@ class Models:
|
|||||||
# The environment variables that name the judge's and the worker's model for one run, over the model saved or configured.
|
# The environment variables that name the judge's and the worker's model for one run, over the model saved or configured.
|
||||||
JUDGE_MODEL = "BUILD_RELEASE_JUDGE_MODEL"
|
JUDGE_MODEL = "BUILD_RELEASE_JUDGE_MODEL"
|
||||||
WORKER_MODEL = "BUILD_RELEASE_WORKER_MODEL"
|
WORKER_MODEL = "BUILD_RELEASE_WORKER_MODEL"
|
||||||
# The file, in CLAIMS under the home folder, that save_model keeps locked with flock while it rereads and replaces the models file. The models file's own folder is a checkout of this setup, which takes no lock file.
|
# The file, in the claims folder, that save_model keeps locked with flock while it rereads and replaces the models file. The models file's own folder is the config folder, which a person backs up, so the lock file is kept out of it.
|
||||||
MODELS_LOCK = "models.lock"
|
MODELS_LOCK = "models.lock"
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ def get_or_ask_model(project_key: str, paths: Paths, driver: str, effects: Effec
|
|||||||
def save_model(project_key: str, chosen: str, paths: Paths, replace: typing.Callable[[pathlib.Path, bytes], Failure | None]) -> Failure | None:
|
def save_model(project_key: str, chosen: str, paths: Paths, replace: typing.Callable[[pathlib.Path, bytes], Failure | None]) -> Failure | None:
|
||||||
"""Adds the project's model to the models file, whose only writer this is, through replace, which writes a file as replace_file does. It holds MODELS_LOCK from its read to its write, so two entry points that save at once both keep their pick."""
|
"""Adds the project's model to the models file, whose only writer this is, through replace, which writes a file as replace_file does. It holds MODELS_LOCK from its read to its write, so two entry points that save at once both keep their pick."""
|
||||||
saved = paths.models_file
|
saved = paths.models_file
|
||||||
with locked(paths.home / CLAIMS / MODELS_LOCK) as unlocked:
|
with locked(claims_folder(paths.state_folder) / MODELS_LOCK) as unlocked:
|
||||||
if unlocked:
|
if unlocked:
|
||||||
return Failure(f"could not save the model in {saved}: {unlocked.reason}")
|
return Failure(f"could not save the model in {saved}: {unlocked.reason}")
|
||||||
# Read under the lock: another entry point may have saved its project while this one waited on the human.
|
# Read under the lock: another entry point may have saved its project while this one waited on the human.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
@@ -6,9 +7,9 @@ from project_config.main import located
|
|||||||
from plan.goals_file import section
|
from plan.goals_file import section
|
||||||
|
|
||||||
|
|
||||||
def read_premises(root: str, home: pathlib.Path) -> str | Failure:
|
def read_premises(root: str, home: pathlib.Path, env: Mapping[str, str]) -> str | Failure:
|
||||||
"""Where the goals file is kept, then its ## Goals and ## Audience. The goals file is the one that the config of root's checkout, under home, names: a file or a Jira epic's description. A Failure where no config names the checkout, or the goals file cannot be read, is missing or empty, lacks a section, holds one twice or leaves one empty."""
|
"""Where the goals file is kept, then its ## Goals and ## Audience. The goals file is the one that the config of root's checkout, under home, names: a file or a Jira epic's description. A Failure where no config names the checkout, or the goals file cannot be read, is missing or empty, lacks a section, holds one twice or leaves one empty."""
|
||||||
config = located(root, home)
|
config = located(root, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Failure(f"{config.reason} - no premises.")
|
return Failure(f"{config.reason} - no premises.")
|
||||||
goals = goals_store(config)
|
goals = goals_store(config)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from loop_state.paths import CLAUDE_HOME
|
from loop_state.paths import CLAUDE_HOME
|
||||||
@@ -22,7 +23,7 @@ HUMAN_RULE_NAMES = (f"~/{CLAUDE_HOME}/{HUMAN_RULES_FILE}", f"~/{CLAUDE_HOME}/{HU
|
|||||||
CONSEQUENCE = "the judge cannot read the records"
|
CONSEQUENCE = "the judge cannot read the records"
|
||||||
|
|
||||||
|
|
||||||
def read_records(root: str | None, home: pathlib.Path, claude_dir: pathlib.Path, first: tuple[tuple[str, str], ...] = ()) -> str | Failure:
|
def read_records(root: str | None, home: pathlib.Path, env: Mapping[str, str], claude_dir: pathlib.Path, first: tuple[tuple[str, str], ...] = ()) -> str | Failure:
|
||||||
"""The project's `AGENTS.md` and decision log, then the human's rules, CLAUDE.md first, each headed by its name. One that does not exist, or is empty, is left out. A text that several of them hold appears once, headed by all their names.
|
"""The project's `AGENTS.md` and decision log, then the human's rules, CLAUDE.md first, each headed by its name. One that does not exist, or is empty, is left out. A text that several of them hold appears once, headed by all their names.
|
||||||
|
|
||||||
`AGENTS.md` is read where the config under home of root's project puts it, and the decision log from the store that config names. Each is headed by its name in RECORD_FILES wherever it is kept.
|
`AGENTS.md` is read where the config under home of root's project puts it, and the decision log from the store that config names. Each is headed by its name in RECORD_FILES wherever it is kept.
|
||||||
@@ -31,7 +32,7 @@ def read_records(root: str | None, home: pathlib.Path, claude_dir: pathlib.Path,
|
|||||||
texts: list[tuple[str, str | Failure]] = list(first)
|
texts: list[tuple[str, str | Failure]] = list(first)
|
||||||
rules = [claude_dir / HUMAN_RULES_FILE, *sorted((claude_dir / HUMAN_RULE_DIR).glob("*.md"))]
|
rules = [claude_dir / HUMAN_RULES_FILE, *sorted((claude_dir / HUMAN_RULE_DIR).glob("*.md"))]
|
||||||
if root is not None:
|
if root is not None:
|
||||||
config = located(root, home)
|
config = located(root, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Failure(f"{config.reason} - {CONSEQUENCE}.")
|
return Failure(f"{config.reason} - {CONSEQUENCE}.")
|
||||||
rules += sorted(config.paths["standards"].glob("*.md"))
|
rules += sorted(config.paths["standards"].glob("*.md"))
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class ModelsOfARun(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
temp = tempfile.TemporaryDirectory()
|
temp = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(temp.cleanup)
|
self.addCleanup(temp.cleanup)
|
||||||
self.paths = paths_from(pathlib.Path(temp.name))
|
self.paths = paths_from(pathlib.Path(temp.name), {})
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
|
|
||||||
def test_a_run_that_names_both_models_reads_no_models_file_and_asks_nothing(self):
|
def test_a_run_that_names_both_models_reads_no_models_file_and_asks_nothing(self):
|
||||||
self.paths.models_file.write_text("not json")
|
self.paths.models_file.write_text("not json")
|
||||||
@@ -76,17 +76,17 @@ class SavingAModel(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
temp = tempfile.TemporaryDirectory()
|
temp = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(temp.cleanup)
|
self.addCleanup(temp.cleanup)
|
||||||
self.paths = paths_from(pathlib.Path(temp.name))
|
self.paths = paths_from(pathlib.Path(temp.name), {})
|
||||||
self.lock = self.paths.home / ".local/state/loop-claude/models.lock"
|
self.lock = self.paths.home / ".local/state/build-release/claims/models.lock"
|
||||||
|
|
||||||
def test_adds_the_projects_model_to_those_the_file_holds(self):
|
def test_adds_the_projects_model_to_those_the_file_holds(self):
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
self.paths.models_file.write_text(json.dumps({"other": "model-x"}))
|
self.paths.models_file.write_text(json.dumps({"other": "model-x"}))
|
||||||
self.assertIsNone(model_choice.save_model("proj", "model-b", self.paths, replace_file))
|
self.assertIsNone(model_choice.save_model("proj", "model-b", self.paths, replace_file))
|
||||||
self.assertEqual(json.loads(self.paths.models_file.read_text()), {"other": "model-x", "proj": "model-b"})
|
self.assertEqual(json.loads(self.paths.models_file.read_text()), {"other": "model-x", "proj": "model-b"})
|
||||||
|
|
||||||
def test_writes_the_file_for_a_human_to_merge_into_a_project_per_tab_indented_line_in_the_order_of_their_keys(self):
|
def test_writes_the_file_for_a_human_to_merge_into_a_project_per_tab_indented_line_in_the_order_of_their_keys(self):
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
self.paths.models_file.write_text(json.dumps({"zebra": "model-z", "other": "model-x"}))
|
self.paths.models_file.write_text(json.dumps({"zebra": "model-z", "other": "model-x"}))
|
||||||
self.assertIsNone(model_choice.save_model("proj", "model-b", self.paths, replace_file))
|
self.assertIsNone(model_choice.save_model("proj", "model-b", self.paths, replace_file))
|
||||||
self.assertEqual(self.paths.models_file.read_text(), '{\n\t"other": "model-x",\n\t"proj": "model-b",\n\t"zebra": "model-z"\n}')
|
self.assertEqual(self.paths.models_file.read_text(), '{\n\t"other": "model-x",\n\t"proj": "model-b",\n\t"zebra": "model-z"\n}')
|
||||||
@@ -100,7 +100,7 @@ class SavingAModel(unittest.TestCase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def test_holds_the_models_lock_from_its_read_to_its_write(self):
|
def test_holds_the_models_lock_from_its_read_to_its_write(self):
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
held = []
|
held = []
|
||||||
|
|
||||||
class Watched(pathlib.PosixPath):
|
class Watched(pathlib.PosixPath):
|
||||||
@@ -119,7 +119,7 @@ class SavingAModel(unittest.TestCase):
|
|||||||
self.assertFalse(self.lock_is_held())
|
self.assertFalse(self.lock_is_held())
|
||||||
|
|
||||||
def test_doesnt_save_anything_where_it_cannot_take_the_lock(self):
|
def test_doesnt_save_anything_where_it_cannot_take_the_lock(self):
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
self.lock.parent.parent.mkdir(parents=True)
|
self.lock.parent.parent.mkdir(parents=True)
|
||||||
self.lock.parent.write_text("")
|
self.lock.parent.write_text("")
|
||||||
saved = model_choice.save_model("proj", "model-b", self.paths, replace_file)
|
saved = model_choice.save_model("proj", "model-b", self.paths, replace_file)
|
||||||
@@ -128,7 +128,7 @@ class SavingAModel(unittest.TestCase):
|
|||||||
self.assertFalse(self.paths.models_file.exists())
|
self.assertFalse(self.paths.models_file.exists())
|
||||||
|
|
||||||
def test_a_pick_is_saved_through_save_model_alone(self):
|
def test_a_pick_is_saved_through_save_model_alone(self):
|
||||||
self.paths.models_file.parent.mkdir()
|
self.paths.models_file.parent.mkdir(parents=True)
|
||||||
fake, held = FakeEffects(inputs=["my-model"]), []
|
fake, held = FakeEffects(inputs=["my-model"]), []
|
||||||
|
|
||||||
def replace(path: pathlib.Path, data: bytes) -> Failure:
|
def replace(path: pathlib.Path, data: bytes) -> Failure:
|
||||||
|
|||||||
@@ -16,42 +16,42 @@ class Records(unittest.TestCase):
|
|||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
|
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
|
||||||
config = configured(self, pathlib.Path(root), home=claude_md.parents[1]) / "config.toml"
|
config = configured(self, pathlib.Path(root), home=claude_md.parents[1]) / "config.toml"
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), "")
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "")
|
||||||
claude_md.parent.mkdir(parents=True)
|
claude_md.parent.mkdir(parents=True)
|
||||||
claude_md.write_text("# Global\n")
|
claude_md.write_text("# Global\n")
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), "From ~/.claude/CLAUDE.md:\n# Global")
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From ~/.claude/CLAUDE.md:\n# Global")
|
||||||
pathlib.Path(root, "docs").mkdir()
|
pathlib.Path(root, "docs").mkdir()
|
||||||
pathlib.Path(root, "docs", "decisions.md").write_text("# Decisions\n")
|
pathlib.Path(root, "docs", "decisions.md").write_text("# Decisions\n")
|
||||||
pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n")
|
pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n")
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global")
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global")
|
||||||
pathlib.Path(claude_md.parent, "rules").mkdir()
|
pathlib.Path(claude_md.parent, "rules").mkdir()
|
||||||
pathlib.Path(claude_md.parent, "rules", "todo-items.md").write_text("# Todo\n")
|
pathlib.Path(claude_md.parent, "rules", "todo-items.md").write_text("# Todo\n")
|
||||||
pathlib.Path(claude_md.parent, "rules", "goals-and-audience.md").write_text("# Goals\n")
|
pathlib.Path(claude_md.parent, "rules", "goals-and-audience.md").write_text("# Goals\n")
|
||||||
pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n")
|
pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n")
|
||||||
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True)
|
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True)
|
||||||
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
|
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/goals-and-audience.md:\n# Goals\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments"))
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/goals-and-audience.md:\n# Goals\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments"))
|
||||||
config.write_text(config.read_text().replace('"~/.claude/skills/larv-review/standards"', '"~/review-standards"'))
|
config.write_text(config.read_text().replace('"~/.claude/skills/larv-review/standards"', '"~/review-standards"'))
|
||||||
pathlib.Path(claude_md.parents[1], "review-standards").mkdir()
|
pathlib.Path(claude_md.parents[1], "review-standards").mkdir()
|
||||||
pathlib.Path(claude_md.parents[1], "review-standards", "quality.md").write_text("# Ours\n")
|
pathlib.Path(claude_md.parents[1], "review-standards", "quality.md").write_text("# Ours\n")
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).endswith("From ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/review-standards/quality.md:\n# Ours"), "the config's standards folder replaces the default")
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/review-standards/quality.md:\n# Ours"), "the config's standards folder replaces the default")
|
||||||
config.write_text(config.read_text().replace('"~/review-standards"', f'"{root}/standards"'))
|
config.write_text(config.read_text().replace('"~/review-standards"', f'"{root}/standards"'))
|
||||||
pathlib.Path(root, "standards").mkdir()
|
pathlib.Path(root, "standards").mkdir()
|
||||||
pathlib.Path(root, "standards", "quality.md").write_text("# Elsewhere\n")
|
pathlib.Path(root, "standards", "quality.md").write_text("# Elsewhere\n")
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).endswith(f"From {root}/standards/quality.md:\n# Elsewhere"), "a folder outside home is named in full")
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith(f"From {root}/standards/quality.md:\n# Elsewhere"), "a folder outside home is named in full")
|
||||||
|
|
||||||
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"checkout:docs/decisions.md"'))
|
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"checkout:docs/decisions.md"'))
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).startswith("From AGENTS.md and docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global"), "a file the config names for two records appears once")
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md and docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global"), "a file the config names for two records appears once")
|
||||||
config.write_text(config.read_text().replace('"checkout:docs/decisions.md"', '"checkout:AGENTS.md"', 1))
|
config.write_text(config.read_text().replace('"checkout:docs/decisions.md"', '"checkout:AGENTS.md"', 1))
|
||||||
|
|
||||||
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"folder:AGENTS.md"').replace('"checkout:docs/decisions.md"', '"folder:log/decisions.md"'))
|
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"folder:AGENTS.md"').replace('"checkout:docs/decisions.md"', '"folder:log/decisions.md"'))
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).startswith("From ~/.claude/CLAUDE.md:\n# Global"), "the checkout's AGENTS.md and docs/decisions.md are its owners'")
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From ~/.claude/CLAUDE.md:\n# Global"), "the checkout's AGENTS.md and docs/decisions.md are its owners'")
|
||||||
pathlib.Path(config.parent, "log").mkdir()
|
pathlib.Path(config.parent, "log").mkdir()
|
||||||
pathlib.Path(config.parent, "log", "decisions.md").write_text("# Ours\n")
|
pathlib.Path(config.parent, "log", "decisions.md").write_text("# Ours\n")
|
||||||
pathlib.Path(config.parent, "AGENTS.md").write_text("# Our rules\n")
|
pathlib.Path(config.parent, "AGENTS.md").write_text("# Our rules\n")
|
||||||
self.assertTrue(records.read_records(root, claude_md.parents[1], claude_md.parent).startswith("From AGENTS.md:\n# Our rules\n\nFrom docs/decisions.md:\n# Ours\n\nFrom ~/.claude/CLAUDE.md:\n# Global"))
|
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md:\n# Our rules\n\nFrom docs/decisions.md:\n# Ours\n\nFrom ~/.claude/CLAUDE.md:\n# Global"))
|
||||||
config.unlink()
|
config.unlink()
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"no config names the checkout {root}: write ~/.claude-projects/<key>/config.toml, as `project-config --help` shows - the judge cannot read the records."))
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"no config names the checkout {root}: write {claude_md.parents[1]}/.config/build-release/<key>/config.toml, as `project-config --help` shows - the judge cannot read the records."))
|
||||||
|
|
||||||
def test_puts_the_records_handed_in_first_and_reads_only_the_humans_rules_without_a_checkout(self):
|
def test_puts_the_records_handed_in_first_and_reads_only_the_humans_rules_without_a_checkout(self):
|
||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
@@ -65,19 +65,19 @@ class Records(unittest.TestCase):
|
|||||||
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
|
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
|
||||||
pathlib.Path(root, "AGENTS.md").write_text("# Rules\n")
|
pathlib.Path(root, "AGENTS.md").write_text("# Rules\n")
|
||||||
first = (("the epic ABC-1's description, ## Decisions", "Squash.\n"), ("the epic ABC-1's description, ## Scoring", " \n"))
|
first = (("the epic ABC-1's description, ## Decisions", "Squash.\n"), ("the epic ABC-1's description, ## Scoring", " \n"))
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom AGENTS.md:\n# Rules\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom AGENTS.md:\n# Rules\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")
|
||||||
self.assertEqual(records.read_records(None, claude_md.parents[1], claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo")
|
self.assertEqual(records.read_records(None, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo")
|
||||||
|
|
||||||
def test_stops_on_a_record_it_cannot_read(self):
|
def test_stops_on_a_record_it_cannot_read(self):
|
||||||
with tempfile.TemporaryDirectory() as root:
|
with tempfile.TemporaryDirectory() as root:
|
||||||
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
|
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
|
||||||
configured(self, pathlib.Path(root), home=claude_md.parents[1])
|
configured(self, pathlib.Path(root), home=claude_md.parents[1])
|
||||||
claude_md.mkdir(parents=True)
|
claude_md.mkdir(parents=True)
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
|
||||||
pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True)
|
pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True)
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"cannot read {root}/docs/decisions.md: Is a directory - the judge cannot read the records."))
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"cannot read {root}/docs/decisions.md: Is a directory - the judge cannot read the records."))
|
||||||
pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n")
|
pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n")
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the records."))
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the records."))
|
||||||
|
|
||||||
|
|
||||||
def test_stops_on_a_rule_it_cannot_read(self):
|
def test_stops_on_a_rule_it_cannot_read(self):
|
||||||
@@ -87,7 +87,7 @@ class Records(unittest.TestCase):
|
|||||||
rules = pathlib.Path(claude_md.parent, "rules")
|
rules = pathlib.Path(claude_md.parent, "rules")
|
||||||
rules.mkdir(parents=True)
|
rules.mkdir(parents=True)
|
||||||
pathlib.Path(rules, "todo-items.md").write_bytes(b"\xff\n")
|
pathlib.Path(rules, "todo-items.md").write_bytes(b"\xff\n")
|
||||||
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"todo-items.md in {rules} is not UTF-8 on line 1 - the judge cannot read the records."))
|
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"todo-items.md in {rules} is not UTF-8 on line 1 - the judge cannot read the records."))
|
||||||
|
|
||||||
|
|
||||||
class JudgeRules(unittest.TestCase):
|
class JudgeRules(unittest.TestCase):
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ProjectRouting(unittest.TestCase):
|
|||||||
temp = tempfile.TemporaryDirectory()
|
temp = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(temp.cleanup)
|
self.addCleanup(temp.cleanup)
|
||||||
self.home = pathlib.Path(temp.name)
|
self.home = pathlib.Path(temp.name)
|
||||||
self.paths = paths_from(self.home)
|
self.paths = paths_from(self.home, {})
|
||||||
self.checkout = self.home / "code" / "acme"
|
self.checkout = self.home / "code" / "acme"
|
||||||
self.checkout.mkdir(parents=True)
|
self.checkout.mkdir(parents=True)
|
||||||
self.config = configured(self, self.checkout, home=self.home)
|
self.config = configured(self, self.checkout, home=self.home)
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ def main(argv: list[str]) -> int:
|
|||||||
if argv[:1] in (["-h"], ["--help"]):
|
if argv[:1] in (["-h"], ["--help"]):
|
||||||
print(__doc__.strip())
|
print(__doc__.strip())
|
||||||
return 0
|
return 0
|
||||||
done = step(argv, runner(os.getcwd()), functools.cache(lambda: located(os.getcwd(), pathlib.Path.home())), os.environ.get(PARKS) == "1", time.sleep)
|
done = step(argv, runner(os.getcwd()), functools.cache(lambda: located(os.getcwd(), pathlib.Path.home(), os.environ)), os.environ.get(PARKS) == "1", time.sleep)
|
||||||
if isinstance(done, Failure):
|
if isinstance(done, Failure):
|
||||||
print(f"chunk-pr: {done.reason}", file=sys.stderr)
|
print(f"chunk-pr: {done.reason}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ Exit 1, saying why, on any argument other than --worktree, --item with an ID, -h
|
|||||||
CHUNK_PREFLIGHT_TIMEOUT that is no number of seconds above 0, when git cannot start or finds no
|
CHUNK_PREFLIGHT_TIMEOUT that is no number of seconds above 0, when git cannot start or finds no
|
||||||
checkout or no default branch, or when no config names the checkout or its config cannot be read.
|
checkout or no default branch, or when no config names the checkout or its config cannot be read.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -167,7 +168,7 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non
|
|||||||
if isinstance(default, Failure):
|
if isinstance(default, Failure):
|
||||||
return default
|
return default
|
||||||
ref, note = default
|
ref, note = default
|
||||||
config = located(str(root), pathlib.Path.home())
|
config = located(str(root), pathlib.Path.home(), os.environ)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
outside = None if config.tracked("plan") else config.plan_label
|
outside = None if config.tracked("plan") else config.plan_label
|
||||||
@@ -178,7 +179,7 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non
|
|||||||
# The folder the chunk works in: the item's worktree where one was made or found, else the checkout.
|
# The folder the chunk works in: the item's worktree where one was made or found, else the checkout.
|
||||||
worktree = item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else None
|
worktree = item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else None
|
||||||
# A `checkout:` path lands in the worktree the chunk works in.
|
# A `checkout:` path lands in the worktree the chunk works in.
|
||||||
made = located(str(worktree), pathlib.Path.home()) if worktree else config
|
made = located(str(worktree), pathlib.Path.home(), os.environ) if worktree else config
|
||||||
places = (config if isinstance(made, Failure) else made).places
|
places = (config if isinstance(made, Failure) else made).places
|
||||||
left = left_worktrees(root, forge_run) if config.merge == "human" else ()
|
left = left_worktrees(root, forge_run) if config.merge == "human" else ()
|
||||||
indentation = space_indented(worktree or root, timeout)
|
indentation = space_indented(worktree or root, timeout)
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class Repo:
|
|||||||
class ChunkPreflightTool(unittest.TestCase):
|
class ChunkPreflightTool(unittest.TestCase):
|
||||||
def test_passes_over_an_item_whose_pull_request_awaits_a_persons_merge_and_names_a_worktree_a_merged_one_left(self):
|
def test_passes_over_an_item_whose_pull_request_awaits_a_persons_merge_and_names_a_worktree_a_merged_one_left(self):
|
||||||
repo = Repo(self, origin="github.com/o/r.git")
|
repo = Repo(self, origin="github.com/o/r.git")
|
||||||
config = repo.temp / "home" / ".claude-projects" / "proj" / "config.toml"
|
config = repo.temp / "home" / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(config.read_text() + 'merge = "human"\n')
|
config.write_text(config.read_text() + 'merge = "human"\n')
|
||||||
repo.git(repo.root, "worktree", "add", "--quiet", "-b", "item-3", str(repo.temp / "proj-item-3"), "main")
|
repo.git(repo.root, "worktree", "add", "--quiet", "-b", "item-3", str(repo.temp / "proj-item-3"), "main")
|
||||||
repo.write(repo.temp / "proj-item-3", "todo.md", TODO.replace("| 3 | 0.2.0 | | | **Do the next thing.** | 2 | 2 | 3 | 5 | 3 | 1 by 9 | 56.2 |\n", ""))
|
repo.write(repo.temp / "proj-item-3", "todo.md", TODO.replace("| 3 | 0.2.0 | | | **Do the next thing.** | 2 | 2 | 3 | 5 | 3 | 1 by 9 | 56.2 |\n", ""))
|
||||||
@@ -171,7 +171,7 @@ elif args[:6] == ["pr", "list", "--head", "item-2", "--state", "merged"]:
|
|||||||
|
|
||||||
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_names_where_the_config_puts_each_file(self):
|
def test_reads_a_plan_outside_the_checkout_as_it_stands_and_names_where_the_config_puts_each_file(self):
|
||||||
repo = Repo(self)
|
repo = Repo(self)
|
||||||
folder = repo.temp / "home" / ".claude-projects" / "proj"
|
folder = repo.temp / "home" / ".config/build-release" / "proj"
|
||||||
config = folder / "config.toml"
|
config = folder / "config.toml"
|
||||||
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||||
(folder / "todo.md").write_text(SHIPPED)
|
(folder / "todo.md").write_text(SHIPPED)
|
||||||
@@ -192,7 +192,7 @@ elif args[:6] == ["pr", "list", "--head", "item-2", "--state", "merged"]:
|
|||||||
repo.push_from_elsewhere("todo.md", SHIPPED)
|
repo.push_from_elsewhere("todo.md", SHIPPED)
|
||||||
plain = repo.preflight()
|
plain = repo.preflight()
|
||||||
self.assertIn("- The project's config sets: language English; commit-title {summary}; pull-request-title {summary}; branch item-{id}.\n", plain.stdout)
|
self.assertIn("- The project's config sets: language English; commit-title {summary}; pull-request-title {summary}; branch item-{id}.\n", plain.stdout)
|
||||||
config = repo.temp / "home" / ".claude-projects" / "proj" / "config.toml"
|
config = repo.temp / "home" / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(config.read_text() + 'language = "Swedish"\ncommit-title = "PAY-{id} - {summary}"\nbranch = "feature/PAY-{id}"\n')
|
config.write_text(config.read_text() + 'language = "Swedish"\ncommit-title = "PAY-{id} - {summary}"\nbranch = "feature/PAY-{id}"\n')
|
||||||
done = repo.preflight("--worktree")
|
done = repo.preflight("--worktree")
|
||||||
self.assertEqual(done.returncode, 0, done.stderr)
|
self.assertEqual(done.returncode, 0, done.stderr)
|
||||||
@@ -651,7 +651,7 @@ class EpicBranchWorktree(unittest.TestCase):
|
|||||||
self.assertFalse((self.repo.temp / "proj-item-3").exists())
|
self.assertFalse((self.repo.temp / "proj-item-3").exists())
|
||||||
|
|
||||||
def test_the_tool_makes_no_worktree_where_the_config_sets_an_epic_branch_and_keeps_its_plan_in_a_file(self):
|
def test_the_tool_makes_no_worktree_where_the_config_sets_an_epic_branch_and_keeps_its_plan_in_a_file(self):
|
||||||
config = self.repo.temp / "home" / ".claude-projects" / "proj" / "config.toml"
|
config = self.repo.temp / "home" / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(config.read_text() + 'epic-branch = "{epic}"\n')
|
config.write_text(config.read_text() + 'epic-branch = "{epic}"\n')
|
||||||
done = self.repo.preflight("--worktree")
|
done = self.repo.preflight("--worktree")
|
||||||
self.assertEqual(done.returncode, 0, done.stderr)
|
self.assertEqual(done.returncode, 0, done.stderr)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class Main(unittest.TestCase):
|
|||||||
self.git("commit", "-q", "--allow-empty", "-m", "Start")
|
self.git("commit", "-q", "--allow-empty", "-m", "Start")
|
||||||
self.tag("v0.1.0", "2026-11-01T00:00:00Z")
|
self.tag("v0.1.0", "2026-11-01T00:00:00Z")
|
||||||
self.tag("v0.2.0", "2026-11-05T00:00:00Z")
|
self.tag("v0.2.0", "2026-11-05T00:00:00Z")
|
||||||
archive = self.home / ".claude" / "loop-claude-transcripts" / "project"
|
archive = self.home / ".local/state/build-release" / "transcripts" / "project"
|
||||||
for name, finished, command in (("before", "2026-10-30T00:00:00Z", "make old"), ("between", "2026-11-03T00:00:00Z", "tea pr create"), ("after", "2026-11-07T00:00:00Z", "gh pr view")):
|
for name, finished, command in (("before", "2026-10-30T00:00:00Z", "make old"), ("between", "2026-11-03T00:00:00Z", "tea pr create"), ("after", "2026-11-07T00:00:00Z", "gh pr view")):
|
||||||
folder = archive / name
|
folder = archive / name
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
usage: compress-archives
|
usage: compress-archives
|
||||||
|
|
||||||
It gzips each file that last changed over 30 days ago: in build-release's archive,
|
It gzips each file that last changed over 30 days ago: in build-release's archive,
|
||||||
$BUILD_RELEASE_TRANSCRIPTS (default ~/.claude/loop-claude-transcripts), each transcript, *.jsonl;
|
$BUILD_RELEASE_TRANSCRIPTS (default ~/.local/state/build-release/transcripts), each transcript, *.jsonl;
|
||||||
in the review folders, ~/.local/state/larv-review, every file but a lock, *.lock. A file's last change is the later
|
in the review folders, ~/.local/state/build-release/larv-review, every file but a lock, *.lock. A file's last change is the later
|
||||||
of its mtime and ctime, so a copied or unpacked file counts from when it landed.
|
of its mtime and ctime, so a copied or unpacked file counts from when it landed.
|
||||||
|
|
||||||
The gzip lands beside the file as <name>.gz, with the same times. The file is removed only once
|
The gzip lands beside the file as <name>.gz, with the same times. The file is removed only once
|
||||||
@@ -13,6 +13,8 @@ its plain name. README.md → Install has the crontab line that runs it daily.
|
|||||||
|
|
||||||
It prints how many files it compressed. It exits 1, saying why, on any argument but --help or -h,
|
It prints how many files it compressed. It exits 1, saying why, on any argument but --help or -h,
|
||||||
and at the first file it cannot compress, leaving that file and every one after it plain.
|
and at the first file it cannot compress, leaving that file and every one after it plain.
|
||||||
|
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import stat
|
import stat
|
||||||
@@ -21,7 +23,7 @@ import typing
|
|||||||
|
|
||||||
from transcript_archive.location import archive_root
|
from transcript_archive.location import archive_root
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from review_rules.review_folder import REPORTS
|
from review_rules.review_folder import reports_folder
|
||||||
from text_files.compressed import SUFFIX
|
from text_files.compressed import SUFFIX
|
||||||
|
|
||||||
# Why 30 days: docs/decisions.md → `archives: gzip each transcript in build-release's archive and each file in the review folders 30 days after it last changed, keeping all of them`.
|
# Why 30 days: docs/decisions.md → `archives: gzip each transcript in build-release's archive and each file in the review folders 30 days after it last changed, keeping all of them`.
|
||||||
@@ -37,7 +39,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, now
|
|||||||
return 1
|
return 1
|
||||||
cutoff = now() - AGE_DAYS * 24 * 60 * 60
|
cutoff = now() - AGE_DAYS * 24 * 60 * 60
|
||||||
count = 0
|
count = 0
|
||||||
for path in [*old_files(archive_root(home, env), "*.jsonl", cutoff), *old_files(home / REPORTS, "*", cutoff)]:
|
for path in [*old_files(archive_root(home, env), "*.jsonl", cutoff), *old_files(reports_folder(home, env), "*", cutoff)]:
|
||||||
if failed := compress(path):
|
if failed := compress(path):
|
||||||
print(failed.reason, file=sys.stderr)
|
print(failed.reason, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class Main(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||||
self.archive = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
self.archive = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
self.reviews = self.home / ".local" / "state" / "larv-review" / "code" / "proj-item-1"
|
self.reviews = self.home / ".local" / "state" / "build-release" / "larv-review" / "code" / "proj-item-1"
|
||||||
for folder in (self.archive / "session" / "s" / "subagents", self.reviews / "probe"):
|
for folder in (self.archive / "session" / "s" / "subagents", self.reviews / "probe"):
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
self.write(self.archive / "a.jsonl", OLD)
|
self.write(self.archive / "a.jsonl", OLD)
|
||||||
@@ -57,14 +57,14 @@ class Main(unittest.TestCase):
|
|||||||
code, out, err = self.run_main()
|
code, out, err = self.run_main()
|
||||||
self.assertEqual((code, err), (0, ""))
|
self.assertEqual((code, err), (0, ""))
|
||||||
self.assertEqual(self.kept(), [
|
self.assertEqual(self.kept(), [
|
||||||
".claude/loop-claude-transcripts/proj/c1/a.jsonl.gz",
|
".local/state/build-release/larv-review/code/proj-item-1/branch-1.diff",
|
||||||
".claude/loop-claude-transcripts/proj/c1/a.outcomes.md",
|
".local/state/build-release/larv-review/code/proj-item-1/probe/out.js.gz",
|
||||||
".claude/loop-claude-transcripts/proj/c1/b.jsonl",
|
".local/state/build-release/larv-review/code/proj-item-1/stability-round-1.md.gz",
|
||||||
".claude/loop-claude-transcripts/proj/c1/session/s/subagents/agent-a.jsonl.gz",
|
".local/state/build-release/transcripts/proj/c1/a.jsonl.gz",
|
||||||
".claude/loop-claude-transcripts/proj/c1/session/s/subagents/agent-a.meta.json",
|
".local/state/build-release/transcripts/proj/c1/a.outcomes.md",
|
||||||
".local/state/larv-review/code/proj-item-1/branch-1.diff",
|
".local/state/build-release/transcripts/proj/c1/b.jsonl",
|
||||||
".local/state/larv-review/code/proj-item-1/probe/out.js.gz",
|
".local/state/build-release/transcripts/proj/c1/session/s/subagents/agent-a.jsonl.gz",
|
||||||
".local/state/larv-review/code/proj-item-1/stability-round-1.md.gz",
|
".local/state/build-release/transcripts/proj/c1/session/s/subagents/agent-a.meta.json",
|
||||||
])
|
])
|
||||||
self.assertEqual(gzip.decompress((self.archive / "a.jsonl.gz").read_bytes()), b"a.jsonl\n")
|
self.assertEqual(gzip.decompress((self.archive / "a.jsonl.gz").read_bytes()), b"a.jsonl\n")
|
||||||
self.assertEqual(out, "Compressed 4 files.\n")
|
self.assertEqual(out, "Compressed 4 files.\n")
|
||||||
@@ -103,7 +103,7 @@ class Main(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_the_archive_where_build_release_transcripts_puts_it(self):
|
def test_reads_the_archive_where_build_release_transcripts_puts_it(self):
|
||||||
moved = self.home / "elsewhere"
|
moved = self.home / "elsewhere"
|
||||||
(self.home / ".claude" / "loop-claude-transcripts").rename(moved)
|
(self.home / ".local/state/build-release" / "transcripts").rename(moved)
|
||||||
code, _, err = self.run_main(env={"BUILD_RELEASE_TRANSCRIPTS": str(moved)})
|
code, _, err = self.run_main(env={"BUILD_RELEASE_TRANSCRIPTS": str(moved)})
|
||||||
self.assertEqual((code, err), (0, ""))
|
self.assertEqual((code, err), (0, ""))
|
||||||
self.assertTrue((moved / "proj" / "c1" / "a.jsonl.gz").is_file())
|
self.assertTrue((moved / "proj" / "c1" / "a.jsonl.gz").is_file())
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ with --cut-patch.
|
|||||||
It says on stderr as each step finishes, and ends stdout, after the changelog, with the line
|
It says on stderr as each step finishes, and ends stdout, after the changelog, with the line
|
||||||
`Done: v<version> is cut and pushed, and <checkout> is on it.`
|
`Done: v<version> is cut and pushed, and <checkout> is on it.`
|
||||||
It keeps each of those lines, with its time in UTC, in the run's trace: a file of its own under
|
It keeps each of those lines, with its time in UTC, in the run's trace: a file of its own under
|
||||||
$XDG_STATE_HOME/deploy-release (default ~/.local/state/deploy-release), named by when the run began. --cut-patch does too.
|
$XDG_STATE_HOME/build-release/deploy-release (default ~/.local/state/build-release/deploy-release), named by when the run began. --cut-patch does too.
|
||||||
Where Ctrl-C or an unexpected fault ends the run, the trace ends with a line that starts `stopped:`.
|
Where Ctrl-C or an unexpected fault ends the run, the trace ends with a line that starts `stopped:`.
|
||||||
Where a step fails it stops, exit 1, with git's or the forge's reason, and leaves the pull request
|
Where a step fails it stops, exit 1, with git's or the forge's reason, and leaves the pull request
|
||||||
and the branch as they are. A rerun continues: it takes the branch's open pull request and a cut
|
and the branch as they are. A rerun continues: it takes the branch's open pull request and a cut
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ class Cut(unittest.TestCase):
|
|||||||
|
|
||||||
def traces(self) -> list[str]:
|
def traces(self) -> list[str]:
|
||||||
"""The text of each run's trace, oldest first."""
|
"""The text of each run's trace, oldest first."""
|
||||||
return [file.read_text() for file in sorted((self.temp / "state" / "deploy-release").glob("*.log")) if not file.name.endswith("-ci.log")]
|
return [file.read_text() for file in sorted((self.temp / "state" / "build-release" / "deploy-release").glob("*.log")) if not file.name.endswith("-ci.log")]
|
||||||
|
|
||||||
def test_keeps_each_step_of_a_cut_with_its_time_in_a_file_of_the_run(self):
|
def test_keeps_each_step_of_a_cut_with_its_time_in_a_file_of_the_run(self):
|
||||||
self.assert_cut(self.cut())
|
self.assert_cut(self.cut())
|
||||||
@@ -500,7 +500,7 @@ class Cut(unittest.TestCase):
|
|||||||
self.assertRegex(lines[0], rf"^[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}T[0-9:]{{8}}Z deploy-release --cut {self.target} in {self.clone}$")
|
self.assertRegex(lines[0], rf"^[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}T[0-9:]{{8}}Z deploy-release --cut {self.target} in {self.clone}$")
|
||||||
self.assertRegex(kept, r"(?m)^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}Z pushed the tag v0\.2\.0$")
|
self.assertRegex(kept, r"(?m)^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}Z pushed the tag v0\.2\.0$")
|
||||||
self.assertIn("Done: v0.2.0 is cut and pushed", lines[-1])
|
self.assertIn("Done: v0.2.0 is cut and pushed", lines[-1])
|
||||||
[file] = (self.temp / "state" / "deploy-release").glob("*.log")
|
[file] = (self.temp / "state" / "build-release" / "deploy-release").glob("*.log")
|
||||||
self.assertRegex(file.name, r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}-[0-9]{2}-[0-9]{2}Z-[0-9]+\.log$")
|
self.assertRegex(file.name, r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}-[0-9]{2}-[0-9]{2}Z-[0-9]+\.log$")
|
||||||
|
|
||||||
def test_keeps_the_reason_a_cut_stopped_in_its_trace_and_a_rerun_writes_its_own(self):
|
def test_keeps_the_reason_a_cut_stopped_in_its_trace_and_a_rerun_writes_its_own(self):
|
||||||
@@ -556,7 +556,7 @@ class Cut(unittest.TestCase):
|
|||||||
def test_says_where_ci_shs_output_goes_and_keeps_it_there(self):
|
def test_says_where_ci_shs_output_goes_and_keeps_it_there(self):
|
||||||
ran = self.cut_patch(self.plan_patch({"ci.sh": "echo the suite ran\nexit 0\n"}))
|
ran = self.cut_patch(self.plan_patch({"ci.sh": "echo the suite ran\nexit 0\n"}))
|
||||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||||
[log] = (self.temp / "state" / "deploy-release").glob("*-ci.log")
|
[log] = (self.temp / "state" / "build-release" / "deploy-release").glob("*-ci.log")
|
||||||
self.assertEqual(log.read_text(), "the suite ran\n")
|
self.assertEqual(log.read_text(), "the suite ran\n")
|
||||||
self.assertIn(f"ci.sh's output goes to {log}", ran.stderr)
|
self.assertIn(f"ci.sh's output goes to {log}", ran.stderr)
|
||||||
|
|
||||||
@@ -966,8 +966,8 @@ class Trace(unittest.TestCase):
|
|||||||
self.now = lambda: 1795771805.0
|
self.now = lambda: 1795771805.0
|
||||||
|
|
||||||
def test_keeps_traces_under_the_state_folder_xdg_names_else_under_homes(self):
|
def test_keeps_traces_under_the_state_folder_xdg_names_else_under_homes(self):
|
||||||
self.assertEqual(trace.trace_folder({"XDG_STATE_HOME": "/x/state"}, pathlib.Path("/home/u")), pathlib.Path("/x/state/deploy-release"))
|
self.assertEqual(trace.trace_folder({"XDG_STATE_HOME": "/x/state"}, pathlib.Path("/home/u")), pathlib.Path("/x/state/build-release/deploy-release"))
|
||||||
self.assertEqual(trace.trace_folder({}, pathlib.Path("/home/u")), pathlib.Path("/home/u/.local/state/deploy-release"))
|
self.assertEqual(trace.trace_folder({}, pathlib.Path("/home/u")), pathlib.Path("/home/u/.local/state/build-release/deploy-release"))
|
||||||
|
|
||||||
def test_names_a_run_by_its_start_and_its_process(self):
|
def test_names_a_run_by_its_start_and_its_process(self):
|
||||||
self.assertEqual(trace.run_name(self.now(), 4711), "2026-11-27T09-30-05Z-4711")
|
self.assertEqual(trace.run_name(self.now(), 4711), "2026-11-27T09-30-05Z-4711")
|
||||||
|
|||||||
+1
-1
@@ -10,4 +10,4 @@ from loop_effects import effects
|
|||||||
from do_epic import main
|
from do_epic import main
|
||||||
from loop_state import paths
|
from loop_state import paths
|
||||||
|
|
||||||
sys.exit(main.main(sys.argv[1:], os.environ, paths.paths_from(pathlib.Path.home()), LAUNCHER, effects.system_effects(pathlib.Path.home(), os.environ)))
|
sys.exit(main.main(sys.argv[1:], os.environ, paths.paths_from(pathlib.Path.home(), os.environ), LAUNCHER, effects.system_effects(pathlib.Path.home(), os.environ)))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from do_epic.backend.jira_start import Start, started
|
|||||||
FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"]
|
FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"]
|
||||||
# How many child issues one search for sub-tasks names, which keeps its JQL well inside the length Jira takes.
|
# How many child issues one search for sub-tasks names, which keeps its JQL well inside the length Jira takes.
|
||||||
PARENTS_PER_SEARCH = 50
|
PARENTS_PER_SEARCH = 50
|
||||||
NO_FINISH = "do-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""
|
NO_FINISH = "do-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ class Jira(Case):
|
|||||||
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
||||||
unconverted = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda markdown: Failure("adf-codec refused it"), Finish("Mark as done", "Done"))
|
unconverted = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda markdown: Failure("adf-codec refused it"), Finish("Mark as done", "Done"))
|
||||||
for store, reason in (
|
for store, reason in (
|
||||||
(unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""),
|
(unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""),
|
||||||
(wrong_status, "ABC-12's transition 'Start' leads to the status 'In Progress', not to 'Done', which `jira-finish-status` names"),
|
(wrong_status, "ABC-12's transition 'Start' leads to the status 'In Progress', not to 'Done', which `jira-finish-status` names"),
|
||||||
(unconverted, "cannot convert the summary to a Jira comment: adf-codec refused it"),
|
(unconverted, "cannot convert the summary to a Jira comment: adf-codec refused it"),
|
||||||
):
|
):
|
||||||
@@ -523,7 +523,7 @@ class Jira(Case):
|
|||||||
unnamed = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf)
|
unnamed = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf)
|
||||||
wrong_status = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Mark as done", "Closed"))
|
wrong_status = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Mark as done", "Closed"))
|
||||||
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
||||||
self.assertEqual(unnamed.finish_issue(key), Failure("do-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""))
|
self.assertEqual(unnamed.finish_issue(key), Failure("do-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""))
|
||||||
self.assertEqual(wrong_status.finish_issue(key), Failure(f"{key}'s transition 'Mark as done' leads to the status 'Done', not to 'Closed', which `jira-finish-status` names"))
|
self.assertEqual(wrong_status.finish_issue(key), Failure(f"{key}'s transition 'Mark as done' leads to the status 'Done', not to 'Closed', which `jira-finish-status` names"))
|
||||||
refused = no_such.finish_issue(key)
|
refused = no_such.finish_issue(key)
|
||||||
assert isinstance(refused, Failure)
|
assert isinstance(refused, Failure)
|
||||||
|
|||||||
+12
-9
@@ -1,4 +1,4 @@
|
|||||||
"""do-epic's machine-wide settings: `~/.claude-projects/do-epic/config.toml`, and `repo-rule.md` beside it.
|
"""do-epic's machine-wide settings: `do-epic/config.toml` in the config folder (`loop_state.paths.config_folder`), and `repo-rule.md` beside it.
|
||||||
|
|
||||||
One pair per machine, the same for every epic (docs/decisions.md → `do-epic: drives one Jira epic …`). The config is TOML:
|
One pair per machine, the same for every epic (docs/decisions.md → `do-epic: drives one Jira epic …`). The config is TOML:
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
|||||||
twu-4 = "tenant-web-ui-4"
|
twu-4 = "tenant-web-ui-4"
|
||||||
|
|
||||||
- `jira-url` is the Jira site's address: https, a host, and no path.
|
- `jira-url` is the Jira site's address: https, a host, and no path.
|
||||||
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of `~/.claude-projects` and outside the clone folder, which hold git checkouts. `~/.claude-projects/<key>.env` is fine.
|
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of the config folder and outside the clone folder, which hold git checkouts. `<key>.env` in the config folder itself is fine.
|
||||||
- `repoless-model` is the model that works an epic item with no repo: a model on the routing ladder, `model_routing/routing-ladder.json`.
|
- `repoless-model` is the model that works an epic item with no repo: a model on the routing ladder, `model_routing/routing-ladder.json`.
|
||||||
- `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out.
|
- `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out.
|
||||||
- `language` is the default language of Jira text, by its English name. English where left out.
|
- `language` is the default language of Jira text, by its English name. English where left out.
|
||||||
@@ -27,12 +27,14 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
|||||||
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, do-epic writes the label of the first.
|
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, do-epic writes the label of the first.
|
||||||
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
|
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from project_config.settings import anywhere, CONFIG, DEFAULT_ISSUE_TYPE, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINDING_TYPE, JIRA_FINISH, JIRA_REVIEW_TYPE, LANGUAGE, language_fault, lies_in, name_of, parsed, PROJECTS, SITE, type_fault
|
from project_config.settings import anywhere, CONFIG, DEFAULT_ISSUE_TYPE, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINDING_TYPE, JIRA_FINISH, JIRA_REVIEW_TYPE, LANGUAGE, language_fault, lies_in, name_of, parsed, SITE, type_fault
|
||||||
|
from loop_state.paths import config_folder
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from do_epic.backend.protocol import LABEL, REVIEW_LABEL
|
from do_epic.backend.protocol import LABEL, REVIEW_LABEL
|
||||||
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME
|
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME
|
||||||
@@ -64,7 +66,7 @@ LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTION
|
|||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class DoEpicConfig:
|
class DoEpicConfig:
|
||||||
"""folder is `~/.claude-projects/do-epic`; repo_rule is `repo-rule.md`'s text."""
|
"""folder is `do-epic` in the config folder; repo_rule is `repo-rule.md`'s text."""
|
||||||
folder: pathlib.Path
|
folder: pathlib.Path
|
||||||
jira_url: str
|
jira_url: str
|
||||||
env_file: pathlib.Path
|
env_file: pathlib.Path
|
||||||
@@ -151,9 +153,10 @@ def workflow_faults(values: dict[str, object]) -> list[str]:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
|
def load(home: pathlib.Path, env: Mapping[str, str], ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
|
||||||
"""The settings and the repo rule under home; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that do-epic refuses to start."""
|
"""The settings and the repo rule in the config folder; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that do-epic refuses to start."""
|
||||||
folder = home / PROJECTS / DO_EPIC
|
configs = config_folder(env, home)
|
||||||
|
folder = configs / DO_EPIC
|
||||||
values = parsed(folder / CONFIG)
|
values = parsed(folder / CONFIG)
|
||||||
if isinstance(values, Failure):
|
if isinstance(values, Failure):
|
||||||
return Failure(f"{values.reason}. {LISTED}")
|
return Failure(f"{values.reason}. {LISTED}")
|
||||||
@@ -166,7 +169,7 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
|||||||
rule = (folder / REPO_RULE).read_text(encoding="utf-8")
|
rule = (folder / REPO_RULE).read_text(encoding="utf-8")
|
||||||
except (OSError, UnicodeDecodeError) as failure:
|
except (OSError, UnicodeDecodeError) as failure:
|
||||||
rule = Failure(f"cannot read {folder / REPO_RULE}: {failure}")
|
rule = Failure(f"cannot read {folder / REPO_RULE}: {failure}")
|
||||||
config_folders = [path for path in (home / PROJECTS).iterdir() if path.is_dir()]
|
config_folders = [path for path in configs.iterdir() if path.is_dir()]
|
||||||
clone_folder = anywhere(values.get(CLONE_FOLDER, "~/code"), home)
|
clone_folder = anywhere(values.get(CLONE_FOLDER, "~/code"), home)
|
||||||
env_file = anywhere(values.get(ENV_FILE), home)
|
env_file = anywhere(values.get(ENV_FILE), home)
|
||||||
language = values.get(LANGUAGE, "English")
|
language = values.get(LANGUAGE, "English")
|
||||||
@@ -177,7 +180,7 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
|||||||
*([f"`{JIRA_URL}` is {url!r}, not a site's https address without a path, such as \"https://acme.atlassian.net\""] if JIRA_URL in values and not (isinstance(url, str) and re.fullmatch(SITE, url)) else []),
|
*([f"`{JIRA_URL}` is {url!r}, not a site's https address without a path, such as \"https://acme.atlassian.net\""] if JIRA_URL in values and not (isinstance(url, str) and re.fullmatch(SITE, url)) else []),
|
||||||
*([f"`{CLONE_FOLDER}` is {values[CLONE_FOLDER]!r}, not a path that starts with / or ~/"] if clone_folder is None else []),
|
*([f"`{CLONE_FOLDER}` is {values[CLONE_FOLDER]!r}, not a path that starts with / or ~/"] if clone_folder is None else []),
|
||||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, not a path that starts with / or ~/"] if ENV_FILE in values and env_file is None else []),
|
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, not a path that starts with / or ~/"] if ENV_FILE in values and env_file is None else []),
|
||||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of ~/{PROJECTS} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []),
|
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of {configs} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []),
|
||||||
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
|
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
|
||||||
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
|
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
|
||||||
*finish_faults(values),
|
*finish_faults(values),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import tempfile
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL
|
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL
|
||||||
from loop_state.paths import CONFIG_FOLDER
|
from loop_state.paths import config_folder, without_xdg_folders
|
||||||
from project_config.settings import Epic, Finish
|
from project_config.settings import Epic, Finish
|
||||||
from do_epic import epic_record, findings, finish
|
from do_epic import epic_record, findings, finish
|
||||||
from record_store.jira_description import EpicDescription
|
from record_store.jira_description import EpicDescription
|
||||||
@@ -56,7 +56,9 @@ class Machine:
|
|||||||
|
|
||||||
|
|
||||||
def machine_made(home: pathlib.Path, sandbox: Sandbox, launcher: pathlib.Path, env: typing.Mapping[str, str]) -> Machine | Failure:
|
def machine_made(home: pathlib.Path, sandbox: Sandbox, launcher: pathlib.Path, env: typing.Mapping[str, str]) -> Machine | Failure:
|
||||||
folder = home / CONFIG_FOLDER / "do-epic"
|
# So that do-epic keeps its config and state under home.
|
||||||
|
env = without_xdg_folders(env)
|
||||||
|
folder = config_folder(env, home) / "do-epic"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
ladder = read_ladder(SHIPPED)
|
ladder = read_ladder(SHIPPED)
|
||||||
if isinstance(ladder, Failure):
|
if isinstance(ladder, Failure):
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class MachineTest(unittest.TestCase):
|
|||||||
machine = scenario.machine_made(home, self.sandbox, pathlib.Path("do-epic"), {"A": "b"})
|
machine = scenario.machine_made(home, self.sandbox, pathlib.Path("do-epic"), {"A": "b"})
|
||||||
assert not isinstance(machine, Failure), machine
|
assert not isinstance(machine, Failure), machine
|
||||||
self.assertEqual((machine.home, machine.launcher, machine.env), (home, pathlib.Path("do-epic"), {"A": "b"}))
|
self.assertEqual((machine.home, machine.launcher, machine.env), (home, pathlib.Path("do-epic"), {"A": "b"}))
|
||||||
config = load(home)
|
config = load(home, {})
|
||||||
assert not isinstance(config, Failure), config
|
assert not isinstance(config, Failure), config
|
||||||
self.assertEqual((config.jira_url, config.env_file, config.repo_rule), ("https://acme.atlassian.net", self.env_file, scenario.RULE))
|
self.assertEqual((config.jira_url, config.env_file, config.repo_rule), ("https://acme.atlassian.net", self.env_file, scenario.RULE))
|
||||||
self.assertEqual((config.finish.transition, config.finish.status) if config.finish else None, ("Done", "Done"))
|
self.assertEqual((config.finish.transition, config.finish.status) if config.finish else None, ("Done", "Done"))
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ class EpicRun:
|
|||||||
def session(self) -> str:
|
def session(self) -> str:
|
||||||
return tmux.session_name(tmux.EPIC, self.key)
|
return tmux.session_name(tmux.EPIC, self.key)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def folder(self) -> pathlib.Path:
|
||||||
|
return scheduler.epic_folder(self.paths.state_folder, self.key)
|
||||||
|
|
||||||
|
|
||||||
def chunks_started(epic: EpicRun, issues: list[EpicIssue], own: str | None, told: str = "") -> scheduler.Started | Failure:
|
def chunks_started(epic: EpicRun, issues: list[EpicIssue], own: str | None, told: str = "") -> scheduler.Started | Failure:
|
||||||
"""scheduler.start_chunks on the epic's issues, as read, in order of score, and its cap, read afresh; own is the issue of the chunk that asks, and told is the reason the planning just gave for stopping, which isn't said twice. Where no issue is open, the chunk to start is the epic's finishing, unless the epic is closed."""
|
"""scheduler.start_chunks on the epic's issues, as read, in order of score, and its cap, read afresh; own is the issue of the chunk that asks, and told is the reason the planning just gave for stopping, which isn't said twice. Where no issue is open, the chunk to start is the epic's finishing, unless the epic is closed."""
|
||||||
@@ -57,7 +61,7 @@ def chunks_started(epic: EpicRun, issues: list[EpicIssue], own: str | None, told
|
|||||||
|
|
||||||
def planned_epic(epic: EpicRun) -> planning.Planned:
|
def planned_epic(epic: EpicRun) -> planning.Planned:
|
||||||
"""The epic as planning reads and writes it."""
|
"""The epic as planning reads and writes it."""
|
||||||
return planning.Planned(epic.key, epic.config, epic.store, epic.record, epic.paths.home, epic.effects)
|
return planning.Planned(epic.key, epic.config, epic.store, epic.record, epic.paths.home, epic.env, epic.folder, epic.effects)
|
||||||
|
|
||||||
|
|
||||||
def scheduled_epic(epic: EpicRun, order: tuple[str, ...]) -> scheduler.Epic | Failure:
|
def scheduled_epic(epic: EpicRun, order: tuple[str, ...]) -> scheduler.Epic | Failure:
|
||||||
@@ -69,13 +73,13 @@ def scheduled_epic(epic: EpicRun, order: tuple[str, ...]) -> scheduler.Epic | Fa
|
|||||||
seen: list[pathlib.Path] = []
|
seen: list[pathlib.Path] = []
|
||||||
|
|
||||||
def located(name: str) -> tuple[pathlib.Path, int] | Failure:
|
def located(name: str) -> tuple[pathlib.Path, int] | Failure:
|
||||||
found = locate(name, [checkout for checkout in seen], epic.config, epic.paths.home, epic.effects.git)
|
found = locate(name, [checkout for checkout in seen], epic.config, epic.paths.home, epic.env, epic.effects.git)
|
||||||
if isinstance(found, Failure):
|
if isinstance(found, Failure):
|
||||||
return found
|
return found
|
||||||
seen.append(found.checkout)
|
seen.append(found.checkout)
|
||||||
return real(found.checkout), found.config.parallel_chunks
|
return real(found.checkout), found.config.parallel_chunks
|
||||||
|
|
||||||
return scheduler.Epic(epic.key, cap, located, epic.paths.home, epic.launcher, epic.env, epic.config.label_repos, order, epic.config.unblocking)
|
return scheduler.Epic(epic.key, cap, located, epic.paths, epic.launcher, epic.env, epic.config.label_repos, order, epic.config.unblocking)
|
||||||
|
|
||||||
|
|
||||||
def real(checkout: pathlib.Path) -> pathlib.Path:
|
def real(checkout: pathlib.Path) -> pathlib.Path:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"""A human's task that holds up other issues of an epic (docs/decisions.md → `do-epic: drives one Jira epic …`, "Human tasks").
|
"""A human's task that holds up other issues of an epic (docs/decisions.md → `do-epic: drives one Jira epic …`, "Human tasks").
|
||||||
|
|
||||||
A window that starts again, as after a reboot, DMs again, and so does one whose DM failed, on its next read."""
|
A window that starts again, as after a reboot, DMs again, and so does one whose DM failed, on its next read."""
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from project_config.settings import by_name, ProjectConfig
|
from project_config.settings import by_name, ProjectConfig
|
||||||
@@ -27,17 +28,17 @@ def message(task: EpicIssue, epic: str, held: list[str]) -> str:
|
|||||||
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. do-epic goes on once you close {task.key} in Jira."
|
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. do-epic goes on once you close {task.key} in Jira."
|
||||||
|
|
||||||
|
|
||||||
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path) -> str | None:
|
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path, env: Mapping[str, str]) -> str | None:
|
||||||
"""The checkout of the first of issues whose repo has a git checkout and a project config that names a notifier: where the DM finds that notifier, since the window runs in no checkout. None where there is none."""
|
"""The checkout of the first of issues whose repo has a git checkout and a project config that names a notifier: where the DM finds that notifier, since the window runs in no checkout. None where there is none."""
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
pick = recorded(issue, team)
|
pick = recorded(issue, team)
|
||||||
found = by_name(pick.name, home) if isinstance(pick, Repo) else None
|
found = by_name(pick.name, home, env) if isinstance(pick, Repo) else None
|
||||||
if isinstance(found, ProjectConfig) and found.notifier and (found.top / ".git").exists():
|
if isinstance(found, ProjectConfig) and found.notifier and (found.top / ".git").exists():
|
||||||
return str(found.top)
|
return str(found.top)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unblocking: tuple[str, ...], window: tmux.Window, poll: int, home: pathlib.Path, effects: Effects) -> None:
|
def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unblocking: tuple[str, ...], window: tmux.Window, poll: int, home: pathlib.Path, env: Mapping[str, str], effects: Effects) -> None:
|
||||||
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it no longer holds up any issue. A read of the epic that fails is said once and tried again."""
|
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it no longer holds up any issue. A read of the epic that fails is said once and tried again."""
|
||||||
tmux.park(window, AWAITS, effects.tmux)
|
tmux.park(window, AWAITS, effects.tmux)
|
||||||
told, said = False, None
|
told, said = False, None
|
||||||
@@ -53,7 +54,7 @@ def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unbl
|
|||||||
text = message(task, epic, held)
|
text = message(task, epic, held)
|
||||||
say(text, effects, stdout=True)
|
say(text, effects, stdout=True)
|
||||||
# The issues it holds up come first; any other issue of the epic may do where they have no repo with a notifier.
|
# The issues it holds up come first; any other issue of the epic may do where they have no repo with a notifier.
|
||||||
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), team, home)
|
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), team, home, env)
|
||||||
if where is None:
|
if where is None:
|
||||||
say("no DM went out: no issue of the epic has a repo whose project config names a notifier and whose checkout exists", effects, stdout=True)
|
say("no DM went out: no issue of the epic has a repo whose project config names a notifier and whose checkout exists", effects, stdout=True)
|
||||||
told = where is None or tell(text, effects, where)
|
told = where is None or tell(text, effects, where)
|
||||||
|
|||||||
+20
-18
@@ -14,7 +14,6 @@ from chunk_driver.claims import CHUNK_FLAG
|
|||||||
from do_epic import chunk_prompt, dry_run, findings, finish, human_tasks, parent_moves, planning, scheduler, split, status
|
from do_epic import chunk_prompt, dry_run, findings, finish, human_tasks, parent_moves, planning, scheduler, split, status
|
||||||
from chunk_driver.chunk_run import ChunkRun, closed_cycle
|
from chunk_driver.chunk_run import ChunkRun, closed_cycle
|
||||||
from do_epic.epic_run import chunks_started, EpicRun, planned_epic, POLL_SECONDS, real
|
from do_epic.epic_run import chunks_started, EpicRun, planned_epic, POLL_SECONDS, real
|
||||||
from loop_state.paths import CLAUDE_HOME, Paths
|
|
||||||
from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
|
from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
|
||||||
from project_config.main import located as config_located
|
from project_config.main import located as config_located
|
||||||
from chunk_driver.project.records import CONSEQUENCE, read_records
|
from chunk_driver.project.records import CONSEQUENCE, read_records
|
||||||
@@ -36,6 +35,7 @@ from do_epic.repos import locate
|
|||||||
from chunk_driver.this_loop import Loop
|
from chunk_driver.this_loop import Loop
|
||||||
from do_epic.parking import Merged, parked_through
|
from do_epic.parking import Merged, parked_through
|
||||||
from chunk_driver.project.model_choice import Models, overridden
|
from chunk_driver.project.model_choice import Models, overridden
|
||||||
|
from loop_state.paths import Paths
|
||||||
from chunk_driver.project.premises import read_premises
|
from chunk_driver.project.premises import read_premises
|
||||||
from git_cli.git_repo import record_chunk_base
|
from git_cli.git_repo import record_chunk_base
|
||||||
from forge.commands import Run, runner
|
from forge.commands import Run, runner
|
||||||
@@ -73,9 +73,11 @@ request is ready, with nothing else to wait on, the window's name says `awaits y
|
|||||||
A repo that is missing isn't cloned. Planning then stops there, so its writes are only those made before it, and the issues of that repo wait, and a chunk of another repo may start in the place a real run gives them; a real run would clone it and go on.
|
A repo that is missing isn't cloned. Planning then stops there, so its writes are only those made before it, and the issues of that repo wait, and a chunk of another repo may start in the place a real run gives them; a real run would clone it and go on.
|
||||||
{findings.HELP}
|
{findings.HELP}
|
||||||
{finish.HELP}
|
{finish.HELP}
|
||||||
The Jira site and its credentials are set in ~/.claude-projects/do-epic/config.toml."""
|
The Jira site and its credentials are set in ~/.config/build-release/do-epic/config.toml.
|
||||||
# Under the home folder, where a chunk's cycles are archived, a folder per epic. It is not build-release's archive, since that archive's readers, such as judge-replay and the routing figures, read build-release's prompts.
|
|
||||||
ARCHIVE = f"{CLAUDE_HOME}/do-epic-transcripts"
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path."""
|
||||||
|
# The folder in the state folder where a chunk's cycles are archived, in a folder per epic. It is not build-release's archive, since that archive's readers, such as judge-replay and the routing figures, read build-release's prompts.
|
||||||
|
ARCHIVE = "do-epic-transcripts"
|
||||||
# The flag that prints what each open issue does.
|
# The flag that prints what each open issue does.
|
||||||
STATUS_FLAG = "--status"
|
STATUS_FLAG = "--status"
|
||||||
# The flag that prints what planning and the scheduler would do, without doing it.
|
# The flag that prints what planning and the scheduler would do, without doing it.
|
||||||
@@ -119,11 +121,11 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
|
|||||||
if (len(words) != 1 and not writes and not closes) or not ISSUE_KEY.fullmatch(words[0]) or (chunk is not None and not ISSUE_KEY.fullmatch(chunk)):
|
if (len(words) != 1 and not writes and not closes) or not ISSUE_KEY.fullmatch(words[0]) or (chunk is not None and not ISSUE_KEY.fullmatch(chunk)):
|
||||||
return Stop(0 if words in (["-h"], ["--help"]) else 1, HELP)
|
return Stop(0 if words in (["-h"], ["--help"]) else 1, HELP)
|
||||||
if writes or closes:
|
if writes or closes:
|
||||||
return epic_written(words[0], writes, paths, backend, stdin)
|
return epic_written(words[0], writes, paths, env, backend, stdin)
|
||||||
# Before anything starts: a clone, a claude session or a tmux window.
|
# Before anything starts: a clone, a claude session or a tmux window.
|
||||||
if not dry_run_asked and (reason := tmux.unusable(effects.tmux, chunk_prompt.DRIVER)):
|
if not dry_run_asked and (reason := tmux.unusable(effects.tmux, chunk_prompt.DRIVER)):
|
||||||
return Stop(1, reason)
|
return Stop(1, reason)
|
||||||
config = load(paths.home)
|
config = load(paths.home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Stop(1, config.reason)
|
return Stop(1, config.reason)
|
||||||
store, record = backend(config, words[0])
|
store, record = backend(config, words[0])
|
||||||
@@ -142,17 +144,17 @@ def status_printed(epic: EpicRun) -> Stop:
|
|||||||
reading = dataclasses.replace(epic, effects=dataclasses.replace(epic.effects, git=dry_run.without_clones(epic.effects.git)))
|
reading = dataclasses.replace(epic, effects=dataclasses.replace(epic.effects, git=dry_run.without_clones(epic.effects.git)))
|
||||||
order = issues if isinstance(issues, Failure) else planning.start_order(planned_epic(reading), issues)
|
order = issues if isinstance(issues, Failure) else planning.start_order(planned_epic(reading), issues)
|
||||||
# Where the issues cannot be put in order of score, they start in the backlog's order, as a run says.
|
# Where the issues cannot be put in order of score, they start in the backlog's order, as a run says.
|
||||||
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux, () if isinstance(order, Failure) else tuple(order))
|
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.folder, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux, () if isinstance(order, Failure) else tuple(order))
|
||||||
return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue")
|
return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue")
|
||||||
|
|
||||||
|
|
||||||
def epic_written(key: str, writes: findings.Write | None, paths: Paths, backend: Backend, stdin: typing.TextIO) -> Stop:
|
def epic_written(key: str, writes: findings.Write | None, paths: Paths, env: typing.Mapping[str, str], backend: Backend, stdin: typing.TextIO) -> Stop:
|
||||||
"""Files a finding in the epic or records a decision in its description, as writes says; closes the epic where writes is None. It needs no tmux, so a chunk's worker may run it anywhere."""
|
"""Files a finding in the epic or records a decision in its description, as writes says; closes the epic where writes is None. It needs no tmux, so a chunk's worker may run it anywhere."""
|
||||||
config = load(paths.home)
|
config = load(paths.home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Stop(1, config.reason)
|
return Stop(1, config.reason)
|
||||||
store, record = backend(config, key)
|
store, record = backend(config, key)
|
||||||
done = findings.written(key, writes, store, config.label_repos, record, stdin, paths.home / scheduler.STATE / key) if writes else finish.closed(key, store, config.label_repos, stdin, config.pull_merged_status)
|
done = findings.written(key, writes, store, config.label_repos, record, stdin, scheduler.epic_folder(paths.state_folder, key)) if writes else finish.closed(key, store, config.label_repos, stdin, config.pull_merged_status)
|
||||||
return Stop(1, done.reason) if isinstance(done, Failure) else Stop(0, done)
|
return Stop(1, done.reason) if isinstance(done, Failure) else Stop(0, done)
|
||||||
|
|
||||||
|
|
||||||
@@ -243,7 +245,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
|||||||
if isinstance(issue, Stop):
|
if isinstance(issue, Stop):
|
||||||
return issue
|
return issue
|
||||||
if issue and isinstance(recorded(issue, epic.config.label_repos), HumanTask):
|
if issue and isinstance(recorded(issue, epic.config.label_repos), HumanTask):
|
||||||
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, epic.config.unblocking, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.effects)
|
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, epic.config.unblocking, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.env, epic.effects)
|
||||||
return handed_on(key, epic, Landed.WITH_A_HUMAN)
|
return handed_on(key, epic, Landed.WITH_A_HUMAN)
|
||||||
place = chunk_root(key, issue, epic)
|
place = chunk_root(key, issue, epic)
|
||||||
if isinstance(place, Stop):
|
if isinstance(place, Stop):
|
||||||
@@ -289,7 +291,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
|||||||
|
|
||||||
def epic_based(key: str, root: str, epic: EpicRun) -> str | None | Stop:
|
def epic_based(key: str, root: str, epic: EpicRun) -> str | None | Stop:
|
||||||
"""Readies the epic's working branch for the chunk called key, whose repo is checked out at root: the branch, or None where the repo's config sets no `epic-branch`. It makes the branch on origin, or brings it level with the default branch, and records it as the base of the chunk's branch. A default branch that doesn't merge into it cleanly stops the loop, since a person resolves the conflict (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`)."""
|
"""Readies the epic's working branch for the chunk called key, whose repo is checked out at root: the branch, or None where the repo's config sets no `epic-branch`. It makes the branch on origin, or brings it level with the default branch, and records it as the base of the chunk's branch. A default branch that doesn't merge into it cleanly stops the loop, since a person resolves the conflict (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`)."""
|
||||||
config = config_located(root, epic.paths.home)
|
config = config_located(root, epic.paths.home, epic.env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Stop(1, config.reason)
|
return Stop(1, config.reason)
|
||||||
if config.epic_branch is None:
|
if config.epic_branch is None:
|
||||||
@@ -328,10 +330,10 @@ def chunk_root(key: str, issue: EpicIssue | None, epic: EpicRun) -> tuple[str, s
|
|||||||
if isinstance(pick, Failure):
|
if isinstance(pick, Failure):
|
||||||
return Stop(1, pick.reason)
|
return Stop(1, pick.reason)
|
||||||
if isinstance(pick, ClaudeWork):
|
if isinstance(pick, ClaudeWork):
|
||||||
return str(epic.paths.home / scheduler.STATE / epic.key), None
|
return str(epic.folder), None
|
||||||
if not isinstance(pick, Repo):
|
if not isinstance(pick, Repo):
|
||||||
return Stop(1, f"{key} is no chunk: no label names its repo")
|
return Stop(1, f"{key} is no chunk: no label names its repo")
|
||||||
found = locate(pick.name, [], epic.config, epic.paths.home, epic.effects.git)
|
found = locate(pick.name, [], epic.config, epic.paths.home, epic.env, epic.effects.git)
|
||||||
return Stop(1, found.reason) if isinstance(found, Failure) else (str(real(found.checkout)), pick.name)
|
return Stop(1, found.reason) if isinstance(found, Failure) else (str(real(found.checkout)), pick.name)
|
||||||
|
|
||||||
|
|
||||||
@@ -507,7 +509,7 @@ def next_cycle(run: ChunkRun, loop: Loop, in_repo: bool, epic: EpicRun, news: st
|
|||||||
routing = project_routing(loop, chunk_prompt.DRIVER) if in_repo else routing_on(repoless_models(epic), SHIPPED)
|
routing = project_routing(loop, chunk_prompt.DRIVER) if in_repo else routing_on(repoless_models(epic), SHIPPED)
|
||||||
if isinstance(routing, Stop):
|
if isinstance(routing, Stop):
|
||||||
return routing
|
return routing
|
||||||
archive_folder = epic.paths.home / ARCHIVE / epic.key
|
archive_folder = epic.paths.state_folder / ARCHIVE / epic.key
|
||||||
route = announced_route(run.cycle_number, run.route, routing, archive_folder, lambda: issue, loop)
|
route = announced_route(run.cycle_number, run.route, routing, archive_folder, lambda: issue, loop)
|
||||||
prompts = chunk_prompt.unparked(news) if news else chunk_prompt.restating(task) if loop.window.name == epic.key else chunk_prompt.WORKER
|
prompts = chunk_prompt.unparked(news) if news else chunk_prompt.restating(task) if loop.window.name == epic.key else chunk_prompt.WORKER
|
||||||
return cycle_of(loop, routing, route, archive_folder, task=task, facts="", premises=premises, records=records, unfinished_evidence=run.unfinished_evidence, prompts=prompts, taken_in=lambda entries: TakenIn())
|
return cycle_of(loop, routing, route, archive_folder, task=task, facts="", premises=premises, records=records, unfinished_evidence=run.unfinished_evidence, prompts=prompts, taken_in=lambda entries: TakenIn())
|
||||||
@@ -524,7 +526,7 @@ def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) ->
|
|||||||
issue = issue_read(key, epic)
|
issue = issue_read(key, epic)
|
||||||
if isinstance(issue, Stop):
|
if isinstance(issue, Stop):
|
||||||
return issue
|
return issue
|
||||||
config = config_located(checkout, epic.paths.home) if checkout else None
|
config = config_located(checkout, epic.paths.home, epic.env) if checkout else None
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Stop(1, config.reason)
|
return Stop(1, config.reason)
|
||||||
return chunk_prompt.task(issue, epic.key, epic.config.label_repos, checkout, epic.launcher, language, config), RoutingIssue(issue) if "L" in issue.scores else None
|
return chunk_prompt.task(issue, epic.key, epic.config.label_repos, checkout, epic.launcher, language, config), RoutingIssue(issue) if "L" in issue.scores else None
|
||||||
@@ -550,7 +552,7 @@ def records_read(root: str | None, epic: EpicRun) -> str | Failure:
|
|||||||
if isinstance(body, Failure):
|
if isinstance(body, Failure):
|
||||||
return Failure(f"the epic {epic.key}'s description: {body.reason} - {CONSEQUENCE}.")
|
return Failure(f"the epic {epic.key}'s description: {body.reason} - {CONSEQUENCE}.")
|
||||||
sections.append((f"the epic {epic.key}'s description, ## {name}", body))
|
sections.append((f"the epic {epic.key}'s description, ## {name}", body))
|
||||||
return read_records(root, epic.paths.home, epic.paths.claude_dir, tuple(sections))
|
return read_records(root, epic.paths.home, epic.env, epic.paths.claude_dir, tuple(sections))
|
||||||
|
|
||||||
|
|
||||||
def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
|
def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
|
||||||
@@ -563,7 +565,7 @@ def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
|
|||||||
if not body.strip():
|
if not body.strip():
|
||||||
return Failure(f"the epic {epic.key}'s description has no text under a `## {name}` heading - no premises.")
|
return Failure(f"the epic {epic.key}'s description has no text under a `## {name}` heading - no premises.")
|
||||||
bodies.append(body)
|
bodies.append(body)
|
||||||
theirs = read_premises(root, epic.paths.home) if root else ""
|
theirs = read_premises(root, epic.paths.home, epic.env) if root else ""
|
||||||
if isinstance(theirs, Failure):
|
if isinstance(theirs, Failure):
|
||||||
return theirs
|
return theirs
|
||||||
return f"the epic {epic.key}'s description:\n## Goals\n{bodies[0]}\n\n## Audience\n{bodies[1]}" + (f"\n\nThe repo's goals, which rank after the epic's and after code health, are from {theirs}" if theirs else "")
|
return f"the epic {epic.key}'s description:\n## Goals\n{bodies[0]}\n\n## Audience\n{bodies[1]}" + (f"\n\nThe repo's goals, which rank after the epic's and after code health, are from {theirs}" if theirs else "")
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finis
|
|||||||
|
|
||||||
A chunk parks in three steps: its file is written, its window is shown as parked, and the epic's next chunks start in the slot it frees. It resumes in the reverse order: `scheduler.resume` gives it a running slot, then its file is removed. So a window that ends in between finds the chunk parked when it starts again.
|
A chunk parks in three steps: its file is written, its window is shown as parked, and the epic's next chunks start in the slot it frees. It resumes in the reverse order: `scheduler.resume` gives it a running slot, then its file is removed. So a window that ends in between finds the chunk parked when it starts again.
|
||||||
"""
|
"""
|
||||||
key, folder = loop.window.name, epic.paths.home / scheduler.STATE / epic.key
|
key = loop.window.name
|
||||||
recorded_as = parked.parked_chunks(folder)
|
recorded_as = parked.parked_chunks(epic.folder)
|
||||||
if isinstance(recorded_as, Failure):
|
if isinstance(recorded_as, Failure):
|
||||||
return Stop(1, recorded_as.reason)
|
return Stop(1, recorded_as.reason)
|
||||||
config = config_located(loop.root, epic.paths.home)
|
config = config_located(loop.root, epic.paths.home, epic.env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return Stop(1, config.reason)
|
return Stop(1, config.reason)
|
||||||
# A pull request into an epic's working branch merges without a person, whatever `merge` says. The base recorded says so, not the config: the gate fails where the forge merges the pull request elsewhere.
|
# A pull request into an epic's working branch merges without a person, whatever `merge` says. The base recorded says so, not the config: the gate fails where the forge merges the pull request elsewhere.
|
||||||
poll = Poll(key, repo, config.merge == "human" and based is None, folder, loop, epic)
|
poll = Poll(key, repo, config.merge == "human" and based is None, epic.folder, loop, epic)
|
||||||
if key in recorded_as:
|
if key in recorded_as:
|
||||||
return resumed_news(poll, recorded_as[key].on, shown=None)
|
return resumed_news(poll, recorded_as[key].on, shown=None)
|
||||||
entered = None if told is None else poll.first_gate(again=finished)
|
entered = None if told is None else poll.first_gate(again=finished)
|
||||||
|
|||||||
+11
-9
@@ -6,6 +6,7 @@ Planning runs only in the `do-epic <EPIC-KEY>` the human starts. A chunk that fi
|
|||||||
|
|
||||||
Planning holds no lock: one `do-epic <EPIC-KEY>` at a time is assumed. A second one started meanwhile finds the sub-tasks the first filed, since `split` reads them before it files, unless Jira's search lags."""
|
Planning holds no lock: one `do-epic <EPIC-KEY>` at a time is assumed. A second one started meanwhile finds the sub-tasks the first filed, since `split` reads them before it files, unless Jira's search lags."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ from claude_code.reply import Limited
|
|||||||
from plan_store.jira_epic import number
|
from plan_store.jira_epic import number
|
||||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||||
from model_routing.ladder import Rung
|
from model_routing.ladder import Rung
|
||||||
from do_epic.scheduler import STATE, unblocks
|
from do_epic.scheduler import unblocks
|
||||||
from plan_store.scoring import weighing_texts
|
from plan_store.scoring import weighing_texts
|
||||||
|
|
||||||
# The epic's formula, stated under its `## Scoring` as a todo.md states its own.
|
# The epic's formula, stated under its `## Scoring` as a todo.md states its own.
|
||||||
@@ -41,6 +42,9 @@ class Planned:
|
|||||||
store: EpicStore
|
store: EpicStore
|
||||||
record: EpicRecord
|
record: EpicRecord
|
||||||
home: pathlib.Path
|
home: pathlib.Path
|
||||||
|
env: Mapping[str, str]
|
||||||
|
# The epic's folder, where claude plans and scores its issues.
|
||||||
|
folder: pathlib.Path
|
||||||
effects: Effects
|
effects: Effects
|
||||||
|
|
||||||
|
|
||||||
@@ -92,17 +96,16 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad
|
|||||||
if failed := next((each for each in (rung, language, places) if isinstance(each, Failure)), None):
|
if failed := next((each for each in (rung, language, places) if isinstance(each, Failure)), None):
|
||||||
return failed
|
return failed
|
||||||
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(places, dict)
|
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(places, dict)
|
||||||
folder = epic.home / STATE / epic.key
|
epic.folder.mkdir(parents=True, exist_ok=True)
|
||||||
folder.mkdir(parents=True, exist_ok=True)
|
|
||||||
checkouts = tuple(str(place.checkout) for place in places.values())
|
checkouts = tuple(str(place.checkout) for place in places.values())
|
||||||
for issue in unplaced:
|
for issue in unplaced:
|
||||||
say(f"planning {issue.key}", epic.effects, stdout=True)
|
say(f"planning {issue.key}", epic.effects, stdout=True)
|
||||||
parts = split.split(epic.store, issue, epic.config.label_repos, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(folder), epic.config.sub_task_summary)
|
parts = split.split(epic.store, issue, epic.config.label_repos, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(epic.folder), epic.config.sub_task_summary)
|
||||||
if isinstance(parts, split.Split) and parts.repos:
|
if isinstance(parts, split.Split) and parts.repos:
|
||||||
added[issue.key] = split.SPLIT_LABEL
|
added[issue.key] = split.SPLIT_LABEL
|
||||||
say(f"{issue.key} is split into a sub-task for each of {', '.join(parts.repos)}", epic.effects, stdout=True)
|
say(f"{issue.key} is split into a sub-task for each of {', '.join(parts.repos)}", epic.effects, stdout=True)
|
||||||
continue
|
continue
|
||||||
pick: repo_pick.Pick | repo_pick.Unclear | Failure | Limited | None = parts if not isinstance(parts, split.Split) else repo_pick.picked(epic.store, issue, epic.config.label_repos, epic.config.repo_rule, rung, epic.effects.claude, str(folder))
|
pick: repo_pick.Pick | repo_pick.Unclear | Failure | Limited | None = parts if not isinstance(parts, split.Split) else repo_pick.picked(epic.store, issue, epic.config.label_repos, epic.config.repo_rule, rung, epic.effects.claude, str(epic.folder))
|
||||||
if isinstance(pick, repo_pick.Unclear):
|
if isinstance(pick, repo_pick.Unclear):
|
||||||
pick = answered(epic, issue, pick.question)
|
pick = answered(epic, issue, pick.question)
|
||||||
if isinstance(pick, Limited):
|
if isinstance(pick, Limited):
|
||||||
@@ -151,7 +154,7 @@ def located(epic: Planned, picks: list[repo_pick.Repo]) -> dict[str, repos.Locat
|
|||||||
"""Each picked repo's checkout and project config, by the repo's name."""
|
"""Each picked repo's checkout and project config, by the repo's name."""
|
||||||
places: dict[str, repos.Located] = {}
|
places: dict[str, repos.Located] = {}
|
||||||
for name in sorted({pick.name for pick in picks}):
|
for name in sorted({pick.name for pick in picks}):
|
||||||
place = repos.locate(name, [each.checkout for each in places.values()], epic.config, epic.home, epic.effects.git)
|
place = repos.locate(name, [each.checkout for each in places.values()], epic.config, epic.home, epic.env, epic.effects.git)
|
||||||
if isinstance(place, Failure):
|
if isinstance(place, Failure):
|
||||||
return place
|
return place
|
||||||
places[name] = place
|
places[name] = place
|
||||||
@@ -210,13 +213,12 @@ def scored(epic: Planned, issues: list[EpicIssue]) -> tuple[list[EpicIssue], Fai
|
|||||||
if failed := next((each for each in (rung, language, rule, weighed) if isinstance(each, Failure)), None):
|
if failed := next((each for each in (rung, language, rule, weighed) if isinstance(each, Failure)), None):
|
||||||
return issues, failed
|
return issues, failed
|
||||||
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(rule, str) and isinstance(weighed, Weighing)
|
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(rule, str) and isinstance(weighed, Weighing)
|
||||||
folder = epic.home / STATE / epic.key
|
epic.folder.mkdir(parents=True, exist_ok=True)
|
||||||
folder.mkdir(parents=True, exist_ok=True)
|
|
||||||
for issue in bare:
|
for issue in bare:
|
||||||
say(f"scoring {issue.key}", epic.effects, stdout=True)
|
say(f"scoring {issue.key}", epic.effects, stdout=True)
|
||||||
repo = repo_of(epic, issue)
|
repo = repo_of(epic, issue)
|
||||||
goals = ranking.goals_named(weighed.goals, repo, weighed.repos.get(repo) if repo else None)
|
goals = ranking.goals_named(weighed.goals, repo, weighed.repos.get(repo) if repo else None)
|
||||||
answer = goals if isinstance(goals, Failure) else issue_scores.asked(issue, rule, goals, language or epic.config.language, rung, epic.effects.claude, str(folder))
|
answer = goals if isinstance(goals, Failure) else issue_scores.asked(issue, rule, goals, language or epic.config.language, rung, epic.effects.claude, str(epic.folder))
|
||||||
if isinstance(answer, Limited):
|
if isinstance(answer, Limited):
|
||||||
return issues, answer
|
return issues, answer
|
||||||
held = answer if isinstance(answer, Failure) else scores_set(epic, issue, answer, weighed)
|
held = answer if isinstance(answer, Failure) else scores_set(epic, issue, answer, weighed)
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
A missing checkout is cloned from the host and owner of the epic's other repos (docs/decisions.md → `do-epic: drives one Jira epic …`). Where that is unclear, the answer is an Unsure."""
|
A missing checkout is cloned from the host and owner of the epic's other repos (docs/decisions.md → `do-epic: drives one Jira epic …`). Where that is unclear, the answer is an Unsure."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from project_config.settings import by_name, CONFIG, ProjectConfig, PROJECTS
|
from project_config.settings import by_name, CONFIG, ProjectConfig
|
||||||
|
from loop_state.paths import config_folder
|
||||||
from do_epic.config import DoEpicConfig
|
from do_epic.config import DoEpicConfig
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from git_cli.git_repo import Git
|
from git_cli.git_repo import Git
|
||||||
@@ -34,14 +36,14 @@ class Unsure(Failure):
|
|||||||
"""reason is a question for the human."""
|
"""reason is a question for the human."""
|
||||||
|
|
||||||
|
|
||||||
def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pathlib.Path, git: Git) -> Located | Failure:
|
def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pathlib.Path, env: Mapping[str, str], git: Git) -> Located | Failure:
|
||||||
"""The checkout and project config of the repo called name; others are the checkouts of the epic's other repos.
|
"""The checkout and project config of the repo called name; others are the checkouts of the epic's other repos.
|
||||||
|
|
||||||
A project config names the repo's checkout, and it is cloned where missing. Where no config names the repo, it is cloned into the clone folder, if it isn't there, and the human is asked to write the config, since the repo's plan, goals and records are theirs to place.
|
A project config names the repo's checkout, and it is cloned where missing. Where no config names the repo, it is cloned into the clone folder, if it isn't there, and the human is asked to write the config, since the repo's plan, goals and records are theirs to place.
|
||||||
A name that is no repo's name, or a config that can't be read, is a plain Failure. Any other fault is an Unsure."""
|
A name that is no repo's name, or a config that can't be read, is a plain Failure. Any other fault is an Unsure."""
|
||||||
if not re.fullmatch(REPO_NAME, name):
|
if not re.fullmatch(REPO_NAME, name):
|
||||||
return Failure(f"{name!r} is not a repo's name: one folder name that starts with a letter, digit or underscore")
|
return Failure(f"{name!r} is not a repo's name: one folder name that starts with a letter, digit or underscore")
|
||||||
found = by_name(name, home)
|
found = by_name(name, home, env)
|
||||||
if isinstance(found, Failure):
|
if isinstance(found, Failure):
|
||||||
return found
|
return found
|
||||||
checkout = found.top if found else config.clone_folder / name
|
checkout = found.top if found else config.clone_folder / name
|
||||||
@@ -49,7 +51,7 @@ def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pa
|
|||||||
if isinstance(cloned, Failure):
|
if isinstance(cloned, Failure):
|
||||||
return cloned
|
return cloned
|
||||||
if found is None:
|
if found is None:
|
||||||
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {home / PROJECTS}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run do-epic again.")
|
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {config_folder(env, home)}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run do-epic again.")
|
||||||
return Located(checkout, found)
|
return Located(checkout, found)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,20 @@ from text_files.markdown_text import listed
|
|||||||
from project_config.settings import PARALLEL_CHUNKS
|
from project_config.settings import PARALLEL_CHUNKS
|
||||||
from do_epic.parked import parked_chunks
|
from do_epic.parked import parked_chunks
|
||||||
from chunk_pr.approval import PARKS
|
from chunk_pr.approval import PARKS
|
||||||
from loop_state.paths import STATE_FOLDER
|
from loop_state.paths import Paths
|
||||||
from agent_cycle import tmux
|
from agent_cycle import tmux
|
||||||
|
|
||||||
# Under the home folder, a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
|
# The folder in the state folder where a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
|
||||||
STATE = f"{STATE_FOLDER}/do-epic"
|
STATE = "do-epic"
|
||||||
# Why a human's task with a live window waits, as the epic's status says.
|
# Why a human's task with a live window waits, as the epic's status says.
|
||||||
HUMAN_WAIT = "it is a human's task; do-epic polls Jira until you close it"
|
HUMAN_WAIT = "it is a human's task; do-epic polls Jira until you close it"
|
||||||
|
|
||||||
|
|
||||||
|
def epic_folder(state: pathlib.Path, key: str) -> pathlib.Path:
|
||||||
|
"""The folder of the epic called key, in the state folder state."""
|
||||||
|
return state / STATE / key
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class Chunk:
|
class Chunk:
|
||||||
"""An issue to work as one chunk, in the window named for its key."""
|
"""An issue to work as one chunk, in the window named for its key."""
|
||||||
@@ -69,7 +74,7 @@ class Epic:
|
|||||||
cap: int
|
cap: int
|
||||||
# The checkout of the repo with this name and its `parallel-chunks`, or why the repo cannot be used.
|
# The checkout of the repo with this name and its `parallel-chunks`, or why the repo cannot be used.
|
||||||
locate: typing.Callable[[str], tuple[pathlib.Path, int] | Failure]
|
locate: typing.Callable[[str], tuple[pathlib.Path, int] | Failure]
|
||||||
home: pathlib.Path
|
paths: Paths
|
||||||
# The do-epic script each window runs.
|
# The do-epic script each window runs.
|
||||||
launcher: pathlib.Path
|
launcher: pathlib.Path
|
||||||
env: typing.Mapping[str, str]
|
env: typing.Mapping[str, str]
|
||||||
@@ -82,7 +87,7 @@ class Epic:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def folder(self) -> pathlib.Path:
|
def folder(self) -> pathlib.Path:
|
||||||
return self.home / STATE / self.key
|
return epic_folder(self.paths.state_folder, self.key)
|
||||||
|
|
||||||
|
|
||||||
def unblocks(status: str, unblocking: tuple[str, ...]) -> bool:
|
def unblocks(status: str, unblocking: tuple[str, ...]) -> bool:
|
||||||
@@ -228,10 +233,10 @@ def start_chunk(epic: Epic, chunk: Chunk, own: str | None, windows: list[tmux.Li
|
|||||||
if isinstance(located, Failure):
|
if isinstance(located, Failure):
|
||||||
return Waits(chunk.issue, located.reason)
|
return Waits(chunk.issue, located.reason)
|
||||||
checkout, limit = located
|
checkout, limit = located
|
||||||
with starting(project_lock(str(checkout), epic.home)) as unlocked:
|
with starting(project_lock(str(checkout), epic.paths)) as unlocked:
|
||||||
if unlocked:
|
if unlocked:
|
||||||
return unlocked
|
return unlocked
|
||||||
if reason := refusal(chunk.repo, room_in(str(checkout), limit, (session, own), epic.home, run)):
|
if reason := refusal(chunk.repo, room_in(str(checkout), limit, (session, own), epic.paths.home, run)):
|
||||||
return Waits(chunk.issue, reason)
|
return Waits(chunk.issue, reason)
|
||||||
return tmux.start_chunk(tmux.Window(session, chunk.issue, ""), str(checkout), handed, command, windows, False, run)
|
return tmux.start_chunk(tmux.Window(session, chunk.issue, ""), str(checkout), handed, command, windows, False, run)
|
||||||
|
|
||||||
@@ -254,10 +259,10 @@ def resume(epic: Epic, repo: str, window: tmux.Window, run: tmux.Tmux) -> str |
|
|||||||
if isinstance(located, Failure):
|
if isinstance(located, Failure):
|
||||||
return located.reason
|
return located.reason
|
||||||
checkout, limit = located
|
checkout, limit = located
|
||||||
with starting(project_lock(str(checkout), epic.home)) as unlocked:
|
with starting(project_lock(str(checkout), epic.paths)) as unlocked:
|
||||||
if unlocked:
|
if unlocked:
|
||||||
return unlocked.reason
|
return unlocked.reason
|
||||||
if reason := refusal(repo, room_in(str(checkout), limit, (window.session, window.name), epic.home, run)):
|
if reason := refusal(repo, room_in(str(checkout), limit, (window.session, window.name), epic.paths.home, run)):
|
||||||
return reason
|
return reason
|
||||||
tmux.unpark(window, str(checkout), run)
|
tmux.unpark(window, str(checkout), run)
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from do_epic.scheduler import chunks, HUMAN_WAIT, STATE
|
from do_epic.scheduler import chunks, HUMAN_WAIT
|
||||||
from do_epic.backend.protocol import EpicIssue
|
from do_epic.backend.protocol import EpicIssue
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from do_epic.parked import file_of, Parked, parked_chunks, SLOT
|
from do_epic.parked import file_of, Parked, parked_chunks, SLOT
|
||||||
@@ -20,10 +20,9 @@ def since(folder: pathlib.Path, chunk: Parked) -> str:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux, order: tuple[str, ...]) -> list[str] | Failure:
|
def lines(key: str, folder: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux, order: tuple[str, ...]) -> list[str] | Failure:
|
||||||
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. order holds the keys of the issues that start by score, as planning.start_order puts them; a chunk it leaves out says that it starts after them. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
|
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. order holds the keys of the issues that start by score, as planning.start_order puts them; a chunk it leaves out says that it starts after them. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
|
||||||
found, waits = chunks(issues, team, unblocking)
|
found, waits = chunks(issues, team, unblocking)
|
||||||
folder = home / STATE / key
|
|
||||||
parked = parked_chunks(folder)
|
parked = parked_chunks(folder)
|
||||||
if isinstance(parked, Failure):
|
if isinstance(parked, Failure):
|
||||||
return parked
|
return parked
|
||||||
|
|||||||
+27
-27
@@ -21,7 +21,7 @@ class ConfigTest(unittest.TestCase):
|
|||||||
made = tempfile.TemporaryDirectory()
|
made = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(made.cleanup)
|
self.addCleanup(made.cleanup)
|
||||||
self.home = pathlib.Path(made.name).resolve()
|
self.home = pathlib.Path(made.name).resolve()
|
||||||
self.folder = self.home / ".claude-projects" / "do-epic"
|
self.folder = self.home / ".config/build-release" / "do-epic"
|
||||||
self.folder.mkdir(parents=True)
|
self.folder.mkdir(parents=True)
|
||||||
|
|
||||||
def write(self, settings: str | None = SETTINGS, rule: str | None = "A label that equals a repo's name names that repo.\n") -> None:
|
def write(self, settings: str | None = SETTINGS, rule: str | None = "A label that equals a repo's name names that repo.\n") -> None:
|
||||||
@@ -31,17 +31,17 @@ class ConfigTest(unittest.TestCase):
|
|||||||
(self.folder / "repo-rule.md").write_text(rule, encoding="utf-8")
|
(self.folder / "repo-rule.md").write_text(rule, encoding="utf-8")
|
||||||
|
|
||||||
def failure(self) -> str:
|
def failure(self) -> str:
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
return found.reason
|
return found.reason
|
||||||
|
|
||||||
def test_reads_the_settings_and_the_rule_and_defaults_the_clone_folder_and_language(self) -> None:
|
def test_reads_the_settings_and_the_rule_and_defaults_the_clone_folder_and_language(self) -> None:
|
||||||
self.write()
|
self.write()
|
||||||
self.assertEqual(load(self.home), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
|
self.assertEqual(load(self.home, {}), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
|
||||||
|
|
||||||
def test_reads_the_teams_labels_for_its_repos(self) -> None:
|
def test_reads_the_teams_labels_for_its_repos(self) -> None:
|
||||||
self.write(SETTINGS + '[label-repos]\ntwu-4 = "tenant-web-ui-4"\n"core-4" = "core-4"\n')
|
self.write(SETTINGS + '[label-repos]\ntwu-4 = "tenant-web-ui-4"\n"core-4" = "core-4"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
|
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_a_template_for_a_sub_tasks_summary(self) -> None:
|
def test_reads_a_template_for_a_sub_tasks_summary(self) -> None:
|
||||||
self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n')
|
self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
|
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
|
||||||
|
|
||||||
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
|
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
|
||||||
self.write()
|
self.write()
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertIsNone(found.sub_task_summary)
|
self.assertIsNone(found.sub_task_summary)
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class ConfigTest(unittest.TestCase):
|
|||||||
for template in ("{Summary}", "{Summary}{{", "{Summary} for {label} in Jira"):
|
for template in ("{Summary}", "{Summary}{{", "{Summary} for {label} in Jira"):
|
||||||
with self.subTest(template=template):
|
with self.subTest(template=template):
|
||||||
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
|
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.sub_task_summary, template)
|
self.assertEqual(found.sub_task_summary, template)
|
||||||
|
|
||||||
@@ -102,13 +102,13 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_a_clone_folder_and_language_the_config_sets(self) -> None:
|
def test_reads_a_clone_folder_and_language_the_config_sets(self) -> None:
|
||||||
self.write(SETTINGS + 'clone-folder = "/srv/repos"\nlanguage = "Brazilian Portuguese"\n')
|
self.write(SETTINGS + 'clone-folder = "/srv/repos"\nlanguage = "Brazilian Portuguese"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.clone_folder, found.language), (pathlib.Path("/srv/repos"), "Brazilian Portuguese"))
|
self.assertEqual((found.clone_folder, found.language), (pathlib.Path("/srv/repos"), "Brazilian Portuguese"))
|
||||||
|
|
||||||
def test_reads_how_a_finished_epic_closes_and_wants_both_names_or_neither(self) -> None:
|
def test_reads_how_a_finished_epic_closes_and_wants_both_names_or_neither(self) -> None:
|
||||||
self.write(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
self.write(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.finish, Finish("Mark as done", "Done"))
|
self.assertEqual(found.finish, Finish("Mark as done", "Done"))
|
||||||
self.write(SETTINGS + 'jira-finish-status = " "\n')
|
self.write(SETTINGS + 'jira-finish-status = " "\n')
|
||||||
@@ -116,11 +116,11 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_how_a_starting_issue_moves_and_which_boards_sprint_it_joins(self) -> None:
|
def test_reads_how_a_starting_issue_moves_and_which_boards_sprint_it_joins(self) -> None:
|
||||||
self.write(SETTINGS)
|
self.write(SETTINGS)
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.start, Start(None, None))
|
self.assertEqual(found.start, Start(None, None))
|
||||||
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
|
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.start, Start("In Progress", 1))
|
self.assertEqual(found.start, Start("In Progress", 1))
|
||||||
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
|
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
|
||||||
@@ -130,11 +130,11 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_the_transition_that_moves_a_parent_whose_sub_tasks_have_all_landed(self) -> None:
|
def test_reads_the_transition_that_moves_a_parent_whose_sub_tasks_have_all_landed(self) -> None:
|
||||||
self.write(SETTINGS)
|
self.write(SETTINGS)
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertIsNone(found.sub_tasks_landed_transition)
|
self.assertIsNone(found.sub_tasks_landed_transition)
|
||||||
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = "Release Ready"\n')
|
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = "Release Ready"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.sub_tasks_landed_transition, "Release Ready")
|
self.assertEqual(found.sub_tasks_landed_transition, "Release Ready")
|
||||||
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = 5\n')
|
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = 5\n')
|
||||||
@@ -142,23 +142,23 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_the_unblocking_statuses_and_that_the_teams_automation_moves_issues(self) -> None:
|
def test_reads_the_unblocking_statuses_and_that_the_teams_automation_moves_issues(self) -> None:
|
||||||
self.write(SETTINGS)
|
self.write(SETTINGS)
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.unblocking, found.automation_moves), ((), False))
|
self.assertEqual((found.unblocking, found.automation_moves), ((), False))
|
||||||
self.write(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Done"]\njira-automation-moves-issues = true\n')
|
self.write(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Done"]\njira-automation-moves-issues = true\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.unblocking, found.automation_moves), (("Release Ready", "Done"), True))
|
self.assertEqual((found.unblocking, found.automation_moves), (("Release Ready", "Done"), True))
|
||||||
|
|
||||||
def test_the_issue_types_of_a_finding_and_a_release_review_are_task_where_left_out(self) -> None:
|
def test_the_issue_types_of_a_finding_and_a_release_review_are_task_where_left_out(self) -> None:
|
||||||
self.write()
|
self.write()
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.finding_type, found.review_type), ("Task", "Task"))
|
self.assertEqual((found.finding_type, found.review_type), ("Task", "Task"))
|
||||||
|
|
||||||
def test_reads_the_issue_types_of_a_finding_and_a_release_review(self) -> None:
|
def test_reads_the_issue_types_of_a_finding_and_a_release_review(self) -> None:
|
||||||
self.write(SETTINGS + 'jira-finding-type = "Feature"\njira-review-type = "Chore"\n')
|
self.write(SETTINGS + 'jira-finding-type = "Feature"\njira-review-type = "Chore"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.finding_type, found.review_type), ("Feature", "Chore"))
|
self.assertEqual((found.finding_type, found.review_type), ("Feature", "Chore"))
|
||||||
|
|
||||||
@@ -171,11 +171,11 @@ class ConfigTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reads_the_statuses_of_an_issue_whose_pull_request_into_an_epic_branch_opened_and_merged(self) -> None:
|
def test_reads_the_statuses_of_an_issue_whose_pull_request_into_an_epic_branch_opened_and_merged(self) -> None:
|
||||||
self.write(SETTINGS)
|
self.write(SETTINGS)
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.pull_open_status, found.pull_merged_status), (None, None))
|
self.assertEqual((found.pull_open_status, found.pull_merged_status), (None, None))
|
||||||
self.write(SETTINGS + 'jira-unblocking-statuses = ["release ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
self.write(SETTINGS + 'jira-unblocking-statuses = ["release ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual((found.pull_open_status, found.pull_merged_status), ("Code Review", "Release Ready"))
|
self.assertEqual((found.pull_open_status, found.pull_merged_status), ("Code Review", "Release Ready"))
|
||||||
|
|
||||||
@@ -243,8 +243,8 @@ class ConfigTest(unittest.TestCase):
|
|||||||
self.assertIn(f"`{name}` is", self.failure())
|
self.assertIn(f"`{name}` is", self.failure())
|
||||||
|
|
||||||
def test_keeps_the_credentials_outside_every_config_folder_and_the_clone_folder(self) -> None:
|
def test_keeps_the_credentials_outside_every_config_folder_and_the_clone_folder(self) -> None:
|
||||||
(self.home / ".claude-projects" / "acme").mkdir()
|
(self.home / ".config/build-release" / "acme").mkdir()
|
||||||
for env_file in ("~/.claude-projects/do-epic/jira.env", "~/.claude-projects/acme/jira.env", "~/code/acme/jira.env"):
|
for env_file in ("~/.config/build-release/do-epic/jira.env", "~/.config/build-release/acme/jira.env", "~/code/acme/jira.env"):
|
||||||
with self.subTest(env_file):
|
with self.subTest(env_file):
|
||||||
self.write(SETTINGS.replace("~/jira.env", env_file))
|
self.write(SETTINGS.replace("~/jira.env", env_file))
|
||||||
self.assertIn("`env-file` is", self.failure())
|
self.assertIn("`env-file` is", self.failure())
|
||||||
@@ -254,14 +254,14 @@ class ConfigTest(unittest.TestCase):
|
|||||||
self.assertIn("`env-file` is", self.failure())
|
self.assertIn("`env-file` is", self.failure())
|
||||||
|
|
||||||
def test_accepts_credentials_beside_the_config_folders(self) -> None:
|
def test_accepts_credentials_beside_the_config_folders(self) -> None:
|
||||||
self.write(SETTINGS.replace("~/jira.env", "~/.claude-projects/do-epic.env"))
|
self.write(SETTINGS.replace("~/jira.env", "~/.config/build-release/do-epic.env"))
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.env_file, self.home / ".claude-projects" / "do-epic.env")
|
self.assertEqual(found.env_file, self.home / ".config/build-release" / "do-epic.env")
|
||||||
|
|
||||||
def test_refuses_while_the_routing_ladder_cannot_be_read(self) -> None:
|
def test_refuses_while_the_routing_ladder_cannot_be_read(self) -> None:
|
||||||
self.write()
|
self.write()
|
||||||
found = load(self.home, self.home / "no-ladder.json")
|
found = load(self.home, {}, self.home / "no-ladder.json")
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("no-ladder.json", found.reason)
|
self.assertIn("no-ladder.json", found.reason)
|
||||||
|
|
||||||
@@ -276,12 +276,12 @@ class ConfigTest(unittest.TestCase):
|
|||||||
ladder = self.home / "ladder.json"
|
ladder = self.home / "ladder.json"
|
||||||
ladder.write_text('[{"model": "claude-sonnet-5-5", "effort": "low"}, {"model": "claude-opus-5-5", "effort": "low"}]', encoding="utf-8")
|
ladder.write_text('[{"model": "claude-sonnet-5-5", "effort": "low"}, {"model": "claude-opus-5-5", "effort": "low"}]', encoding="utf-8")
|
||||||
self.write(SETTINGS.replace("claude-opus-5-5", "claude-haiku-5-5"))
|
self.write(SETTINGS.replace("claude-opus-5-5", "claude-haiku-5-5"))
|
||||||
found = load(self.home, ladder)
|
found = load(self.home, {}, ladder)
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("not a model on the routing ladder: claude-opus-5-5, claude-sonnet-5-5.", found.reason)
|
self.assertIn("not a model on the routing ladder: claude-opus-5-5, claude-sonnet-5-5.", found.reason)
|
||||||
|
|
||||||
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
|
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
|
||||||
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
|
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
|
||||||
found = load(self.home)
|
found = load(self.home, {})
|
||||||
assert isinstance(found, DoEpicConfig), found
|
assert isinstance(found, DoEpicConfig), found
|
||||||
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")
|
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class FindingsTest(DoEpicTest):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.store = MemoryEpic("ABC-12", list(self.issues))
|
self.store = MemoryEpic("ABC-12", list(self.issues))
|
||||||
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/do-epic/ABC-12/decisions.lock")
|
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/build-release/do-epic/ABC-12/decisions.lock")
|
||||||
self.keys: list[str] = []
|
self.keys: list[str] = []
|
||||||
|
|
||||||
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
|
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
|
||||||
@@ -63,7 +63,7 @@ class FindingsTest(DoEpicTest):
|
|||||||
def run_with(self, argv: list[str], stdin: str = "") -> tuple[int, str, str, FakeEffects]:
|
def run_with(self, argv: list[str], stdin: str = "") -> tuple[int, str, str, FakeEffects]:
|
||||||
out, err, fake = io.StringIO(), io.StringIO(), FakeEffects()
|
out, err, fake = io.StringIO(), io.StringIO(), FakeEffects()
|
||||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||||
code = main.main(argv, {}, paths_from(self.home), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
|
code = main.main(argv, {}, paths_from(self.home, {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
|
||||||
# Without the time each line of do-epic opens with.
|
# Without the time each line of do-epic opens with.
|
||||||
return code, out.getvalue().replace("<1790000000> ", ""), err.getvalue().replace("<1790000000> ", ""), fake
|
return code, out.getvalue().replace("<1790000000> ", ""), err.getvalue().replace("<1790000000> ", ""), fake
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class FilingAFinding(FindingsTest):
|
|||||||
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", (label,), ""))
|
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", (label,), ""))
|
||||||
|
|
||||||
def test_a_label_of_the_teams_says_where_the_issue_is_worked(self) -> None:
|
def test_a_label_of_the_teams_says_where_the_issue_is_worked(self) -> None:
|
||||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||||
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\n')
|
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\n')
|
||||||
code, out, _, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4"])
|
code, out, _, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4"])
|
||||||
filed = self.store.issues[-1]
|
filed = self.store.issues[-1]
|
||||||
@@ -139,7 +139,7 @@ class FilingAFinding(FindingsTest):
|
|||||||
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: Jira answered 401\n"))
|
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: Jira answered 401\n"))
|
||||||
|
|
||||||
def test_stops_where_the_machines_settings_cannot_be_read(self) -> None:
|
def test_stops_where_the_machines_settings_cannot_be_read(self) -> None:
|
||||||
(self.home / ".claude-projects/do-epic/config.toml").unlink()
|
(self.home / ".config/build-release/do-epic/config.toml").unlink()
|
||||||
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
|
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
|
||||||
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
|
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
|
||||||
self.assertIn("config.toml", err)
|
self.assertIn("config.toml", err)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class ClosingTheEpic(DoEpicTest):
|
|||||||
def close(self, summary: str = "## Shipped\n\napi: the import.\n") -> tuple[int, str, str]:
|
def close(self, summary: str = "## Shipped\n\napi: the import.\n") -> tuple[int, str, str]:
|
||||||
out, err = io.StringIO(), io.StringIO()
|
out, err = io.StringIO(), io.StringIO()
|
||||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||||
code = main.main(["ABC-12", "--close-epic"], {}, paths_from(self.home), LAUNCHER, FakeEffects().effects(), self.backend, io.StringIO(summary))
|
code = main.main(["ABC-12", "--close-epic"], {}, paths_from(self.home, {}), LAUNCHER, FakeEffects().effects(), self.backend, io.StringIO(summary))
|
||||||
return code, out.getvalue(), err.getvalue()
|
return code, out.getvalue(), err.getvalue()
|
||||||
|
|
||||||
def test_posts_the_summary_on_the_epic_and_closes_it(self) -> None:
|
def test_posts_the_summary_on_the_epic_and_closes_it(self) -> None:
|
||||||
@@ -127,15 +127,15 @@ class ClosingTheEpic(DoEpicTest):
|
|||||||
self.assertEqual(finish.closed("ABC-12", Unreadable("ABC-12", list(REVIEWED)), {}, io.StringIO("Shipped.")), Failure("cannot close the epic ABC-12: Jira answered 503"))
|
self.assertEqual(finish.closed("ABC-12", Unreadable("ABC-12", list(REVIEWED)), {}, io.StringIO("Shipped.")), Failure("cannot close the epic ABC-12: Jira answered 503"))
|
||||||
|
|
||||||
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
|
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
|
||||||
with open(self.home / ".claude-projects/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
with open(self.home / ".config/build-release/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
||||||
settings.write('jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
settings.write('jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
assert isinstance(config, DoEpicConfig), config
|
assert isinstance(config, DoEpicConfig), config
|
||||||
store, _ = main.jira_backend(config, "ABC-12")
|
store, _ = main.jira_backend(config, "ABC-12")
|
||||||
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
|
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
|
||||||
|
|
||||||
def test_closes_an_epic_whose_open_issues_all_have_the_merged_status(self) -> None:
|
def test_closes_an_epic_whose_open_issues_all_have_the_merged_status(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||||
self.issues.append(issue("ABC-31", "repo:api", status="Release Ready"))
|
self.issues.append(issue("ABC-31", "repo:api", status="Release Ready"))
|
||||||
code, out, err = self.close()
|
code, out, err = self.close()
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
@@ -201,7 +201,7 @@ class TheFinishingChunk(DoEpicTest):
|
|||||||
self.assertIn(["/b/do-epic", "--chunk", "ABC-12", "ABC-12"], [args[-4:] for args in fake.tmux_calls])
|
self.assertIn(["/b/do-epic", "--chunk", "ABC-12", "ABC-12"], [args[-4:] for args in fake.tmux_calls])
|
||||||
|
|
||||||
def test_starts_once_each_open_issue_has_the_merged_status(self) -> None:
|
def test_starts_once_each_open_issue_has_the_merged_status(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||||
self.issues = [issue("ABC-20", "do-epic-claude", status="Release Ready"), issue("ABC-21", "do-epic-claude", done=True)]
|
self.issues = [issue("ABC-20", "do-epic-claude", status="Release Ready"), issue("ABC-21", "do-epic-claude", done=True)]
|
||||||
fake = FakeEffects(on_terminal=False)
|
fake = FakeEffects(on_terminal=False)
|
||||||
code, out, err = self.run_main(["ABC-12"], fake)
|
code, out, err = self.run_main(["ABC-12"], fake)
|
||||||
@@ -227,7 +227,7 @@ class TheFinishingChunk(DoEpicTest):
|
|||||||
|
|
||||||
def test_its_worker_is_handed_the_finishing_task_and_runs_until_the_judge_rules_it_finished(self) -> None:
|
def test_its_worker_is_handed_the_finishing_task_and_runs_until_the_judge_rules_it_finished(self) -> None:
|
||||||
self.issues = list(REVIEWED)
|
self.issues = list(REVIEWED)
|
||||||
worker = Worker(paths_from(self.home).claude_code_transcripts.parent)
|
worker = Worker(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||||
fake = FakeEffects(streams=[worker], claude=[judged("finished")], git=UNREAD, windows="ABC-12\t0\t@9\n")
|
fake = FakeEffects(streams=[worker], claude=[judged("finished")], git=UNREAD, windows="ABC-12\t0\t@9\n")
|
||||||
code, out, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
|
code, out, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
@@ -237,11 +237,11 @@ class TheFinishingChunk(DoEpicTest):
|
|||||||
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
|
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
|
||||||
self.assertIn("From the epic ABC-12's description:\n## Goals\nShip the import.", streamed)
|
self.assertIn("From the epic ABC-12's description:\n## Goals\nShip the import.", streamed)
|
||||||
self.assertIn("write a summary in English, the epic's language", streamed)
|
self.assertIn("write a summary in English, the epic's language", streamed)
|
||||||
self.assertTrue((self.home / ".local/state/do-epic/ABC-12").is_dir())
|
self.assertTrue((self.home / ".local/state/build-release/do-epic/ABC-12").is_dir())
|
||||||
|
|
||||||
def test_a_worker_that_resumes_is_told_the_task_as_the_epic_now_stands(self) -> None:
|
def test_a_worker_that_resumes_is_told_the_task_as_the_epic_now_stands(self) -> None:
|
||||||
self.issues = list(REVIEWED)
|
self.issues = list(REVIEWED)
|
||||||
transcripts = paths_from(self.home).claude_code_transcripts
|
transcripts = paths_from(self.home, {}).claude_code_transcripts
|
||||||
worker = Worker(transcripts.parent)
|
worker = Worker(transcripts.parent)
|
||||||
session = session_named("A ABC-12 do-epic ABC-12", transcripts)
|
session = session_named("A ABC-12 do-epic ABC-12", transcripts)
|
||||||
(transcripts / "-fake").mkdir(parents=True)
|
(transcripts / "-fake").mkdir(parents=True)
|
||||||
@@ -256,7 +256,7 @@ class TheFinishingChunk(DoEpicTest):
|
|||||||
|
|
||||||
def test_stops_where_the_epics_issues_cannot_be_read_or_its_lock_cannot_be_taken(self) -> None:
|
def test_stops_where_the_epics_issues_cannot_be_read_or_its_lock_cannot_be_taken(self) -> None:
|
||||||
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
|
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
|
||||||
(self.home / ".local/state/do-epic/ABC-12" / LOCK).mkdir(parents=True)
|
(self.home / ".local/state/build-release/do-epic/ABC-12" / LOCK).mkdir(parents=True)
|
||||||
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
|
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
|
||||||
self.assertEqual(code, 1)
|
self.assertEqual(code, 1)
|
||||||
self.assertIn("cannot lock ", err)
|
self.assertIn("cannot lock ", err)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
|
|||||||
folder = configured(self, checkout, home=self.home)
|
folder = configured(self, checkout, home=self.home)
|
||||||
if notifier:
|
if notifier:
|
||||||
with (folder / "config.toml").open("a") as config:
|
with (folder / "config.toml").open("a") as config:
|
||||||
config.write('env-file = "~/.claude-projects/notifier.env"\nnotifier = "slack"\n')
|
config.write('env-file = "~/.config/build-release/notifier.env"\nnotifier = "slack"\n')
|
||||||
return checkout
|
return checkout
|
||||||
|
|
||||||
def awaited(self, fake: FakeEffects, closes_after: int) -> tuple[int, str, str]:
|
def awaited(self, fake: FakeEffects, closes_after: int) -> tuple[int, str, str]:
|
||||||
@@ -52,7 +52,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
|
|||||||
|
|
||||||
def moved_to_an_unblocking_status(self, switch: str, frees: tuple[str, dict[str, object]] = ("ABC-19", {"status": "Release Ready"}), starts: str = "ABC-21") -> bool:
|
def moved_to_an_unblocking_status(self, switch: str, frees: tuple[str, dict[str, object]] = ("ABC-19", {"status": "Release Ready"}), starts: str = "ABC-21") -> bool:
|
||||||
"""Whether Jira counts the task done after its window's run, where the config ends with switch. frees is the change in Jira that ends the wait: by default the human moves the task to an unblocking status. starts is what the window then starts."""
|
"""Whether Jira counts the task done after its window's run, where the config ends with switch. frees is the change in Jira that ends the wait: by default the human moves the task to an unblocking status. starts is what the window then starts."""
|
||||||
with (self.home / ".claude-projects" / "do-epic" / "config.toml").open("a") as config:
|
with (self.home / ".config/build-release" / "do-epic" / "config.toml").open("a") as config:
|
||||||
config.write('jira-unblocking-statuses = ["Release Ready"]\n' + switch)
|
config.write('jira-unblocking-statuses = ["Release Ready"]\n' + switch)
|
||||||
fake = FakeEffects(git=UNREAD, windows=WINDOW)
|
fake = FakeEffects(git=UNREAD, windows=WINDOW)
|
||||||
slept: list[int] = []
|
slept: list[int] = []
|
||||||
|
|||||||
+34
-34
@@ -56,7 +56,7 @@ class DoEpicTest(unittest.TestCase):
|
|||||||
made = tempfile.TemporaryDirectory()
|
made = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(made.cleanup)
|
self.addCleanup(made.cleanup)
|
||||||
self.home = pathlib.Path(made.name).resolve()
|
self.home = pathlib.Path(made.name).resolve()
|
||||||
folder = self.home / ".claude-projects" / "do-epic"
|
folder = self.home / ".config/build-release" / "do-epic"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
(folder / "config.toml").write_text(SETTINGS, encoding="utf-8")
|
(folder / "config.toml").write_text(SETTINGS, encoding="utf-8")
|
||||||
(folder / "repo-rule.md").write_text("A label that equals a repo's name names that repo.\n", encoding="utf-8")
|
(folder / "repo-rule.md").write_text("A label that equals a repo's name names that repo.\n", encoding="utf-8")
|
||||||
@@ -77,7 +77,7 @@ class DoEpicTest(unittest.TestCase):
|
|||||||
return MemoryEpic(key, list(self.issues)), EpicRecord(Description(self.description)) # type: ignore[arg-type]
|
return MemoryEpic(key, list(self.issues)), EpicRecord(Description(self.description)) # type: ignore[arg-type]
|
||||||
|
|
||||||
def worker(self) -> Worker:
|
def worker(self) -> Worker:
|
||||||
return Worker(paths_from(self.home).claude_code_transcripts.parent)
|
return Worker(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||||
|
|
||||||
def repo_chunk(self) -> pathlib.Path:
|
def repo_chunk(self) -> pathlib.Path:
|
||||||
"""Makes ABC-20 the one issue, a chunk in the repo api whose checkout holds its premises; the folder of the repo's config."""
|
"""Makes ABC-20 the one issue, a chunk in the repo api whose checkout holds its premises; the folder of the repo's config."""
|
||||||
@@ -88,15 +88,15 @@ class DoEpicTest(unittest.TestCase):
|
|||||||
return folder
|
return folder
|
||||||
|
|
||||||
def epic_run(self, fake: FakeEffects, env: dict[str, str] | None = None) -> epic_run.EpicRun:
|
def epic_run(self, fake: FakeEffects, env: dict[str, str] | None = None) -> epic_run.EpicRun:
|
||||||
config = main.load(self.home)
|
config = main.load(self.home, {})
|
||||||
assert not isinstance(config, Failure)
|
assert not isinstance(config, Failure)
|
||||||
store, record = self.backend(config, "ABC-12")
|
store, record = self.backend(config, "ABC-12")
|
||||||
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home), env or {}, pathlib.Path("/b/do-epic"), fake.effects())
|
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home, env or {}), env or {}, pathlib.Path("/b/do-epic"), fake.effects())
|
||||||
|
|
||||||
def run_main(self, argv: list[str], fake: FakeEffects, env: dict[str, str] | None = None) -> tuple[int, str, str]:
|
def run_main(self, argv: list[str], fake: FakeEffects, env: dict[str, str] | None = None) -> tuple[int, str, str]:
|
||||||
out, err = io.StringIO(), io.StringIO()
|
out, err = io.StringIO(), io.StringIO()
|
||||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||||
code = main.main(argv, env or {}, paths_from(self.home), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
|
code = main.main(argv, env or {}, paths_from(self.home, env or {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
|
||||||
return code, out.getvalue(), err.getvalue()
|
return code, out.getvalue(), err.getvalue()
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ class TheCommand(DoEpicTest):
|
|||||||
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
|
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
|
||||||
self.assertIn("ABC-20 waits: it is a human's task\n", out)
|
self.assertIn("ABC-20 waits: it is a human's task\n", out)
|
||||||
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
|
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
|
||||||
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
|
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
|
||||||
# The session is no checkout's, so nothing marks it as one's.
|
# The session is no checkout's, so nothing marks it as one's.
|
||||||
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
|
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
|
||||||
|
|
||||||
@@ -195,22 +195,22 @@ class TheCommand(DoEpicTest):
|
|||||||
|
|
||||||
class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
||||||
def test_naming_the_chunks_folder_doesnt_make_it(self) -> None:
|
def test_naming_the_chunks_folder_doesnt_make_it(self) -> None:
|
||||||
folder = self.home / ".local/state/do-epic/ABC-12"
|
folder = self.home / ".local/state/build-release/do-epic/ABC-12"
|
||||||
self.assertEqual(main.chunk_root("ABC-21", self.issues[1], self.epic_run(FakeEffects())), (str(folder), None))
|
self.assertEqual(main.chunk_root("ABC-21", self.issues[1], self.epic_run(FakeEffects())), (str(folder), None))
|
||||||
self.assertFalse(folder.exists())
|
self.assertFalse(folder.exists())
|
||||||
self.assertIsNone(main.folder_made(str(folder)))
|
self.assertIsNone(main.folder_made(str(folder)))
|
||||||
self.assertTrue(folder.is_dir())
|
self.assertTrue(folder.is_dir())
|
||||||
|
|
||||||
def test_a_chunk_whose_folder_cannot_be_made_stops_with_the_reason(self) -> None:
|
def test_a_chunk_whose_folder_cannot_be_made_stops_with_the_reason(self) -> None:
|
||||||
(self.home / ".local/state").mkdir(parents=True, exist_ok=True)
|
(self.home / ".local/state/build-release").mkdir(parents=True, exist_ok=True)
|
||||||
(self.home / ".local/state/do-epic").write_text("", encoding="utf-8")
|
(self.home / ".local/state/build-release/do-epic").write_text("", encoding="utf-8")
|
||||||
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
|
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
|
||||||
self.assertEqual(code, 1)
|
self.assertEqual(code, 1)
|
||||||
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/do-epic/ABC-12: \\w")
|
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
|
||||||
|
|
||||||
def cycle(self, env: dict[str, str] | None = None, run: ChunkRun = ChunkRun(1)) -> main.Cycle:
|
def cycle(self, env: dict[str, str] | None = None, run: ChunkRun = ChunkRun(1)) -> main.Cycle:
|
||||||
fake = FakeEffects(git=[Failure("no git"), Failure("no git")])
|
fake = FakeEffects(git=[Failure("no git"), Failure("no git")])
|
||||||
paths = paths_from(self.home)
|
paths = paths_from(self.home, env or {})
|
||||||
epic = self.epic_run(fake, env)
|
epic = self.epic_run(fake, env)
|
||||||
place = main.chunk_root("ABC-21", self.issues[1], epic)
|
place = main.chunk_root("ABC-21", self.issues[1], epic)
|
||||||
assert isinstance(place, tuple)
|
assert isinstance(place, tuple)
|
||||||
@@ -243,7 +243,7 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
|||||||
|
|
||||||
def test_works_in_the_epics_folder_and_archives_apart_from_build_release(self) -> None:
|
def test_works_in_the_epics_folder_and_archives_apart_from_build_release(self) -> None:
|
||||||
cycle = self.cycle()
|
cycle = self.cycle()
|
||||||
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/do-epic/ABC-12"), self.home / ".claude/do-epic-transcripts/ABC-12", ""))
|
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/build-release/do-epic/ABC-12"), self.home / ".local/state/build-release/do-epic-transcripts/ABC-12", ""))
|
||||||
|
|
||||||
def test_the_records_are_the_epics_scoring_and_decisions_then_the_humans_rules(self) -> None:
|
def test_the_records_are_the_epics_scoring_and_decisions_then_the_humans_rules(self) -> None:
|
||||||
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
|
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
|
||||||
@@ -315,7 +315,7 @@ class TheHumansRun(DoEpicTest):
|
|||||||
code, _, err = self.run_main(["ABC-12"], FakeEffects())
|
code, _, err = self.run_main(["ABC-12"], FakeEffects())
|
||||||
self.assertEqual(code, 1)
|
self.assertEqual(code, 1)
|
||||||
self.assertIn("`**Max parallel chunks:** many`, which is not a whole number of 1 or more", err)
|
self.assertIn("`**Max parallel chunks:** many`, which is not a whole number of 1 or more", err)
|
||||||
(self.home / ".claude-projects/do-epic/config.toml").unlink()
|
(self.home / ".config/build-release/do-epic/config.toml").unlink()
|
||||||
code, out, err = self.run_main(["ABC-12"], FakeEffects())
|
code, out, err = self.run_main(["ABC-12"], FakeEffects())
|
||||||
self.assertEqual((code, out), (1, ""))
|
self.assertEqual((code, out), (1, ""))
|
||||||
self.assertIn("config.toml", err)
|
self.assertIn("config.toml", err)
|
||||||
@@ -413,9 +413,9 @@ class AChunksRun(DoEpicTest):
|
|||||||
self.assertNotIn("=== cycle 3", out)
|
self.assertNotIn("=== cycle 3", out)
|
||||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||||
self.assertEqual(fake.dms, [])
|
self.assertEqual(fake.dms, [])
|
||||||
archive = self.home / ".claude/do-epic-transcripts/ABC-12"
|
archive = self.home / ".local/state/build-release/do-epic-transcripts/ABC-12"
|
||||||
self.assertTrue(any(archive.iterdir()))
|
self.assertTrue(any(archive.iterdir()))
|
||||||
self.assertFalse((self.home / ".claude/loop-claude-transcripts").exists())
|
self.assertFalse((self.home / ".local/state/build-release/transcripts").exists())
|
||||||
streamed = [what for seam, what in fake.calls if seam == "stream_claude"]
|
streamed = [what for seam, what in fake.calls if seam == "stream_claude"]
|
||||||
self.assertIn("Work the Jira issue ABC-21 of the epic ABC-12 as one chunk", " ".join(streamed[0]))
|
self.assertIn("Work the Jira issue ABC-21 of the epic ABC-12 as one chunk", " ".join(streamed[0]))
|
||||||
self.assertNotIn("Work the Jira issue", " ".join(streamed[1]))
|
self.assertNotIn("Work the Jira issue", " ".join(streamed[1]))
|
||||||
@@ -428,7 +428,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
judged_with = [" ".join(what[0]) + (what[1] or "") for seam, what in fake.calls if seam == "claude"]
|
judged_with = [" ".join(what[0]) + (what[1] or "") for seam, what in fake.calls if seam == "claude"]
|
||||||
self.assertEqual((len(prompts), len(judged_with)), (3, 3))
|
self.assertEqual((len(prompts), len(judged_with)), (3, 3))
|
||||||
for text in (*prompts, *judged_with, *fake.dms, *[str(what) for seam, what in fake.calls if seam == "input"]):
|
for text in (*prompts, *judged_with, *fake.dms, *[str(what) for seam, what in fake.calls if seam == "input"]):
|
||||||
self.assertNotIn("build-release", text)
|
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
|
||||||
self.assertNotIn("None", text)
|
self.assertNotIn("None", text)
|
||||||
self.assertIn(" do-epic runs you on claude-", prompts[1])
|
self.assertIn(" do-epic runs you on claude-", prompts[1])
|
||||||
self.assertIn("The human answered your question at do-epic's terminal:\nUse B.", prompts[2])
|
self.assertIn("The human answered your question at do-epic's terminal:\nUse B.", prompts[2])
|
||||||
@@ -449,7 +449,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished", escalation="working")] + [judged("unfinished")] * 5, git=UNREAD)
|
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished", escalation="working")] + [judged("unfinished")] * 5, git=UNREAD)
|
||||||
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
||||||
self.assertEqual(code, 2, out)
|
self.assertEqual(code, 2, out)
|
||||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".claude/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||||
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
||||||
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
"""Writes the file, and adds a line to the worker's transcript after each copy of it, as a worker that still writes does."""
|
"""Writes the file, and adds a line to the worker's transcript after each copy of it, as a worker that still writes does."""
|
||||||
unwritten = replace_file(path, data)
|
unwritten = replace_file(path, data)
|
||||||
if path.suffix == ".jsonl":
|
if path.suffix == ".jsonl":
|
||||||
for transcript in (paths_from(self.home).claude_code_transcripts.parent / "projects" / "-fake").glob("*.jsonl"):
|
for transcript in (paths_from(self.home, {}).claude_code_transcripts.parent / "projects" / "-fake").glob("*.jsonl"):
|
||||||
with open(transcript, "a", encoding="utf-8") as handle:
|
with open(transcript, "a", encoding="utf-8") as handle:
|
||||||
handle.write(json.dumps({"type": "queue-operation", "timestamp": str(path)}) + "\n")
|
handle.write(json.dumps({"type": "queue-operation", "timestamp": str(path)}) + "\n")
|
||||||
return unwritten
|
return unwritten
|
||||||
@@ -468,7 +468,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
fake.replace_file = grown_after_each_copy
|
fake.replace_file = grown_after_each_copy
|
||||||
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
||||||
self.assertEqual(code, 2, out)
|
self.assertEqual(code, 2, out)
|
||||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".claude/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||||
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
||||||
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||||
|
|
||||||
def test_where_the_teams_automation_moves_issues_a_finished_chunk_without_a_repo_still_moves_its_own(self) -> None:
|
def test_where_the_teams_automation_moves_issues_a_finished_chunk_without_a_repo_still_moves_its_own(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||||
parent = issue("ABC-23", "split-by-repo")
|
parent = issue("ABC-23", "split-by-repo")
|
||||||
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "do-epic-claude", parent="ABC-23"), issue("ABC-22", "do-epic-claude", blockers=("ABC-23",))])
|
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "do-epic-claude", parent="ABC-23"), issue("ABC-22", "do-epic-claude", blockers=("ABC-23",))])
|
||||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||||
@@ -515,7 +515,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||||
|
|
||||||
def test_the_last_sub_task_a_person_filed_to_finish_moves_its_parent_to_done_and_starts_what_it_blocks(self) -> None:
|
def test_the_last_sub_task_a_person_filed_to_finish_moves_its_parent_to_done_and_starts_what_it_blocks(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||||
tasks = [issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21", done=True)]
|
tasks = [issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21", done=True)]
|
||||||
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), *tasks, issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
|
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), *tasks, issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
|
||||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||||
@@ -526,7 +526,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||||
|
|
||||||
def test_a_parent_jira_will_not_move_is_said_and_the_next_chunk_still_starts(self) -> None:
|
def test_a_parent_jira_will_not_move_is_said_and_the_next_chunk_still_starts(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||||
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-22", "do-epic-claude")])
|
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-22", "do-epic-claude")])
|
||||||
finish = store.finish_issue
|
finish = store.finish_issue
|
||||||
store.finish_issue = lambda key: Failure("no way to done") if key == "ABC-21" else finish(key) # type: ignore[method-assign]
|
store.finish_issue = lambda key: Failure("no way to done") if key == "ABC-21" else finish(key) # type: ignore[method-assign]
|
||||||
@@ -614,7 +614,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
|
|
||||||
def test_a_chunk_in_a_repo_routes_on_the_repos_model(self) -> None:
|
def test_a_chunk_in_a_repo_routes_on_the_repos_model(self) -> None:
|
||||||
folder = self.repo_chunk()
|
folder = self.repo_chunk()
|
||||||
models = self.home / ".claude/loop-claude-models.json"
|
models = self.home / ".config/build-release/models.json"
|
||||||
models.parent.mkdir(parents=True, exist_ok=True)
|
models.parent.mkdir(parents=True, exist_ok=True)
|
||||||
models.write_text(json.dumps({folder.name: "claude-fable-5-2", "other": "claude-opus-5-5"}), encoding="utf-8")
|
models.write_text(json.dumps({folder.name: "claude-fable-5-2", "other": "claude-opus-5-5"}), encoding="utf-8")
|
||||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
|
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
|
||||||
@@ -661,7 +661,7 @@ class AChunksRun(DoEpicTest):
|
|||||||
store.issues[:] = [issue("ABC-20", "do-epic-claude")]
|
store.issues[:] = [issue("ABC-20", "do-epic-claude")]
|
||||||
return super().__call__(*args, **kwargs)
|
return super().__call__(*args, **kwargs)
|
||||||
|
|
||||||
worker = Relabelling(paths_from(self.home).claude_code_transcripts.parent)
|
worker = Relabelling(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||||
fake = FakeEffects(streams=[worker, self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD)
|
fake = FakeEffects(streams=[worker, self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD)
|
||||||
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
@@ -710,7 +710,7 @@ class WhatAWorkerJudgeAndHumanRead(DoEpicTest):
|
|||||||
str(judge.judge_schema(prompts.driver)),
|
str(judge.judge_schema(prompts.driver)),
|
||||||
]
|
]
|
||||||
for text in texts:
|
for text in texts:
|
||||||
self.assertNotIn("build-release", text)
|
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
|
||||||
self.assertIn(f"do-epic runs you on {cycle.route.rung}, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue.", texts[0])
|
self.assertIn(f"do-epic runs you on {cycle.route.rung}, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue.", texts[0])
|
||||||
self.assertRegex(texts[0], r"it means the issue\.( \S|\n\n)")
|
self.assertRegex(texts[0], r"it means the issue\.( \S|\n\n)")
|
||||||
self.assertNotIn("Chunk items:", texts[1])
|
self.assertNotIn("Chunk items:", texts[1])
|
||||||
@@ -738,8 +738,8 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
|||||||
super().setUp()
|
super().setUp()
|
||||||
self.repo_config = self.repo_chunk() / "config.toml"
|
self.repo_config = self.repo_chunk() / "config.toml"
|
||||||
self.issues.append(issue("ABC-22", "do-epic-claude"))
|
self.issues.append(issue("ABC-22", "do-epic-claude"))
|
||||||
self.file = parked.file_of(self.home / ".local/state/do-epic/ABC-12", "ABC-20")
|
self.file = parked.file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20")
|
||||||
self.session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home).claude_code_transcripts)
|
self.session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
|
||||||
|
|
||||||
def parked_run(self, fake: FakeEffects) -> tuple[int, str, str, list[str]]:
|
def parked_run(self, fake: FakeEffects) -> tuple[int, str, str, list[str]]:
|
||||||
"""The chunk's run, as its exit code, what it printed, and each prompt its workers got."""
|
"""The chunk's run, as its exit code, what it printed, and each prompt its workers got."""
|
||||||
@@ -855,7 +855,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
|||||||
self.assertEqual((code, len(prompts)), (0, 1), err)
|
self.assertEqual((code, len(prompts)), (0, 1), err)
|
||||||
|
|
||||||
def test_where_the_teams_automation_moves_issues_a_finished_chunk_in_a_repo_moves_none_and_waits_for_the_move(self) -> None:
|
def test_where_the_teams_automation_moves_issues_a_finished_chunk_in_a_repo_moves_none_and_waits_for_the_move(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||||
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
||||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||||
self.forges = [awaiting(pulls="")]
|
self.forges = [awaiting(pulls="")]
|
||||||
@@ -953,7 +953,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
|||||||
self.assertFalse(self.file.exists())
|
self.assertFalse(self.file.exists())
|
||||||
|
|
||||||
def test_where_the_teams_automation_moves_issues_a_merged_parked_chunk_waits_for_the_move_as_a_finished_one_does(self) -> None:
|
def test_where_the_teams_automation_moves_issues_a_merged_parked_chunk_waits_for_the_move_as_a_finished_one_does(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||||
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
||||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||||
self.forges = [awaiting(), awaiting(pulls="", merged=True)]
|
self.forges = [awaiting(), awaiting(pulls="", merged=True)]
|
||||||
@@ -1117,7 +1117,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
|||||||
self.git_timeouts: list[tuple[str, object]] = []
|
self.git_timeouts: list[tuple[str, object]] = []
|
||||||
|
|
||||||
def settings(self, more: str) -> None:
|
def settings(self, more: str) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
|
||||||
|
|
||||||
def with_git(self, fake: FakeEffects, **answers: str | Failure) -> FakeEffects:
|
def with_git(self, fake: FakeEffects, **answers: str | Failure) -> FakeEffects:
|
||||||
"""fake, whose git answers each command by its first word: as answers has it, else as a checkout whose origin has the branch ABC-12, which holds origin/main."""
|
"""fake, whose git answers each command by its first word: as answers has it, else as a checkout whose origin has the branch ABC-12, which holds origin/main."""
|
||||||
@@ -1157,7 +1157,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
|||||||
def test_a_folder_no_checkout_holds_stops_with_the_reason_its_config_cannot_be_found(self) -> None:
|
def test_a_folder_no_checkout_holds_stops_with_the_reason_its_config_cannot_be_found(self) -> None:
|
||||||
elsewhere = self.home / "elsewhere"
|
elsewhere = self.home / "elsewhere"
|
||||||
elsewhere.mkdir()
|
elsewhere.mkdir()
|
||||||
unnamed = main.config_located(str(elsewhere), self.home)
|
unnamed = main.config_located(str(elsewhere), self.home, {})
|
||||||
assert isinstance(unnamed, Failure), unnamed
|
assert isinstance(unnamed, Failure), unnamed
|
||||||
self.assertEqual(main.epic_based("ABC-20", str(elsewhere), self.epic_run(self.with_git(FakeEffects()))), main.Stop(1, unnamed.reason))
|
self.assertEqual(main.epic_based("ABC-20", str(elsewhere), self.epic_run(self.with_git(FakeEffects()))), main.Stop(1, unnamed.reason))
|
||||||
|
|
||||||
@@ -1210,8 +1210,8 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
|||||||
|
|
||||||
def test_a_chunk_parked_on_a_persons_merge_into_the_default_branch_stays_parked_until_its_pull_request_goes_into_the_branch(self) -> None:
|
def test_a_chunk_parked_on_a_persons_merge_into_the_default_branch_stays_parked_until_its_pull_request_goes_into_the_branch(self) -> None:
|
||||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||||
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home).claude_code_transcripts)
|
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
|
||||||
parked.park(self.home / ".local/state/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
|
parked.park(self.home / ".local/state/build-release/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
|
||||||
self.worker()(["--session-id", str(session.id)])
|
self.worker()(["--session-id", str(session.id)])
|
||||||
# The pull request was opened into main before the setting was on; a person then changes its base to ABC-12.
|
# The pull request was opened into main before the setting was on; a person then changes its base to ABC-12.
|
||||||
self.forges = [self.recorded(decision="APPROVED"), self.recorded(decision="APPROVED"), self.recorded(base="ABC-12", decision="APPROVED")]
|
self.forges = [self.recorded(decision="APPROVED"), self.recorded(decision="APPROVED"), self.recorded(base="ABC-12", decision="APPROVED")]
|
||||||
@@ -1419,7 +1419,7 @@ class TheDryRun(DoEpicTest):
|
|||||||
self.assertEqual([args for args in fake.tmux_calls if args[0] in changing], [])
|
self.assertEqual([args for args in fake.tmux_calls if args[0] in changing], [])
|
||||||
|
|
||||||
def test_prints_each_move_of_a_parent_whose_sub_tasks_a_person_filed(self) -> None:
|
def test_prints_each_move_of_a_parent_whose_sub_tasks_a_person_filed(self) -> None:
|
||||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||||
self.issues = [issue("ABC-20", status="In Progress"), issue("ABC-30", "do-epic-claude", parent="ABC-20", status="Release Ready"), issue("ABC-21"), issue("ABC-31", "do-epic-claude", parent="ABC-21", done=True), issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))]
|
self.issues = [issue("ABC-20", status="In Progress"), issue("ABC-30", "do-epic-claude", parent="ABC-20", status="Release Ready"), issue("ABC-21"), issue("ABC-31", "do-epic-claude", parent="ABC-21", done=True), issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))]
|
||||||
code, out, err = self.run_main(["ABC-12", "--dry-run"], FakeEffects())
|
code, out, err = self.run_main(["ABC-12", "--dry-run"], FakeEffects())
|
||||||
self.assertEqual((code, err), (0, ""))
|
self.assertEqual((code, err), (0, ""))
|
||||||
|
|||||||
@@ -36,12 +36,16 @@ def scored(key: str, moves: str, *labels: str, blockers: tuple[str, ...] = (), b
|
|||||||
|
|
||||||
|
|
||||||
class Planning(DoEpicTest):
|
class Planning(DoEpicTest):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
super().setUp()
|
||||||
|
self.folder = self.home / ".local/state/build-release/do-epic/ABC-12"
|
||||||
|
|
||||||
def plan(self, fake: FakeEffects) -> tuple[list[EpicIssue] | Failure | Limited, MemoryEpic, str]:
|
def plan(self, fake: FakeEffects) -> tuple[list[EpicIssue] | Failure | Limited, MemoryEpic, str]:
|
||||||
"""What planning answers for self.issues, the store it changed and what it printed on stdout. self.asked holds what it asked the human, on stderr."""
|
"""What planning answers for self.issues, the store it changed and what it printed on stdout. self.asked holds what it asked the human, on stderr."""
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
assert not isinstance(config, Failure), config
|
assert not isinstance(config, Failure), config
|
||||||
store = MemoryEpic("ABC-12", list(self.issues))
|
store = MemoryEpic("ABC-12", list(self.issues))
|
||||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, fake.effects()) # type: ignore[arg-type]
|
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, {}, self.folder, fake.effects()) # type: ignore[arg-type]
|
||||||
out, self.asked = io.StringIO(), io.StringIO()
|
out, self.asked = io.StringIO(), io.StringIO()
|
||||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(self.asked):
|
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(self.asked):
|
||||||
read = store.read()
|
read = store.read()
|
||||||
@@ -73,7 +77,7 @@ class Planning(DoEpicTest):
|
|||||||
self.assertEqual((found, out, fake.made("claude")), (self.issues, "", []))
|
self.assertEqual((found, out, fake.made("claude")), (self.issues, "", []))
|
||||||
|
|
||||||
def test_an_epic_shaped_as_a_teams_is_planned_without_claude_and_without_a_write(self) -> None:
|
def test_an_epic_shaped_as_a_teams_is_planned_without_claude_and_without_a_write(self) -> None:
|
||||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||||
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\ncore-4 = "core-4"\n')
|
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\ncore-4 = "core-4"\n')
|
||||||
self.description = RANKED
|
self.description = RANKED
|
||||||
self.repo("tenant-web-ui-4")
|
self.repo("tenant-web-ui-4")
|
||||||
@@ -120,7 +124,7 @@ class Planning(DoEpicTest):
|
|||||||
self.assertIn("in English, that tells the team why it is split by repo", fake.made("claude")[0][1])
|
self.assertIn("in English, that tells the team why it is split by repo", fake.made("claude")[0][1])
|
||||||
|
|
||||||
def test_a_failed_runs_sub_task_under_the_teams_label_is_not_filed_again_and_another_label_is_no_pick(self) -> None:
|
def test_a_failed_runs_sub_task_under_the_teams_label_is_not_filed_again_and_another_label_is_no_pick(self) -> None:
|
||||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||||
config.write('\n[label-repos]\nbackend = "api"\n')
|
config.write('\n[label-repos]\nbackend = "api"\n')
|
||||||
configured(self, self.home / "code" / "api", home=self.home)
|
configured(self, self.home / "code" / "api", home=self.home)
|
||||||
self.issues = [issue("ABC-20", "urgent"), dataclasses.replace(issue("ABC-23", "backend", parent="ABC-20"), by_loop=True), issue("ABC-21", "urgent")]
|
self.issues = [issue("ABC-20", "urgent"), dataclasses.replace(issue("ABC-23", "backend", parent="ABC-20"), by_loop=True), issue("ABC-21", "urgent")]
|
||||||
@@ -151,12 +155,11 @@ class Planning(DoEpicTest):
|
|||||||
def claude(args: object, cwd: str, stdin: object) -> object:
|
def claude(args: object, cwd: str, stdin: object) -> object:
|
||||||
folders.append(cwd)
|
folders.append(cwd)
|
||||||
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description("")), self.home, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description("")), self.home, {}, self.folder, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
planning.planned(epic, list(self.issues))
|
planning.planned(epic, list(self.issues))
|
||||||
folder = self.home / ".local" / "state" / "do-epic" / "ABC-12"
|
self.assertEqual((folders, self.folder.is_dir()), ([str(self.folder)] * 2, True))
|
||||||
self.assertEqual((folders, folder.is_dir()), ([str(folder)] * 2, True))
|
|
||||||
|
|
||||||
def test_a_model_off_the_routing_ladder_has_no_rung(self) -> None:
|
def test_a_model_off_the_routing_ladder_has_no_rung(self) -> None:
|
||||||
found = planning.planning_rung("claude-nope-1")
|
found = planning.planning_rung("claude-nope-1")
|
||||||
@@ -181,7 +184,7 @@ class Planning(DoEpicTest):
|
|||||||
self.assertEqual(args[args.index("--add-dir") + 1], str(checkout))
|
self.assertEqual(args[args.index("--add-dir") + 1], str(checkout))
|
||||||
|
|
||||||
def test_asks_for_one_of_the_teams_labels_too_and_takes_it(self) -> None:
|
def test_asks_for_one_of_the_teams_labels_too_and_takes_it(self) -> None:
|
||||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||||
config.write('\n[label-repos]\nbackend = "api"\n')
|
config.write('\n[label-repos]\nbackend = "api"\n')
|
||||||
self.issues = [issue("ABC-20")]
|
self.issues = [issue("ABC-20")]
|
||||||
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["backend"])
|
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["backend"])
|
||||||
@@ -190,7 +193,7 @@ class Planning(DoEpicTest):
|
|||||||
|
|
||||||
def configure_team(self, *above: str) -> None:
|
def configure_team(self, *above: str) -> None:
|
||||||
"""Gives the config the team's label `backend` for api, and the settings in above."""
|
"""Gives the config the team's label `backend` for api, and the settings in above."""
|
||||||
path = self.home / ".claude-projects/do-epic/config.toml"
|
path = self.home / ".config/build-release/do-epic/config.toml"
|
||||||
path.write_text("".join(f"{line}\n" for line in above) + path.read_text(encoding="utf-8") + '\n[label-repos]\nbackend = "api"\n', encoding="utf-8")
|
path.write_text("".join(f"{line}\n" for line in above) + path.read_text(encoding="utf-8") + '\n[label-repos]\nbackend = "api"\n', encoding="utf-8")
|
||||||
|
|
||||||
def test_files_sub_tasks_under_the_teams_label_and_summary_template(self) -> None:
|
def test_files_sub_tasks_under_the_teams_label_and_summary_template(self) -> None:
|
||||||
@@ -379,7 +382,7 @@ class Planning(DoEpicTest):
|
|||||||
self.description = RANKED
|
self.description = RANKED
|
||||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude", by_loop=False), issue("ABC-21", "do-epic-claude")]
|
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude", by_loop=False), issue("ABC-21", "do-epic-claude")]
|
||||||
# An earlier run made the folder the scoring runs in.
|
# An earlier run made the folder the scoring runs in.
|
||||||
(self.home / planning.STATE / "ABC-12").mkdir(parents=True, exist_ok=True)
|
self.folder.mkdir(parents=True, exist_ok=True)
|
||||||
fake = FakeEffects(claude=[says(ANSWER)])
|
fake = FakeEffects(claude=[says(ANSWER)])
|
||||||
found, store, out = self.plan(fake)
|
found, store, out = self.plan(fake)
|
||||||
assert not isinstance(found, Failure | Limited), found
|
assert not isinstance(found, Failure | Limited), found
|
||||||
@@ -402,7 +405,7 @@ class Planning(DoEpicTest):
|
|||||||
self.assertEqual((found, store.writes, out, fake.made("claude")), (self.issues, [], "", []))
|
self.assertEqual((found, store.writes, out, fake.made("claude")), (self.issues, [], "", []))
|
||||||
|
|
||||||
def test_scores_no_issue_whose_work_has_landed(self) -> None:
|
def test_scores_no_issue_whose_work_has_landed(self) -> None:
|
||||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||||
config.write('\njira-unblocking-statuses = ["Release Ready"]\n')
|
config.write('\njira-unblocking-statuses = ["Release Ready"]\n')
|
||||||
self.rule()
|
self.rule()
|
||||||
self.description = RANKED
|
self.description = RANKED
|
||||||
@@ -446,11 +449,11 @@ class Planning(DoEpicTest):
|
|||||||
def claude(args: object, cwd: str, stdin: object) -> object:
|
def claude(args: object, cwd: str, stdin: object) -> object:
|
||||||
folders.append(cwd)
|
folders.append(cwd)
|
||||||
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description(RANKED)), self.home, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description(RANKED)), self.home, {}, self.folder, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
planning.planned(epic, list(self.issues))
|
planning.planned(epic, list(self.issues))
|
||||||
self.assertEqual(folders, [str(self.home / ".local" / "state" / "do-epic" / "ABC-12")] * 2)
|
self.assertEqual(folders, [str(self.folder)] * 2)
|
||||||
|
|
||||||
self.rule()
|
self.rule()
|
||||||
self.description = RANKED
|
self.description = RANKED
|
||||||
@@ -467,9 +470,9 @@ class Planning(DoEpicTest):
|
|||||||
store = MemoryEpic("ABC-12", list(self.issues))
|
store = MemoryEpic("ABC-12", list(self.issues))
|
||||||
store.fails = "Jira answered 503"
|
store.fails = "Jira answered 503"
|
||||||
out = io.StringIO()
|
out = io.StringIO()
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
assert not isinstance(config, Failure), config
|
assert not isinstance(config, Failure), config
|
||||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, FakeEffects(claude=[says(ANSWER)]).effects()) # type: ignore[arg-type]
|
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, {}, self.folder, FakeEffects(claude=[says(ANSWER)]).effects()) # type: ignore[arg-type]
|
||||||
with contextlib.redirect_stdout(out):
|
with contextlib.redirect_stdout(out):
|
||||||
found, stopped = planning.scored(epic, list(self.issues))
|
found, stopped = planning.scored(epic, list(self.issues))
|
||||||
self.assertEqual((found, stopped, out.getvalue()), (self.issues, None, "<1790000000> scoring ABC-20\n<1790000000> ABC-20 is not scored: Jira answered 503\n"))
|
self.assertEqual((found, stopped, out.getvalue()), (self.issues, None, "<1790000000> scoring ABC-20\n<1790000000> ABC-20 is not scored: Jira answered 503\n"))
|
||||||
@@ -518,9 +521,9 @@ class Planning(DoEpicTest):
|
|||||||
|
|
||||||
def planned_on(self, store: MemoryEpic, fake: FakeEffects) -> tuple[list[EpicIssue], Failure | Limited | None]:
|
def planned_on(self, store: MemoryEpic, fake: FakeEffects) -> tuple[list[EpicIssue], Failure | Limited | None]:
|
||||||
"""What planning answers for self.issues on a store that doesn't read as MemoryEpic does."""
|
"""What planning answers for self.issues on a store that doesn't read as MemoryEpic does."""
|
||||||
config = load(self.home)
|
config = load(self.home, {})
|
||||||
assert not isinstance(config, Failure), config
|
assert not isinstance(config, Failure), config
|
||||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, fake.effects()) # type: ignore[arg-type]
|
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, {}, self.folder, fake.effects()) # type: ignore[arg-type]
|
||||||
with contextlib.redirect_stdout(io.StringIO()):
|
with contextlib.redirect_stdout(io.StringIO()):
|
||||||
return planning.planned(epic, list(self.issues))
|
return planning.planned(epic, list(self.issues))
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class LocateTest(unittest.TestCase):
|
|||||||
made = tempfile.TemporaryDirectory()
|
made = tempfile.TemporaryDirectory()
|
||||||
self.addCleanup(made.cleanup)
|
self.addCleanup(made.cleanup)
|
||||||
self.home = pathlib.Path(made.name).resolve()
|
self.home = pathlib.Path(made.name).resolve()
|
||||||
self.projects = self.home / ".claude-projects"
|
self.projects = self.home / ".config/build-release"
|
||||||
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
|
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
|
||||||
self.billing, self.payments = self.home / "elsewhere" / "billing", self.home / "elsewhere" / "payments"
|
self.billing, self.payments = self.home / "elsewhere" / "billing", self.home / "elsewhere" / "payments"
|
||||||
self.origins: dict[str, str | Failure] = {str(self.billing): "git@github.com:acme/billing.git", str(self.payments): "git@github.com:acme/payments"}
|
self.origins: dict[str, str | Failure] = {str(self.billing): "git@github.com:acme/billing.git", str(self.payments): "git@github.com:acme/payments"}
|
||||||
@@ -52,7 +52,7 @@ class LocateTest(unittest.TestCase):
|
|||||||
write_config(self.home, self.home / "code" / "ledger")
|
write_config(self.home, self.home / "code" / "ledger")
|
||||||
|
|
||||||
def locate(self, git: FakeGit, name: str = "ledger") -> Located | Failure:
|
def locate(self, git: FakeGit, name: str = "ledger") -> Located | Failure:
|
||||||
return locate(name, [self.billing, self.payments], self.config, self.home, git)
|
return locate(name, [self.billing, self.payments], self.config, self.home, {}, git)
|
||||||
|
|
||||||
def unsure(self, git: FakeGit, name: str = "ledger") -> str:
|
def unsure(self, git: FakeGit, name: str = "ledger") -> str:
|
||||||
found = self.locate(git, name)
|
found = self.locate(git, name)
|
||||||
@@ -100,7 +100,7 @@ class LocateTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_asks_where_no_other_repo_shows_where_to_clone_from(self) -> None:
|
def test_asks_where_no_other_repo_shows_where_to_clone_from(self) -> None:
|
||||||
self.configure()
|
self.configure()
|
||||||
found = locate("ledger", [], self.config, self.home, FakeGit({}))
|
found = locate("ledger", [], self.config, self.home, {}, FakeGit({}))
|
||||||
assert isinstance(found, Unsure), found
|
assert isinstance(found, Unsure), found
|
||||||
self.assertIn("no other repo of the epic", found.reason)
|
self.assertIn("no other repo of the epic", found.reason)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from do_epic.backend.protocol import EpicIssue
|
|||||||
from failure import Failure
|
from failure import Failure
|
||||||
from do_epic.parked import file_of, park, Parked
|
from do_epic.parked import file_of, park, Parked
|
||||||
from do_epic.epic_record import parallel_chunks_in
|
from do_epic.epic_record import parallel_chunks_in
|
||||||
|
from loop_state.paths import paths_from
|
||||||
from chunk_driver import prompts
|
from chunk_driver import prompts
|
||||||
from model_routing.route import Route
|
from model_routing.route import Route
|
||||||
from model_routing.ladder import Rung
|
from model_routing.ladder import Rung
|
||||||
@@ -210,7 +211,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
"""An epic whose repos are checked out under the home folder, each with its `parallel-chunks`."""
|
"""An epic whose repos are checked out under the home folder, each with its `parallel-chunks`."""
|
||||||
def locate(name: str) -> tuple[pathlib.Path, int] | Failure:
|
def locate(name: str) -> tuple[pathlib.Path, int] | Failure:
|
||||||
return (self.home / "code" / name, limits[name]) if name in limits else Failure(f"no project config names {name}")
|
return (self.home / "code" / name, limits[name]) if name in limits else Failure(f"no project config names {name}")
|
||||||
return Epic("ABC-12", cap, locate, self.home, pathlib.Path("/bin/do-epic"), {"BUILD_RELEASE_X": "1", "OTHER": "2"}, {}, self.order)
|
return Epic("ABC-12", cap, locate, paths_from(self.home, {}), pathlib.Path("/bin/do-epic"), {"BUILD_RELEASE_X": "1", "OTHER": "2"}, {}, self.order)
|
||||||
|
|
||||||
def start(self, epic: Epic, issues: list[EpicIssue], run: Tmux, own: str | None = None) -> Started:
|
def start(self, epic: Epic, issues: list[EpicIssue], run: Tmux, own: str | None = None) -> Started:
|
||||||
found = start_chunks(epic, issues, False, own, run)
|
found = start_chunks(epic, issues, False, own, run)
|
||||||
@@ -222,12 +223,12 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
found = self.start(self.epic(2, api=1, web=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "repo:web")], run)
|
found = self.start(self.epic(2, api=1, web=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "repo:web")], run)
|
||||||
self.assertEqual(found, Started(["ABC-20", "ABC-21"], [Waits("ABC-22", "the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 2")]))
|
self.assertEqual(found, Started(["ABC-20", "ABC-21"], [Waits("ABC-22", "the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 2")]))
|
||||||
self.assertEqual(run.started(), [("epic-ABC-12", "ABC-20", f"{CHUNK_FLAG} ABC-20 ABC-12"), ("epic-ABC-12", "ABC-21", f"{CHUNK_FLAG} ABC-21 ABC-12")])
|
self.assertEqual(run.started(), [("epic-ABC-12", "ABC-20", f"{CHUNK_FLAG} ABC-20 ABC-12"), ("epic-ABC-12", "ABC-21", f"{CHUNK_FLAG} ABC-21 ABC-12")])
|
||||||
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/do-epic/ABC-12")])
|
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/build-release/do-epic/ABC-12")])
|
||||||
self.assertIn("BUILD_RELEASE_X=1", run.calls[[args[0] for args in run.calls].index("new-session")])
|
self.assertIn("BUILD_RELEASE_X=1", run.calls[[args[0] for args in run.calls].index("new-session")])
|
||||||
self.assertNotIn("OTHER=2", run.calls[[args[0] for args in run.calls].index("new-session")])
|
self.assertNotIn("OTHER=2", run.calls[[args[0] for args in run.calls].index("new-session")])
|
||||||
|
|
||||||
def parked(self, issue_key: str, on: str = "an approval") -> None:
|
def parked(self, issue_key: str, on: str = "an approval") -> None:
|
||||||
self.assertIsNone(park(self.home / ".local/state/do-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
|
self.assertIsNone(park(self.home / ".local/state/build-release/do-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
|
||||||
|
|
||||||
def test_starts_the_chunks_in_the_epics_start_order_and_those_it_leaves_out_last_in_backlog_order(self) -> None:
|
def test_starts_the_chunks_in_the_epics_start_order_and_those_it_leaves_out_last_in_backlog_order(self) -> None:
|
||||||
self.order = ("ABC-23", "ABC-21")
|
self.order = ("ABC-23", "ABC-21")
|
||||||
@@ -260,7 +261,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
run = Tmux(*windows, ("epic-ABC-12", "ABC-21", False, str(self.home / "code/api")))
|
run = Tmux(*windows, ("epic-ABC-12", "ABC-21", False, str(self.home / "code/api")))
|
||||||
found = self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], run)
|
found = self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], run)
|
||||||
self.assertEqual(found, Started(["ABC-20"], []))
|
self.assertEqual(found, Started(["ABC-20"], []))
|
||||||
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/do-epic/ABC-12")))
|
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/build-release/do-epic/ABC-12")))
|
||||||
self.assertEqual([name for _, name, dead, _ in run.windows if dead], [""] * len(windows))
|
self.assertEqual([name for _, name, dead, _ in run.windows if dead], [""] * len(windows))
|
||||||
|
|
||||||
def test_a_human_task_that_blocks_an_issue_gets_a_window_that_takes_no_slot_of_the_epics_cap(self) -> None:
|
def test_a_human_task_that_blocks_an_issue_gets_a_window_that_takes_no_slot_of_the_epics_cap(self) -> None:
|
||||||
@@ -292,7 +293,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_stops_on_a_parked_chunk_it_cannot_read_and_starts_none(self) -> None:
|
def test_stops_on_a_parked_chunk_it_cannot_read_and_starts_none(self) -> None:
|
||||||
self.parked("ABC-20")
|
self.parked("ABC-20")
|
||||||
file_of(self.home / ".local/state/do-epic/ABC-12", "ABC-20").write_text("{")
|
file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20").write_text("{")
|
||||||
run = Tmux()
|
run = Tmux()
|
||||||
found = start_chunks(self.epic(2, api=2), [issue("ABC-21", "repo:api")], False, None, run)
|
found = start_chunks(self.epic(2, api=2), [issue("ABC-21", "repo:api")], False, None, run)
|
||||||
assert isinstance(found, Failure)
|
assert isinstance(found, Failure)
|
||||||
@@ -314,7 +315,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
self.assertEqual(run.windows[0], ("epic-ABC-12", "ABC-20", False, str(self.home / "code/api")))
|
self.assertEqual(run.windows[0], ("epic-ABC-12", "ABC-20", False, str(self.home / "code/api")))
|
||||||
|
|
||||||
def test_a_parked_chunk_whose_window_started_again_doesnt_count_itself_as_running(self) -> None:
|
def test_a_parked_chunk_whose_window_started_again_doesnt_count_itself_as_running(self) -> None:
|
||||||
for root in (str(self.home / ".local/state/do-epic/ABC-12"), str(self.home / "code/api")):
|
for root in (str(self.home / ".local/state/build-release/do-epic/ABC-12"), str(self.home / "code/api")):
|
||||||
with self.subTest(root=root):
|
with self.subTest(root=root):
|
||||||
run = Tmux(("epic-ABC-12", "ABC-20", False, root))
|
run = Tmux(("epic-ABC-12", "ABC-20", False, root))
|
||||||
self.assertIsNone(self.resumed(self.epic(1, api=1), run))
|
self.assertIsNone(self.resumed(self.epic(1, api=1), run))
|
||||||
@@ -373,12 +374,12 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
|
|
||||||
def test_holds_each_repos_starting_lock_that_build_release_holds(self) -> None:
|
def test_holds_each_repos_starting_lock_that_build_release_holds(self) -> None:
|
||||||
self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api")], Tmux())
|
self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api")], Tmux())
|
||||||
self.assertTrue((self.home / ".local/state/loop-claude/api/starting").is_file())
|
self.assertTrue((self.home / ".local/state/build-release/claims/api/starting").is_file())
|
||||||
self.assertTrue((self.home / ".local/state/do-epic/ABC-12/starting").is_file())
|
self.assertTrue((self.home / ".local/state/build-release/do-epic/ABC-12/starting").is_file())
|
||||||
|
|
||||||
def test_a_parked_chunk_resumes_under_the_starting_lock_of_its_repos_checkout(self) -> None:
|
def test_a_parked_chunk_resumes_under_the_starting_lock_of_its_repos_checkout(self) -> None:
|
||||||
self.assertIsNone(self.resumed(self.epic(1, api=1), Tmux(("epic-ABC-12", "ABC-20 awaits an approval", False, ""))))
|
self.assertIsNone(self.resumed(self.epic(1, api=1), Tmux(("epic-ABC-12", "ABC-20 awaits an approval", False, ""))))
|
||||||
self.assertEqual([lock.parent.name for lock in (self.home / ".local/state/loop-claude").glob("*/starting")], ["api"])
|
self.assertEqual([lock.parent.name for lock in (self.home / ".local/state/build-release/claims").glob("*/starting")], ["api"])
|
||||||
|
|
||||||
def test_the_waits_keep_the_trackers_rank_order(self) -> None:
|
def test_the_waits_keep_the_trackers_rank_order(self) -> None:
|
||||||
run = Tmux(("epic-ABC-12", "ABC-20", True, str(self.home / "code/api")), ("epic-ABC-12", "ABC-22", False, str(self.home / "code/api")))
|
run = Tmux(("epic-ABC-12", "ABC-20", True, str(self.home / "code/api")), ("epic-ABC-12", "ABC-22", False, str(self.home / "code/api")))
|
||||||
@@ -393,19 +394,19 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
|||||||
self.assertNotIn(tmux.OWNER, options)
|
self.assertNotIn(tmux.OWNER, options)
|
||||||
|
|
||||||
def test_says_which_lock_it_could_not_take(self) -> None:
|
def test_says_which_lock_it_could_not_take(self) -> None:
|
||||||
(self.home / ".local/state/do-epic").mkdir(parents=True)
|
(self.home / ".local/state/build-release/do-epic").mkdir(parents=True)
|
||||||
(self.home / ".local/state/do-epic/ABC-12").write_text("", encoding="utf-8")
|
(self.home / ".local/state/build-release/do-epic/ABC-12").write_text("", encoding="utf-8")
|
||||||
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
||||||
assert isinstance(found, Failure)
|
assert isinstance(found, Failure)
|
||||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/do-epic/ABC-12: \\w")
|
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
|
||||||
|
|
||||||
def test_says_which_repos_lock_it_could_not_take(self) -> None:
|
def test_says_which_repos_lock_it_could_not_take(self) -> None:
|
||||||
(self.home / ".local/state").mkdir(parents=True)
|
(self.home / ".local/state/build-release").mkdir(parents=True)
|
||||||
(self.home / ".local/state/loop-claude").write_text("", encoding="utf-8")
|
(self.home / ".local/state/build-release/claims").write_text("", encoding="utf-8")
|
||||||
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
||||||
assert isinstance(found, Failure)
|
assert isinstance(found, Failure)
|
||||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/loop-claude/\\S+: \\w")
|
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/claims/\\S+: \\w")
|
||||||
self.assertRegex(self.resumed(self.epic(1, api=1), Tmux()) or "", f"^cannot lock {self.home}/.local/state/loop-claude/\\S+: \\w")
|
self.assertRegex(self.resumed(self.epic(1, api=1), Tmux()) or "", f"^cannot lock {self.home}/.local/state/build-release/claims/\\S+: \\w")
|
||||||
|
|
||||||
def test_an_error_raised_under_the_lock_is_not_reported_as_the_locks(self) -> None:
|
def test_an_error_raised_under_the_lock_is_not_reported_as_the_locks(self) -> None:
|
||||||
def failing(args: list[str]) -> subprocess.CompletedProcess[str]:
|
def failing(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import unittest
|
|||||||
from failure import Failure
|
from failure import Failure
|
||||||
from do_epic.test_scheduler import issue, Tmux
|
from do_epic.test_scheduler import issue, Tmux
|
||||||
from do_epic import parked, status
|
from do_epic import parked, status
|
||||||
from do_epic.scheduler import STATE
|
|
||||||
|
|
||||||
SINCE = 1_700_000_000
|
SINCE = 1_700_000_000
|
||||||
# SINCE as the status prints it.
|
# SINCE as the status prints it.
|
||||||
@@ -17,15 +16,14 @@ EPIC = "epic-ABC-12"
|
|||||||
|
|
||||||
class TheStatusLines(unittest.TestCase):
|
class TheStatusLines(unittest.TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.home = pathlib.Path(tempfile.mkdtemp())
|
self.folder = pathlib.Path(tempfile.mkdtemp())
|
||||||
self.folder = self.home / STATE / "ABC-12"
|
|
||||||
|
|
||||||
def park(self, key: str, on: str) -> None:
|
def park(self, key: str, on: str) -> None:
|
||||||
parked.park(self.folder, parked.Parked(key, f"/code/api-{key}", "7", "s", on))
|
parked.park(self.folder, parked.Parked(key, f"/code/api-{key}", "7", "s", on))
|
||||||
os.utime(parked.file_of(self.folder, key), (SINCE, SINCE))
|
os.utime(parked.file_of(self.folder, key), (SINCE, SINCE))
|
||||||
|
|
||||||
def lines(self, issues: list, *windows: tuple[str, str, bool, str], unblocking: tuple[str, ...] = ()) -> list[str] | Failure:
|
def lines(self, issues: list, *windows: tuple[str, str, bool, str], unblocking: tuple[str, ...] = ()) -> list[str] | Failure:
|
||||||
return status.lines("ABC-12", self.home, issues, {}, unblocking, Tmux(*windows), ())
|
return status.lines("ABC-12", self.folder, issues, {}, unblocking, Tmux(*windows), ())
|
||||||
|
|
||||||
def test_a_chunk_that_asks_says_where_to_answer_and_one_that_works_runs(self) -> None:
|
def test_a_chunk_that_asks_says_where_to_answer_and_one_that_works_runs(self) -> None:
|
||||||
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], (EPIC, "ABC-20 ?", False, ""), (EPIC, "ABC-21", False, ""))
|
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], (EPIC, "ABC-20 ?", False, ""), (EPIC, "ABC-21", False, ""))
|
||||||
@@ -54,7 +52,7 @@ class TheStatusLines(unittest.TestCase):
|
|||||||
def test_an_issue_without_scores_says_that_it_starts_after_each_that_holds_them(self) -> None:
|
def test_an_issue_without_scores_says_that_it_starts_after_each_that_holds_them(self) -> None:
|
||||||
held = dataclasses.replace(issue("ABC-21", "repo:api"), scores={"L": 1, "E": 1, "I": 1, "S": 1})
|
held = dataclasses.replace(issue("ABC-21", "repo:api"), scores={"L": 1, "E": 1, "I": 1, "S": 1})
|
||||||
room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room"
|
room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room"
|
||||||
found = status.lines("ABC-12", self.home, [issue("ABC-20", "repo:api"), held], {}, (), Tmux(), ("ABC-21",))
|
found = status.lines("ABC-12", self.folder, [issue("ABC-20", "repo:api"), held], {}, (), Tmux(), ("ABC-21",))
|
||||||
self.assertEqual(found, [f"ABC-20 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-21 waits: {room}"])
|
self.assertEqual(found, [f"ABC-20 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-21 waits: {room}"])
|
||||||
# Where no issue starts by score, each starts in the tracker's rank order.
|
# Where no issue starts by score, each starts in the tracker's rank order.
|
||||||
self.assertEqual(self.lines([issue("ABC-20", "repo:api"), held]), [f"ABC-20 waits: {room}", f"ABC-21 waits: {room}"])
|
self.assertEqual(self.lines([issue("ABC-20", "repo:api"), held]), [f"ABC-20 waits: {room}", f"ABC-21 waits: {room}"])
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
usage: judge-replay <model> [--offline]
|
usage: judge-replay <model> [--offline]
|
||||||
|
|
||||||
<model> is a project model on the routing ladder this setup ships, such as claude-opus-5-5. The tool replays the
|
<model> is a project model on the routing ladder this setup ships, such as claude-opus-5-5. The tool replays the
|
||||||
verdicts archived for the projects that ~/.claude/loop-claude-models.json runs on it: the latest
|
verdicts archived for the projects that ~/.config/build-release/models.json runs on it: the latest
|
||||||
15 of each kind, finished, unfinished, interrupt and quoted answer. Where the archive kept the judge's own
|
15 of each kind, finished, unfinished, interrupt and quoted answer. Where the archive kept the judge's own
|
||||||
prompt (docs/decisions.md → `build-release: the archive keeps the raw transcript and each judge run, …`), the
|
prompt (docs/decisions.md → `build-release: the archive keeps the raw transcript and each judge run, …`), the
|
||||||
replay hands the judge that prompt, which holds what the judge read then. For a verdict from before the
|
replay hands the judge that prompt, which holds what the judge read then. For a verdict from before the
|
||||||
@@ -28,7 +28,7 @@ keeps the judge to its own model's rungs; a rung above them that misses no inter
|
|||||||
evidence to let the judge climb onto it.
|
evidence to let the judge climb onto it.
|
||||||
|
|
||||||
It keeps each run and the report it prints in build-release's archive, in
|
It keeps each run and the report it prints in build-release's archive, in
|
||||||
replays/judge-replay-<model>-<UTC stamp>/ under ~/.claude/loop-claude-transcripts or $BUILD_RELEASE_TRANSCRIPTS.
|
replays/judge-replay-<model>-<UTC stamp>/ under ~/.local/state/build-release/transcripts or $BUILD_RELEASE_TRANSCRIPTS.
|
||||||
A run's .jsonl file starts with a line holding claude's arguments, working directory, prompt, exit code and
|
A run's .jsonl file starts with a line holding claude's arguments, working directory, prompt, exit code and
|
||||||
stderr, then holds claude's stream-json output; result.md holds the report.
|
stderr, then holds claude's stream-json output; result.md holds the report.
|
||||||
|
|
||||||
@@ -48,6 +48,9 @@ fifths. The classifier trains 330 regressions in Python, about 12 minutes on 1,1
|
|||||||
kept in replays/judge-replay-<model>-offline-<UTC stamp>/result.md. A verdict whose transcript cannot be read is skipped, and the report counts the skipped. Exit 1, saying why, on bad
|
kept in replays/judge-replay-<model>-offline-<UTC stamp>/result.md. A verdict whose transcript cannot be read is skipped, and the report counts the skipped. Exit 1, saying why, on bad
|
||||||
arguments, an unreadable archive or models file, no archived verdict of the model's projects, or none with a
|
arguments, an unreadable archive or models file, no archived verdict of the model's projects, or none with a
|
||||||
transcript that can be read.
|
transcript that can be read.
|
||||||
|
|
||||||
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path.
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
@@ -93,7 +96,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
|||||||
project = arguments_or_exit(TOOL, argv, __doc__, USAGE, lambda argv: model_argument(ladder, [arg for arg in argv if arg != OFFLINE]))
|
project = arguments_or_exit(TOOL, argv, __doc__, USAGE, lambda argv: model_argument(ladder, [arg for arg in argv if arg != OFFLINE]))
|
||||||
if isinstance(project, int):
|
if isinstance(project, int):
|
||||||
return project
|
return project
|
||||||
cases = archived_cases(project.rung.model, archive_root(home, env), home)
|
cases = archived_cases(project.rung.model, archive_root(home, env), home, env)
|
||||||
if isinstance(cases, Failure):
|
if isinstance(cases, Failure):
|
||||||
return failed(TOOL, cases.reason)
|
return failed(TOOL, cases.reason)
|
||||||
if not cases:
|
if not cases:
|
||||||
@@ -105,7 +108,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
|||||||
effects = archiving(effects, folder, say)
|
effects = archiving(effects, folder, say)
|
||||||
reference = Rung(project.rung.model, REFERENCE_EFFORT)
|
reference = Rung(project.rung.model, REFERENCE_EFFORT)
|
||||||
# The candidates stop at the lowest rung a worker routes to: no route uses a rung below it for the judge.
|
# The candidates stop at the lowest rung a worker routes to: no route uses a rung below it for the judge.
|
||||||
replay = replayed(cases, reference, down_from(ladder, project.rung, project.lowest_worker_rung()), lambda found, rung: rule(found, rung, home, effects), reproduced, "verdicts", say, AT_ONCE, climbs(project, reference))
|
replay = replayed(cases, reference, down_from(ladder, project.rung, project.lowest_worker_rung()), lambda found, rung: rule(found, rung, home, env, effects), reproduced, "verdicts", say, AT_ONCE, climbs(project, reference))
|
||||||
if isinstance(replay, Limited):
|
if isinstance(replay, Limited):
|
||||||
return limited_exit(TOOL, replay)
|
return limited_exit(TOOL, replay)
|
||||||
print_report(folder, report(project.rung.model, reference, cases, replay))
|
print_report(folder, report(project.rung.model, reference, cases, replay))
|
||||||
@@ -138,8 +141,8 @@ def climbs(project: ProjectRung, reference: Rung) -> list[Rung]:
|
|||||||
return sorted({project.review_floor(score) for score in REVIEW_STEPS} - {project.rung, reference}, key=project.ladder.position)
|
return sorted({project.review_floor(score) for score in REVIEW_STEPS} - {project.rung, reference}, key=project.ladder.position)
|
||||||
|
|
||||||
|
|
||||||
def archived_cases(model: str, root: pathlib.Path, home: pathlib.Path) -> list[Case] | Failure:
|
def archived_cases(model: str, root: pathlib.Path, home: pathlib.Path, env: typing.Mapping[str, str]) -> list[Case] | Failure:
|
||||||
projects = projects_on(model, home)
|
projects = projects_on(model, home, env)
|
||||||
if isinstance(projects, Failure):
|
if isinstance(projects, Failure):
|
||||||
return projects
|
return projects
|
||||||
listed = archived_outcomes(root)
|
listed = archived_outcomes(root)
|
||||||
@@ -155,7 +158,7 @@ def archived_cases(model: str, root: pathlib.Path, home: pathlib.Path) -> list[C
|
|||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
def rule(case: Case, rung: Rung, home: pathlib.Path, effects: Effects) -> Kind | Limited:
|
def rule(case: Case, rung: Rung, home: pathlib.Path, env: typing.Mapping[str, str], effects: Effects) -> Kind | Limited:
|
||||||
entries = read_transcript(str(case.transcript))
|
entries = read_transcript(str(case.transcript))
|
||||||
if isinstance(entries, Failure):
|
if isinstance(entries, Failure):
|
||||||
return verdict_kind(entries)
|
return verdict_kind(entries)
|
||||||
@@ -168,7 +171,7 @@ def rule(case: Case, rung: Rung, home: pathlib.Path, effects: Effects) -> Kind |
|
|||||||
return verdict_kind(grounds)
|
return verdict_kind(grounds)
|
||||||
verdict: Verdict | Failure | Limited = first_reply(lambda: judge_archived(case.root, kept.prompt, grounds, len(entries), rung, BUILD_RELEASE, effects))
|
verdict: Verdict | Failure | Limited = first_reply(lambda: judge_archived(case.root, kept.prompt, grounds, len(entries), rung, BUILD_RELEASE, effects))
|
||||||
return verdict if isinstance(verdict, Limited) else verdict_kind(verdict)
|
return verdict if isinstance(verdict, Limited) else verdict_kind(verdict)
|
||||||
premises, records = read_premises(case.root, home), read_records(case.root, home, home / CLAUDE_HOME)
|
premises, records = read_premises(case.root, home, env), read_records(case.root, home, env, home / CLAUDE_HOME)
|
||||||
if isinstance(premises, Failure):
|
if isinstance(premises, Failure):
|
||||||
return verdict_kind(premises)
|
return verdict_kind(premises)
|
||||||
if isinstance(records, Failure):
|
if isinstance(records, Failure):
|
||||||
|
|||||||
@@ -122,13 +122,14 @@ class Main(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||||
(self.home / ".claude").mkdir()
|
(self.home / ".claude").mkdir()
|
||||||
(self.home / ".claude" / "loop-claude-models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-sonnet-5-5"}))
|
(self.home / ".config/build-release").mkdir(parents=True)
|
||||||
|
(self.home / ".config/build-release" / "models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-sonnet-5-5"}))
|
||||||
(self.home / ".claude" / "CLAUDE.md").write_text("Be kind.\n")
|
(self.home / ".claude" / "CLAUDE.md").write_text("Be kind.\n")
|
||||||
for key, verdicts in (("proj", (FINISHED, INTERRUPTED)), ("other", (FINISHED,))):
|
for key, verdicts in (("proj", (FINISHED, INTERRUPTED)), ("other", (FINISHED,))):
|
||||||
(self.home / "code" / key).mkdir(parents=True)
|
(self.home / "code" / key).mkdir(parents=True)
|
||||||
(self.home / "code" / key / "README.md").write_text("# p\n\n## Goals\n\n1. Ship.\n\n## Audience\n\nMe.\n")
|
(self.home / "code" / key / "README.md").write_text("# p\n\n## Goals\n\n1. Ship.\n\n## Audience\n\nMe.\n")
|
||||||
configured(self, self.home / "code" / key, home=self.home)
|
configured(self, self.home / "code" / key, home=self.home)
|
||||||
chunk = self.home / ".claude" / "loop-claude-transcripts" / key / "c1"
|
chunk = self.home / ".local/state/build-release" / "transcripts" / key / "c1"
|
||||||
chunk.mkdir(parents=True)
|
chunk.mkdir(parents=True)
|
||||||
for n, verdict in enumerate(verdicts):
|
for n, verdict in enumerate(verdicts):
|
||||||
(chunk / f"t{n}.jsonl").write_text(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": f"said {verdict}"}]}}) + "\n")
|
(chunk / f"t{n}.jsonl").write_text(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": f"said {verdict}"}]}}) + "\n")
|
||||||
@@ -187,18 +188,18 @@ class Main(unittest.TestCase):
|
|||||||
self.assertEqual(self.calls, [])
|
self.assertEqual(self.calls, [])
|
||||||
self.assertIn("Replayed 2 archived verdicts of claude-opus-5-5 projects offline, without sending anything to an outside service. The archive gives them as 1 finished, 1 interrupt.", out)
|
self.assertIn("Replayed 2 archived verdicts of claude-opus-5-5 projects offline, without sending anything to an outside service. The archive gives them as 1 finished, 1 interrupt.", out)
|
||||||
self.assertIn("\"?\" rule, on the whole archive: decided 2 of 2: finished 2 (of these, archived interrupt 1). Missed interrupts: 1.", out)
|
self.assertIn("\"?\" rule, on the whole archive: decided 2 of 2: finished 2 (of these, archived interrupt 1). Missed interrupts: 1.", out)
|
||||||
folder = self.home / ".claude" / "loop-claude-transcripts" / "replays" / "judge-replay-claude-opus-5-5-offline-20260921T141320Z"
|
folder = self.home / ".local/state/build-release" / "transcripts" / "replays" / "judge-replay-claude-opus-5-5-offline-20260921T141320Z"
|
||||||
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
||||||
|
|
||||||
def test_offline_exits_1_where_no_transcript_can_be_read(self):
|
def test_offline_exits_1_where_no_transcript_can_be_read(self):
|
||||||
for path in (self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1").glob("*.jsonl"):
|
for path in (self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1").glob("*.jsonl"):
|
||||||
path.unlink()
|
path.unlink()
|
||||||
code, out, err = self.run_main(["claude-opus-5-5", "--offline"], unused)
|
code, out, err = self.run_main(["claude-opus-5-5", "--offline"], unused)
|
||||||
self.assertEqual((code, out), (1, ""))
|
self.assertEqual((code, out), (1, ""))
|
||||||
self.assertEqual(err.splitlines()[-1], "judge-replay: no archived verdict has a transcript that can be read")
|
self.assertEqual(err.splitlines()[-1], "judge-replay: no archived verdict has a transcript that can be read")
|
||||||
|
|
||||||
def test_offline_skips_each_verdict_whose_transcript_cannot_be_read_and_says_how_many_on_stderr_and_in_the_report(self):
|
def test_offline_skips_each_verdict_whose_transcript_cannot_be_read_and_says_how_many_on_stderr_and_in_the_report(self):
|
||||||
kept = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
kept = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
(kept / "t2.outcomes.md").write_text(f"Task: Do it.\n\n2026-10-14T10:00:02Z {FINISHED}\n\nEvidence:\n> e\n")
|
(kept / "t2.outcomes.md").write_text(f"Task: Do it.\n\n2026-10-14T10:00:02Z {FINISHED}\n\nEvidence:\n> e\n")
|
||||||
(kept / "t0.jsonl").unlink()
|
(kept / "t0.jsonl").unlink()
|
||||||
code, out, err = self.run_main(["claude-opus-5-5", "--offline"], unused)
|
code, out, err = self.run_main(["claude-opus-5-5", "--offline"], unused)
|
||||||
@@ -211,7 +212,7 @@ class Main(unittest.TestCase):
|
|||||||
def test_offline_keeps_its_report_in_the_same_folder_wherever_the_flag_stands(self):
|
def test_offline_keeps_its_report_in_the_same_folder_wherever_the_flag_stands(self):
|
||||||
code, out, err = self.run_main(["--offline", "claude-opus-5-5"], unused)
|
code, out, err = self.run_main(["--offline", "claude-opus-5-5"], unused)
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
folder = self.home / ".claude" / "loop-claude-transcripts" / "replays" / "judge-replay-claude-opus-5-5-offline-20260921T141320Z"
|
folder = self.home / ".local/state/build-release" / "transcripts" / "replays" / "judge-replay-claude-opus-5-5-offline-20260921T141320Z"
|
||||||
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
||||||
|
|
||||||
def test_offline_says_the_usage_on_arguments_that_name_no_model(self):
|
def test_offline_says_the_usage_on_arguments_that_name_no_model(self):
|
||||||
@@ -222,13 +223,13 @@ class Main(unittest.TestCase):
|
|||||||
def test_keeps_each_run_and_the_printed_report_in_one_folder_of_the_archive_beside_the_projects(self):
|
def test_keeps_each_run_and_the_printed_report_in_one_folder_of_the_archive_beside_the_projects(self):
|
||||||
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
folder = self.home / ".claude" / "loop-claude-transcripts" / "replays" / "judge-replay-claude-opus-5-5-20260921T141320Z"
|
folder = self.home / ".local/state/build-release" / "transcripts" / "replays" / "judge-replay-claude-opus-5-5-20260921T141320Z"
|
||||||
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
||||||
runs = [json.loads(path.read_text(encoding="utf-8").splitlines()[0]) for path in folder.glob("*.jsonl")]
|
runs = [json.loads(path.read_text(encoding="utf-8").splitlines()[0]) for path in folder.glob("*.jsonl")]
|
||||||
self.assertEqual({run["prompt"] for run in runs}, set(self.prompts))
|
self.assertEqual({run["prompt"] for run in runs}, set(self.prompts))
|
||||||
|
|
||||||
def test_says_where_it_could_not_keep_a_run_and_still_prints_the_report(self):
|
def test_says_where_it_could_not_keep_a_run_and_still_prints_the_report(self):
|
||||||
replays = self.home / ".claude" / "loop-claude-transcripts" / "replays"
|
replays = self.home / ".local/state/build-release" / "transcripts" / "replays"
|
||||||
replays.write_text("")
|
replays.write_text("")
|
||||||
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
@@ -241,7 +242,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertEqual(err.splitlines()[:2], ["replaying 2 verdicts on claude-opus-5-5 at xhigh effort", "replaying 2 verdicts on claude-fable-5-2 at low effort"])
|
self.assertEqual(err.splitlines()[:2], ["replaying 2 verdicts on claude-opus-5-5 at xhigh effort", "replaying 2 verdicts on claude-fable-5-2 at low effort"])
|
||||||
|
|
||||||
def test_replays_four_verdicts_at_once(self):
|
def test_replays_four_verdicts_at_once(self):
|
||||||
chunk = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
chunk = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
for n in range(2, 8):
|
for n in range(2, 8):
|
||||||
(chunk / f"t{n}.jsonl").write_text(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": f"said {FINISHED} {n}"}]}}) + "\n")
|
(chunk / f"t{n}.jsonl").write_text(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": f"said {FINISHED} {n}"}]}}) + "\n")
|
||||||
(chunk / f"t{n}.outcomes.md").write_text(f"Task: Do it.\n\n2026-10-14T10:00:0{n}Z {FINISHED}\n\nEvidence:\n> e\n")
|
(chunk / f"t{n}.outcomes.md").write_text(f"Task: Do it.\n\n2026-10-14T10:00:0{n}Z {FINISHED}\n\nEvidence:\n> e\n")
|
||||||
@@ -267,7 +268,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertNotIn("None", schema)
|
self.assertNotIn("None", schema)
|
||||||
|
|
||||||
def test_hands_the_judge_the_prompt_the_archive_kept_and_rebuilds_the_prompt_of_a_verdict_with_none(self):
|
def test_hands_the_judge_the_prompt_the_archive_kept_and_rebuilds_the_prompt_of_a_verdict_with_none(self):
|
||||||
kept = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
kept = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
prompt = "From the goals file, OLD premises\n\nThe records: none\n\nThe task the worker was given:\nDo it.\n\nWhat the worker did and said, what the human typed on [human] lines and what build-release told it on [loop] lines, latest last:\nsaid Verdict: finished\n\nOLD rules"
|
prompt = "From the goals file, OLD premises\n\nThe records: none\n\nThe task the worker was given:\nDo it.\n\nWhat the worker did and said, what the human typed on [human] lines and what build-release told it on [loop] lines, latest last:\nsaid Verdict: finished\n\nOLD rules"
|
||||||
(kept / "judge").mkdir()
|
(kept / "judge").mkdir()
|
||||||
(kept / "judge" / "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json").write_text(json.dumps({"prompt": prompt, "reply": {"type": "result"}}))
|
(kept / "judge" / "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json").write_text(json.dumps({"prompt": prompt, "reply": {"type": "result"}}))
|
||||||
@@ -285,7 +286,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertIn("1. Ship.", self.prompts[1])
|
self.assertIn("1. Ship.", self.prompts[1])
|
||||||
|
|
||||||
def test_a_verdict_whose_archived_judge_run_cannot_be_read_replays_as_failed(self):
|
def test_a_verdict_whose_archived_judge_run_cannot_be_read_replays_as_failed(self):
|
||||||
kept = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
kept = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
(kept / "t0.outcomes.md").write_text("Task: Do it.\n\n2026-10-14T10:00:00Z Verdict: finished\n\nJudge: j\nJudge run: judge/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.json\nWorker: x\n")
|
(kept / "t0.outcomes.md").write_text("Task: Do it.\n\n2026-10-14T10:00:00Z Verdict: finished\n\nJudge: j\nJudge run: judge/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.json\nWorker: x\n")
|
||||||
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
@@ -299,7 +300,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertTrue(out.endswith("returns every verdict the reference judge reproduces: claude-sonnet-5-5 at high effort\n"), out)
|
self.assertTrue(out.endswith("returns every verdict the reference judge reproduces: claude-sonnet-5-5 at high effort\n"), out)
|
||||||
|
|
||||||
def test_a_fable_project_tries_no_rung_below_opus_at_medium_and_its_report_names_fable(self):
|
def test_a_fable_project_tries_no_rung_below_opus_at_medium_and_its_report_names_fable(self):
|
||||||
(self.home / ".claude" / "loop-claude-models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-fable-5-2"}))
|
(self.home / ".config/build-release" / "models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-fable-5-2"}))
|
||||||
code, out, err = self.run_main(["claude-fable-5-2"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
code, out, err = self.run_main(["claude-fable-5-2"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertEqual([(model, effort) for model, effort, _ in self.calls][-1], ("claude-opus-5-5", "medium"))
|
self.assertEqual([(model, effort) for model, effort, _ in self.calls][-1], ("claude-opus-5-5", "medium"))
|
||||||
@@ -314,13 +315,13 @@ class Main(unittest.TestCase):
|
|||||||
self.assertTrue(out.endswith(": none, the project's rung misses one\n"))
|
self.assertTrue(out.endswith(": none, the project's rung misses one\n"))
|
||||||
|
|
||||||
def test_replays_a_verdict_whose_transcript_is_gone_as_failed(self):
|
def test_replays_a_verdict_whose_transcript_is_gone_as_failed(self):
|
||||||
(self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1" / "t0.jsonl").unlink()
|
(self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1" / "t0.jsonl").unlink()
|
||||||
code, out, _ = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED}"))
|
code, out, _ = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED}"))
|
||||||
self.assertEqual(code, 0)
|
self.assertEqual(code, 0)
|
||||||
self.assertIn("replayed failed: could not read the transcript", out)
|
self.assertIn("replayed failed: could not read the transcript", out)
|
||||||
|
|
||||||
def test_replays_a_verdict_whose_transcript_is_compressed(self):
|
def test_replays_a_verdict_whose_transcript_is_compressed(self):
|
||||||
self.assertIsNone(compress(self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1" / "t0.jsonl"))
|
self.assertIsNone(compress(self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1" / "t0.jsonl"))
|
||||||
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertNotIn("replayed failed", out)
|
self.assertNotIn("replayed failed", out)
|
||||||
@@ -352,7 +353,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertIn("no archived verdicts of projects on claude-fable-5-2", err)
|
self.assertIn("no archived verdicts of projects on claude-fable-5-2", err)
|
||||||
|
|
||||||
def test_exits_1_on_an_unreadable_models_file(self):
|
def test_exits_1_on_an_unreadable_models_file(self):
|
||||||
(self.home / ".claude" / "loop-claude-models.json").write_text("[")
|
(self.home / ".config/build-release" / "models.json").write_text("[")
|
||||||
self.assertEqual(self.run_main(["claude-opus-5-5"], unused)[0], 1)
|
self.assertEqual(self.run_main(["claude-opus-5-5"], unused)[0], 1)
|
||||||
|
|
||||||
def test_prints_the_help(self):
|
def test_prints_the_help(self):
|
||||||
@@ -365,7 +366,7 @@ class Main(unittest.TestCase):
|
|||||||
self.assertIn("usage: judge-replay <model>", ran.stdout)
|
self.assertIn("usage: judge-replay <model>", ran.stdout)
|
||||||
|
|
||||||
def test_exits_1_on_a_usage_limit_met_on_an_archived_prompt(self):
|
def test_exits_1_on_a_usage_limit_met_on_an_archived_prompt(self):
|
||||||
kept = self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1"
|
kept = self.home / ".local/state/build-release" / "transcripts" / "proj" / "c1"
|
||||||
(kept / "judge").mkdir()
|
(kept / "judge").mkdir()
|
||||||
(kept / "judge" / "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json").write_text(json.dumps({"prompt": "P", "reply": {}}))
|
(kept / "judge" / "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json").write_text(json.dumps({"prompt": "P", "reply": {}}))
|
||||||
(kept / "t0.outcomes.md").write_text("Task: Do it.\n\n2026-10-14T10:00:00Z Verdict: finished\n\nJudge: j\nJudge run: judge/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\nWorker: x\n")
|
(kept / "t0.outcomes.md").write_text("Task: Do it.\n\n2026-10-14T10:00:00Z Verdict: finished\n\nJudge: j\nJudge run: judge/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\nWorker: x\n")
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
@@ -7,11 +8,11 @@ from project_config.main import located
|
|||||||
from record_store.stores import store
|
from record_store.stores import store
|
||||||
|
|
||||||
|
|
||||||
def history_changes(default: str, home: pathlib.Path) -> list[HistoryChange] | Failure:
|
def history_changes(default: str, home: pathlib.Path, env: Mapping[str, str]) -> list[HistoryChange] | Failure:
|
||||||
"""Each merged change on the default branch that touched the history, newest first. A Failure where no commit holds the history, as for one the project's config puts outside the checkout."""
|
"""Each merged change on the default branch that touched the history, newest first. A Failure where no commit holds the history, as for one the project's config puts outside the checkout."""
|
||||||
if partial := full_history():
|
if partial := full_history():
|
||||||
return partial
|
return partial
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
record = store(config, "comprehension-history")
|
record = store(config, "comprehension-history")
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ from larv_review.scoring_setup import removed_setup
|
|||||||
Say = typing.Callable[[str], None]
|
Say = typing.Callable[[str], None]
|
||||||
|
|
||||||
|
|
||||||
def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, now: float) -> str | Failure:
|
def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> str | Failure:
|
||||||
"""Records the ruling the votes file's seats reach, and returns what the tool prints: the ruling and where it went, or which seats to launch where they split."""
|
"""Records the ruling the votes file's seats reach, and returns what the tool prints: the ruling and where it went, or which seats to launch where they split."""
|
||||||
read = read_seats(votes_file, True, home, now)
|
read = read_seats(votes_file, True, home, env, now)
|
||||||
if isinstance(read, Failure):
|
if isinstance(read, Failure):
|
||||||
return read
|
return read
|
||||||
heading_read, seats_read = read
|
heading_read, seats_read = read
|
||||||
@@ -35,25 +35,25 @@ def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, now: float) -> s
|
|||||||
if split(overall_votes):
|
if split(overall_votes):
|
||||||
return f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the votes file, and run this again."
|
return f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the votes file, and run this again."
|
||||||
ruled = ruling(overall_votes)
|
ruled = ruling(overall_votes)
|
||||||
appended_to = append(seats_read.read, ruling_entry(heading_read.title, seats_read.seats, written, counts, ruled), home)
|
appended_to = append(seats_read.read, ruling_entry(heading_read.title, seats_read.seats, written, counts, ruled), home, env)
|
||||||
return appended_to if isinstance(appended_to, Failure) else f"Ruling: {ruled}. Overall votes as counted: {tally}.\n{appended_to}"
|
return appended_to if isinstance(appended_to, Failure) else f"Ruling: {ruled}. Overall votes as counted: {tally}.\n{appended_to}"
|
||||||
|
|
||||||
|
|
||||||
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home: pathlib.Path, now: float, say: Say, warn: Say) -> Failure | None:
|
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home: pathlib.Path, env: typing.Mapping[str, str], now: float, say: Say, warn: Say) -> Failure | None:
|
||||||
"""Records the scoring run the scores file holds in the comprehension history, and ranks the plan again. It says each result as soon as it has it, since a later step may fail after the run is recorded."""
|
"""Records the scoring run the scores file holds in the comprehension history, and ranks the plan again. It says each result as soon as it has it, since a later step may fail after the run is recorded."""
|
||||||
read = read_seats(scores_file, False, home, now)
|
read = read_seats(scores_file, False, home, env, now)
|
||||||
if isinstance(read, Failure):
|
if isinstance(read, Failure):
|
||||||
return read
|
return read
|
||||||
named, given = read
|
named, given = read
|
||||||
scoring = scored_seats(given)
|
scoring = scored_seats(given)
|
||||||
if isinstance(scoring, Failure):
|
if isinstance(scoring, Failure):
|
||||||
return scoring
|
return scoring
|
||||||
reasons = plan_reasons(default, ids, home)
|
reasons = plan_reasons(default, ids, home, env)
|
||||||
if isinstance(reasons, Failure):
|
if isinstance(reasons, Failure):
|
||||||
return reasons
|
return reasons
|
||||||
if not reasons:
|
if not reasons:
|
||||||
return Failure("no plan item or release calls this scoring run; name the item IDs the chunk ships, as needs-scoring-run took them")
|
return Failure("no plan item or release calls this scoring run; name the item IDs the chunk ships, as needs-scoring-run took them")
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
checkout = str(config.top)
|
checkout = str(config.top)
|
||||||
@@ -61,7 +61,7 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home
|
|||||||
if isinstance(todo, Failure):
|
if isinstance(todo, Failure):
|
||||||
return todo
|
return todo
|
||||||
plan = todo.items
|
plan = todo.items
|
||||||
appended_to = append(given.read, scoring_entry(named.title, scoring), home)
|
appended_to = append(given.read, scoring_entry(named.title, scoring), home, env)
|
||||||
if isinstance(appended_to, Failure):
|
if isinstance(appended_to, Failure):
|
||||||
return appended_to
|
return appended_to
|
||||||
say(appended_to)
|
say(appended_to)
|
||||||
@@ -70,14 +70,14 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home
|
|||||||
say(f"Floor: {', '.join(under)} under the floor of {config.readability_floor}.")
|
say(f"Floor: {', '.join(under)} under the floor of {config.readability_floor}.")
|
||||||
if step := floor_step(scoring.means, plan, ids, config.readability_floor):
|
if step := floor_step(scoring.means, plan, ids, config.readability_floor):
|
||||||
say(step)
|
say(step)
|
||||||
reranked = rerank(home, warn)
|
reranked = rerank(home, env, warn)
|
||||||
removed = removed_setup(checkout, home)
|
removed = removed_setup(checkout, home, env)
|
||||||
return reranked or (removed and Failure(f"recorded the run, but {removed.reason}"))
|
return reranked or (removed and Failure(f"recorded the run, but {removed.reason}"))
|
||||||
|
|
||||||
|
|
||||||
def rerank(home: pathlib.Path, warn: Say) -> Failure | None:
|
def rerank(home: pathlib.Path, env: typing.Mapping[str, str], warn: Say) -> Failure | None:
|
||||||
"""Rank the project's todo.md again as rank_todo.py does, since the overall sets code health's weight, and fail where rank_todo.py would. The run stays recorded whatever happens, so those failures say to settle todo.md and run rank_todo.py on it, not to record the run again."""
|
"""Rank the project's todo.md again as rank_todo.py does, since the overall sets code health's weight, and fail where rank_todo.py would. The run stays recorded whatever happens, so those failures say to settle todo.md and run rank_todo.py on it, not to record the run again."""
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
todo = config.plan_file
|
todo = config.plan_file
|
||||||
@@ -102,13 +102,13 @@ def scored_seats(given: SeatsFile) -> ScoringRun | Failure:
|
|||||||
return ScoringRun(given.seats, found, means(list(found.values())))
|
return ScoringRun(given.seats, found, means(list(found.values())))
|
||||||
|
|
||||||
|
|
||||||
def read_seats(path: pathlib.Path, paired: bool, home: pathlib.Path, now: float) -> tuple[Heading, SeatsFile] | Failure:
|
def read_seats(path: pathlib.Path, paired: bool, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> tuple[Heading, SeatsFile] | Failure:
|
||||||
"""The heading the seats file's entry goes under, and the file, as decided says. Its callers run it first, so a file it refuses fails before anything is printed."""
|
"""The heading the seats file's entry goes under, and the file, as decided says. Its callers run it first, so a file it refuses fails before anything is printed."""
|
||||||
try:
|
try:
|
||||||
text = path.read_text(encoding="utf-8")
|
text = path.read_text(encoding="utf-8")
|
||||||
except (OSError, UnicodeDecodeError) as failure:
|
except (OSError, UnicodeDecodeError) as failure:
|
||||||
return Failure(f"could not read {path}: {failure}")
|
return Failure(f"could not read {path}: {failure}")
|
||||||
history = history_file(home)
|
history = history_file(home, env)
|
||||||
if isinstance(history, Failure):
|
if isinstance(history, Failure):
|
||||||
return history
|
return history
|
||||||
return decided(text, now, paired, commit_exists, history)
|
return decided(text, now, paired, commit_exists, history)
|
||||||
@@ -129,8 +129,8 @@ def decided(text: str, now: float, paired: bool, commit_known: typing.Callable[[
|
|||||||
return named, given
|
return named, given
|
||||||
|
|
||||||
|
|
||||||
def read_places(home: pathlib.Path) -> str | Failure:
|
def read_places(home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||||
history = history_file(home)
|
history = history_file(home, env)
|
||||||
return history if isinstance(history, Failure) else places_report(history[1])
|
return history if isinstance(history, Failure) else places_report(history[1])
|
||||||
|
|
||||||
|
|
||||||
@@ -139,20 +139,20 @@ def places_report(history: str) -> str:
|
|||||||
return (latest_places(history) or "Seats found no places hard.").rstrip("\n")
|
return (latest_places(history) or "Seats found no places hard.").rstrip("\n")
|
||||||
|
|
||||||
|
|
||||||
def read_agreement(home: pathlib.Path) -> str | Failure:
|
def read_agreement(home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||||
history = history_file(home)
|
history = history_file(home, env)
|
||||||
return history if isinstance(history, Failure) else agreement_report(history[1])
|
return history if isinstance(history, Failure) else agreement_report(history[1])
|
||||||
|
|
||||||
|
|
||||||
def history_file(home: pathlib.Path) -> tuple[RecordStore, str] | Failure:
|
def history_file(home: pathlib.Path, env: typing.Mapping[str, str]) -> tuple[RecordStore, str] | Failure:
|
||||||
"""The store the project's config names for its comprehension history, and the history's text, empty where there is none yet."""
|
"""The store the project's config names for its comprehension history, and the history's text, empty where there is none yet."""
|
||||||
held = held_history(home)
|
held = held_history(home, env)
|
||||||
return held if isinstance(held, Failure) else (held[0], held[1].text)
|
return held if isinstance(held, Failure) else (held[0], held[1].text)
|
||||||
|
|
||||||
|
|
||||||
def held_history(home: pathlib.Path) -> tuple[RecordStore, Held] | Failure:
|
def held_history(home: pathlib.Path, env: typing.Mapping[str, str]) -> tuple[RecordStore, Held] | Failure:
|
||||||
"""The store the project's config names for its comprehension history, and the history as it stands, with the version a write over it names."""
|
"""The store the project's config names for its comprehension history, and the history as it stands, with the version a write over it names."""
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
history = store(config, "comprehension-history")
|
history = store(config, "comprehension-history")
|
||||||
@@ -160,9 +160,9 @@ def held_history(home: pathlib.Path) -> tuple[RecordStore, Held] | Failure:
|
|||||||
return held if isinstance(held, Failure) else (history, held)
|
return held if isinstance(held, Failure) else (history, held)
|
||||||
|
|
||||||
|
|
||||||
def append(read: str, entry: str, home: pathlib.Path) -> str | Failure:
|
def append(read: str, entry: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||||
"""Appends entry and returns the line the tool prints; a Failure where the history already holds an entry on what the seats read."""
|
"""Appends entry and returns the line the tool prints; a Failure where the history already holds an entry on what the seats read."""
|
||||||
read_history = held_history(home)
|
read_history = held_history(home, env)
|
||||||
return read_history if isinstance(read_history, Failure) else appended_to(*read_history, read, entry)
|
return read_history if isinstance(read_history, Failure) else appended_to(*read_history, read, entry)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+23
-20
@@ -15,8 +15,8 @@ stderr; the other four exit 1.
|
|||||||
The history is docs/comprehension-history.md in the checkout.
|
The history is docs/comprehension-history.md in the checkout.
|
||||||
|
|
||||||
review-folder makes the chunk's review folder, where each reviewer writes its report, and prints its
|
review-folder makes the chunk's review folder, where each reviewer writes its report, and prints its
|
||||||
path: ~/.local/state/larv-review/ followed by the worktree's path relative to ~, or to / outside it.
|
path: ~/.local/state/build-release/larv-review/ followed by the worktree's path relative to ~, or to / outside it.
|
||||||
It leaves ~/.local/state/larv-review readable by you alone.
|
It leaves ~/.local/state/build-release/larv-review readable by you alone.
|
||||||
|
|
||||||
ruling-base prints the commit a paired ruling reads against, then which of these found it. The last
|
ruling-base prints the commit a paired ruling reads against, then which of these found it. The last
|
||||||
measured commit is the default branch's newest merged change that adds a paired ruling or a scoring
|
measured commit is the default branch's newest merged change that adds a paired ruling or a scoring
|
||||||
@@ -164,7 +164,10 @@ breaks the shape above, a todo.md that fails rank_todo.py after record-scoring r
|
|||||||
when git cannot start, finds no checkout or no default branch, cannot fetch origin for ruling-base,
|
when git cannot start, finds no checkout or no default branch, cannot fetch origin for ruling-base,
|
||||||
needs-scoring-run, scoring-run-owed or record-scoring, or cannot read or write the history, todo.md, the review
|
needs-scoring-run, scoring-run-owed or record-scoring, or cannot read or write the history, todo.md, the review
|
||||||
folder or a file prepare-scoring reads.
|
folder or a file prepare-scoring reads.
|
||||||
|
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@@ -209,11 +212,11 @@ def are_ids(given: list[str]) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def run_needs_scoring_run(given: list[str]) -> Failure | None:
|
def run_needs_scoring_run(given: list[str]) -> Failure | None:
|
||||||
return with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given], pathlib.Path.home()), stale_ok=False)
|
return with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given], pathlib.Path.home(), os.environ), stale_ok=False)
|
||||||
|
|
||||||
|
|
||||||
def run_record_scoring(given: list[str]) -> Failure | None:
|
def run_record_scoring(given: list[str]) -> Failure | None:
|
||||||
return with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]], pathlib.Path.home(), time.time(), print, warn), stale_ok=False)
|
return with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]], pathlib.Path.home(), os.environ, time.time(), print, warn), stale_ok=False)
|
||||||
|
|
||||||
|
|
||||||
def fits_reviewer_header(given: list[str]) -> bool:
|
def fits_reviewer_header(given: list[str]) -> bool:
|
||||||
@@ -221,23 +224,23 @@ def fits_reviewer_header(given: list[str]) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def run_reviewer_header(given: list[str]) -> Failure | None:
|
def run_reviewer_header(given: list[str]) -> Failure | None:
|
||||||
return with_default_branch(lambda default: printed(reviewer_header(default, given[0], given[1:] == ["--rerun"], pathlib.Path.home())), stale_ok=True)
|
return with_default_branch(lambda default: printed(reviewer_header(default, given[0], given[1:] == ["--rerun"], pathlib.Path.home(), os.environ)), stale_ok=True)
|
||||||
|
|
||||||
|
|
||||||
# One row per subcommand: main, USAGE and `--help` all read this table.
|
# One row per subcommand: main, USAGE and `--help` all read this table.
|
||||||
COMMANDS = {
|
COMMANDS = {
|
||||||
"review-folder": Command("review-folder", no_arguments, lambda given: make_review_folder()),
|
"review-folder": Command("review-folder", no_arguments, lambda given: make_review_folder()),
|
||||||
"ruling-base": Command("ruling-base", no_arguments, lambda given: with_default_branch(lambda default: show_ruling_base(default, pathlib.Path.home()), stale_ok=False)),
|
"ruling-base": Command("ruling-base", no_arguments, lambda given: with_default_branch(lambda default: show_ruling_base(default, pathlib.Path.home(), os.environ), stale_ok=False)),
|
||||||
"round-count": Command("round-count", no_arguments, lambda given: with_default_branch(round_count, stale_ok=True)),
|
"round-count": Command("round-count", no_arguments, lambda given: with_default_branch(round_count, stale_ok=True)),
|
||||||
"needs-scoring-run": Command("needs-scoring-run [<item ID>...]", are_ids, run_needs_scoring_run, ids_from=0),
|
"needs-scoring-run": Command("needs-scoring-run [<item ID>...]", are_ids, run_needs_scoring_run, ids_from=0),
|
||||||
"scoring-run-owed": Command("scoring-run-owed", no_arguments, lambda given: with_default_branch(lambda default: owed(default, pathlib.Path.home()), stale_ok=False)),
|
"scoring-run-owed": Command("scoring-run-owed", no_arguments, lambda given: with_default_branch(lambda default: owed(default, pathlib.Path.home(), os.environ), stale_ok=False)),
|
||||||
"record-ruling": Command("record-ruling <votes file>", lambda given: len(given) == 1, lambda given: printed(record_ruling(pathlib.Path(given[0]), pathlib.Path.home(), time.time()))),
|
"record-ruling": Command("record-ruling <votes file>", lambda given: len(given) == 1, lambda given: printed(record_ruling(pathlib.Path(given[0]), pathlib.Path.home(), os.environ, time.time()))),
|
||||||
"prepare-scoring": Command("prepare-scoring", no_arguments, lambda given: prepared_scoring()),
|
"prepare-scoring": Command("prepare-scoring", no_arguments, lambda given: prepared_scoring()),
|
||||||
"record-scoring": Command("record-scoring <scores file> [<item ID>...]", lambda given: bool(given) and are_ids(given[1:]), run_record_scoring, ids_from=1),
|
"record-scoring": Command("record-scoring <scores file> [<item ID>...]", lambda given: bool(given) and are_ids(given[1:]), run_record_scoring, ids_from=1),
|
||||||
"places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home()))),
|
"places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home(), os.environ))),
|
||||||
"agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home()))),
|
"agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home(), os.environ))),
|
||||||
"reviewer-header": Command("reviewer-header <pass> [--rerun]", fits_reviewer_header, run_reviewer_header),
|
"reviewer-header": Command("reviewer-header <pass> [--rerun]", fits_reviewer_header, run_reviewer_header),
|
||||||
"round-title": Command("round-title <pass>", lambda given: len(given) == 1 and given[0] in REVIEWERS, lambda given: with_default_branch(lambda default: printed(round_title(default, given[0], pathlib.Path.home())), stale_ok=True)),
|
"round-title": Command("round-title <pass>", lambda given: len(given) == 1 and given[0] in REVIEWERS, lambda given: with_default_branch(lambda default: printed(round_title(default, given[0], pathlib.Path.home(), os.environ)), stale_ok=True)),
|
||||||
"reviewer-context": Command("reviewer-context", no_arguments, lambda given: printed(hook_reply(sys.stdin.read(), pathlib.Path.home()))),
|
"reviewer-context": Command("reviewer-context", no_arguments, lambda given: printed(hook_reply(sys.stdin.read(), pathlib.Path.home()))),
|
||||||
}
|
}
|
||||||
SHAPES = " | ".join(command.shape for command in COMMANDS.values())
|
SHAPES = " | ".join(command.shape for command in COMMANDS.values())
|
||||||
@@ -291,22 +294,22 @@ def with_default_branch(command: typing.Callable[[str], Failure | None], stale_o
|
|||||||
|
|
||||||
def prepared_scoring() -> Failure | None:
|
def prepared_scoring() -> Failure | None:
|
||||||
worktree = top()
|
worktree = top()
|
||||||
return worktree if isinstance(worktree, Failure) else printed(prepare_scoring(worktree, pathlib.Path.home()))
|
return worktree if isinstance(worktree, Failure) else printed(prepare_scoring(worktree, pathlib.Path.home(), os.environ))
|
||||||
|
|
||||||
|
|
||||||
def make_review_folder() -> Failure | None:
|
def make_review_folder() -> Failure | None:
|
||||||
worktree = top()
|
worktree = top()
|
||||||
if isinstance(worktree, Failure):
|
if isinstance(worktree, Failure):
|
||||||
return worktree
|
return worktree
|
||||||
folder = made_review_folder(worktree, pathlib.Path.home())
|
folder = made_review_folder(worktree, pathlib.Path.home(), os.environ)
|
||||||
if isinstance(folder, Failure):
|
if isinstance(folder, Failure):
|
||||||
return folder
|
return folder
|
||||||
print(folder)
|
print(folder)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def show_ruling_base(default: str, home: pathlib.Path) -> Failure | None:
|
def show_ruling_base(default: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
|
||||||
changes = history_changes(default, home)
|
changes = history_changes(default, home, env)
|
||||||
if isinstance(changes, Failure):
|
if isinstance(changes, Failure):
|
||||||
return changes
|
return changes
|
||||||
if found := measured_commit(changes):
|
if found := measured_commit(changes):
|
||||||
@@ -320,7 +323,7 @@ def show_ruling_base(default: str, home: pathlib.Path) -> Failure | None:
|
|||||||
|
|
||||||
|
|
||||||
def round_count(default: str) -> Failure | None:
|
def round_count(default: str) -> Failure | None:
|
||||||
summaries = branch_summaries(default, pathlib.Path.home())
|
summaries = branch_summaries(default, pathlib.Path.home(), os.environ)
|
||||||
if isinstance(summaries, Failure):
|
if isinstance(summaries, Failure):
|
||||||
return summaries
|
return summaries
|
||||||
for name, count in round_counts(summaries).items():
|
for name, count in round_counts(summaries).items():
|
||||||
@@ -334,15 +337,15 @@ def cap_note(count: int, most: int) -> str:
|
|||||||
return f", {'at' if count == most else 'past'} the cap: no more rounds"
|
return f", {'at' if count == most else 'past'} the cap: no more rounds"
|
||||||
|
|
||||||
|
|
||||||
def owed(default: str, home: pathlib.Path) -> Failure | None:
|
def owed(default: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
|
||||||
unrecorded = owed_scoring_run(default, home, warn)
|
unrecorded = owed_scoring_run(default, home, env, warn)
|
||||||
if unrecorded is None:
|
if unrecorded is None:
|
||||||
print("No scoring run owed.")
|
print("No scoring run owed.")
|
||||||
return unrecorded
|
return unrecorded
|
||||||
|
|
||||||
|
|
||||||
def needs_scoring_run(default: str, ids: list[int], home: pathlib.Path) -> Failure | None:
|
def needs_scoring_run(default: str, ids: list[int], home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
|
||||||
reasons = plan_reasons(default, ids, home)
|
reasons = plan_reasons(default, ids, home, env)
|
||||||
if isinstance(reasons, Failure):
|
if isinstance(reasons, Failure):
|
||||||
return reasons
|
return reasons
|
||||||
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
|
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ from plan_store.plans import PlanStore
|
|||||||
from record_store.stores import store
|
from record_store.stores import store
|
||||||
|
|
||||||
|
|
||||||
def owed_scoring_run(default: str, home: pathlib.Path, warn: typing.Callable[[str], None]) -> Failure | None:
|
def owed_scoring_run(default: str, home: pathlib.Path, env: typing.Mapping[str, str], warn: typing.Callable[[str], None]) -> Failure | None:
|
||||||
"""A Failure saying which scoring runs the chunk owes and has not recorded; None where it owes none.
|
"""A Failure saying which scoring runs the chunk owes and has not recorded; None where it owes none.
|
||||||
|
|
||||||
The chunk owes the runs `plan_reasons` calls, two where it empties a release, else one. It has recorded the scoring runs its committed history holds beyond those at the merge base, so a default branch that has moved on since the branch began doesn't count. A project with no plan owes none. Neither does one whose plan or history is outside the checkout: it warns that it cannot tell. A missing run blocks the merge and a low score never does, which keeps the decision `review: the comprehension check records …`: it bars only scores from blocking.
|
The chunk owes the runs `plan_reasons` calls, two where it empties a release, else one. It has recorded the scoring runs its committed history holds beyond those at the merge base, so a default branch that has moved on since the branch began doesn't count. A project with no plan owes none. Neither does one whose plan or history is outside the checkout: it warns that it cannot tell. A missing run blocks the merge and a low score never does, which keeps the decision `review: the comprehension check records …`: it bars only scores from blocking.
|
||||||
"""
|
"""
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
checkout = str(config.top)
|
checkout = str(config.top)
|
||||||
@@ -33,7 +33,7 @@ def owed_scoring_run(default: str, home: pathlib.Path, warn: typing.Callable[[st
|
|||||||
base = git("merge-base", default, "HEAD", cwd=checkout)
|
base = git("merge-base", default, "HEAD", cwd=checkout)
|
||||||
if isinstance(base, Failure):
|
if isinstance(base, Failure):
|
||||||
return base
|
return base
|
||||||
reasons = plan_reasons(base.strip(), None, home)
|
reasons = plan_reasons(base.strip(), None, home, env)
|
||||||
if isinstance(reasons, Failure):
|
if isinstance(reasons, Failure):
|
||||||
return reasons
|
return reasons
|
||||||
if not reasons:
|
if not reasons:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""reviewer-header: write the branch diff, the places and the plan into the chunk's review folder, and print the header of a reviewer's prompt."""
|
"""reviewer-header: write the branch diff, the places and the plan into the chunk's review folder, and print the header of a reviewer's prompt."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from git_cli.git_repo import branch_titles, git, top
|
from git_cli.git_repo import branch_titles, git, top
|
||||||
@@ -80,18 +81,18 @@ def unanswered_round(titles: list[str], pass_: str) -> int | Failure:
|
|||||||
return done + 1
|
return done + 1
|
||||||
|
|
||||||
|
|
||||||
def branch_summaries(default: str, home: pathlib.Path) -> list[str] | Failure:
|
def branch_summaries(default: str, home: pathlib.Path, env: Mapping[str, str]) -> list[str] | Failure:
|
||||||
"""The branch's commit titles since default, each read as its summary in the project's title templates, so round titles count under any template. rule-hook's round-cap reads them its own way: guarded, and counting zero rounds where git fails."""
|
"""The branch's commit titles since default, each read as its summary in the project's title templates, so round titles count under any template. rule-hook's round-cap reads them its own way: guarded, and counting zero rounds where git fails."""
|
||||||
titles = branch_titles(default)
|
titles = branch_titles(default)
|
||||||
if isinstance(titles, Failure):
|
if isinstance(titles, Failure):
|
||||||
return titles
|
return titles
|
||||||
templates = title_templates(None, home)
|
templates = title_templates(None, home, env)
|
||||||
return templates if isinstance(templates, Failure) else [templates.summary(title) for title in titles]
|
return templates if isinstance(templates, Failure) else [templates.summary(title) for title in titles]
|
||||||
|
|
||||||
|
|
||||||
def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -> str | Failure:
|
def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path, env: Mapping[str, str]) -> str | Failure:
|
||||||
"""Writes the branch diff, the places and the plan's listing into the review folder, and returns the header that launches pass_'s reviewer in the pass's unanswered round, or its relaunch one rung up where rerun."""
|
"""Writes the branch diff, the places and the plan's listing into the review folder, and returns the header that launches pass_'s reviewer in the pass's unanswered round, or its relaunch one rung up where rerun."""
|
||||||
summaries = branch_summaries(default, home)
|
summaries = branch_summaries(default, home, env)
|
||||||
round_ = summaries if isinstance(summaries, Failure) else unanswered_round(summaries, pass_)
|
round_ = summaries if isinstance(summaries, Failure) else unanswered_round(summaries, pass_)
|
||||||
if isinstance(round_, Failure):
|
if isinstance(round_, Failure):
|
||||||
return round_
|
return round_
|
||||||
@@ -100,10 +101,10 @@ def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -
|
|||||||
if failed is not None:
|
if failed is not None:
|
||||||
return failed
|
return failed
|
||||||
worktree, branch, head, base = (str(answer).strip() for answer in found)
|
worktree, branch, head, base = (str(answer).strip() for answer in found)
|
||||||
folder = made_review_folder(worktree, home)
|
folder = made_review_folder(worktree, home, env)
|
||||||
if isinstance(folder, Failure):
|
if isinstance(folder, Failure):
|
||||||
return folder
|
return folder
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
principles, standards = config.paths["principles"], config.paths["standards"]
|
principles, standards = config.paths["principles"], config.paths["standards"]
|
||||||
@@ -125,18 +126,18 @@ def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -
|
|||||||
launch = Launch(pass_, round_, rerun, pull_named(worktree, branch), worktree, branch, base, default, folder, folder / f"branch-{head}.diff", principles, standards, goals, folder / "plan.md", starts_bare(next((agent for name, agent in REVIEWERS.items() if name == pass_), ""), home), config.paths["working-rules"], decisions, config.language, config.coding_conventions)
|
launch = Launch(pass_, round_, rerun, pull_named(worktree, branch), worktree, branch, base, default, folder, folder / f"branch-{head}.diff", principles, standards, goals, folder / "plan.md", starts_bare(next((agent for name, agent in REVIEWERS.items() if name == pass_), ""), home), config.paths["working-rules"], decisions, config.language, config.coding_conventions)
|
||||||
if rerun and not launch.asked().exists():
|
if rerun and not launch.asked().exists():
|
||||||
return Failure(f"no report asked for a rerun of {pass_}'s round {round_}: {launch.asked()} is missing; relaunch before you commit the round's answers")
|
return Failure(f"no report asked for a rerun of {pass_}'s round {round_}: {launch.asked()} is missing; relaunch before you commit the round's answers")
|
||||||
written = write_inputs(launch, base, home, plan_listing(plan_store(config)))
|
written = write_inputs(launch, base, home, env, plan_listing(plan_store(config)))
|
||||||
if isinstance(written, Failure):
|
if isinstance(written, Failure):
|
||||||
return written
|
return written
|
||||||
return launch.header()
|
return launch.header()
|
||||||
|
|
||||||
|
|
||||||
def write_inputs(launch: Launch, base: str, home: pathlib.Path, listing: str) -> Failure | None:
|
def write_inputs(launch: Launch, base: str, home: pathlib.Path, env: Mapping[str, str], listing: str) -> Failure | None:
|
||||||
"""Writes the branch diff from base to HEAD, what `larv-review places` prints, and the plan's listing into the review folder."""
|
"""Writes the branch diff from base to HEAD, what `larv-review places` prints, and the plan's listing into the review folder."""
|
||||||
diff = git("diff", base, "HEAD", errors="replace")
|
diff = git("diff", base, "HEAD", errors="replace")
|
||||||
if isinstance(diff, Failure):
|
if isinstance(diff, Failure):
|
||||||
return diff
|
return diff
|
||||||
history = history_file(home)
|
history = history_file(home, env)
|
||||||
if isinstance(history, Failure):
|
if isinstance(history, Failure):
|
||||||
return history
|
return history
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""round-title: print the opening of a round commit's title, counted from the round's report."""
|
"""round-title: print the opening of a round commit's title, counted from the round's report."""
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from larv_review.reviewer_header import branch_summaries, unanswered_round
|
from larv_review.reviewer_header import branch_summaries, unanswered_round
|
||||||
@@ -8,14 +9,14 @@ from review_rules.round_titles import round_prefix
|
|||||||
from git_cli.git_repo import top
|
from git_cli.git_repo import top
|
||||||
|
|
||||||
|
|
||||||
def round_title(default: str, pass_: str, home: pathlib.Path) -> str | Failure:
|
def round_title(default: str, pass_: str, home: pathlib.Path, env: Mapping[str, str]) -> str | Failure:
|
||||||
"""The title prefix of pass_'s unanswered round, counted from that round's report in the chunk's review folder."""
|
"""The title prefix of pass_'s unanswered round, counted from that round's report in the chunk's review folder."""
|
||||||
summaries = branch_summaries(default, home)
|
summaries = branch_summaries(default, home, env)
|
||||||
round_ = summaries if isinstance(summaries, Failure) else unanswered_round(summaries, pass_)
|
round_ = summaries if isinstance(summaries, Failure) else unanswered_round(summaries, pass_)
|
||||||
if isinstance(round_, Failure):
|
if isinstance(round_, Failure):
|
||||||
return round_
|
return round_
|
||||||
worktree = top()
|
worktree = top()
|
||||||
if isinstance(worktree, Failure):
|
if isinstance(worktree, Failure):
|
||||||
return worktree
|
return worktree
|
||||||
findings = findings_in(standing_report(pathlib.Path(review_folder(str(home), worktree)), pass_, round_))
|
findings = findings_in(standing_report(pathlib.Path(review_folder(str(home), env, worktree)), pass_, round_))
|
||||||
return findings if isinstance(findings, Failure) else round_prefix(pass_, round_, findings)
|
return findings if isinstance(findings, Failure) else round_prefix(pass_, round_, findings)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""When the plan calls a scoring run: a chunk that ships a floor item, one that empties a release that work has already landed towards, or one after a release cut unmeasured; and each reason it gives."""
|
"""When the plan calls a scoring run: a chunk that ships a floor item, one that empties a release that work has already landed towards, or one after a release cut unmeasured; and each reason it gives."""
|
||||||
|
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from release_plan.release_standing import Cut, LastCut, next_release, project_plan, standing_of, Unknown
|
from release_plan.release_standing import Cut, LastCut, next_release, project_plan, standing_of, Unknown
|
||||||
@@ -79,9 +80,9 @@ def finished_unseen(config: ProjectConfig, ids: list[int], chunk: list[Item]) ->
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def plan_reasons(ref: str, ids: list[int] | None, home: pathlib.Path) -> list[str] | Failure:
|
def plan_reasons(ref: str, ids: list[int] | None, home: pathlib.Path, env: Mapping[str, str]) -> list[str] | Failure:
|
||||||
"""Why the plan calls a scoring run, from todo.md at ref and the checkout's, each file where the project's config puts it; empty where the project opts out of the comprehension check. ref is the default branch, or the commit where the chunk began. Where ids is None, the chunk ships each item the plan at ref holds and the checkout's does not."""
|
"""Why the plan calls a scoring run, from todo.md at ref and the checkout's, each file where the project's config puts it; empty where the project opts out of the comprehension check. ref is the default branch, or the commit where the chunk began. Where ids is None, the chunk ships each item the plan at ref holds and the checkout's does not."""
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
checkout = str(config.top)
|
checkout = str(config.top)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Set up a scoring run: the worktree its seats read and each seat's prompt, filled from skills/comprehension-panel/seat-prompts.md."""
|
"""Set up a scoring run: the worktree its seats read and each seat's prompt, filled from skills/comprehension-panel/seat-prompts.md."""
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -127,18 +128,18 @@ def prompt_parts() -> dict[str, str] | Failure:
|
|||||||
return parts
|
return parts
|
||||||
|
|
||||||
|
|
||||||
def scoring_folder(worktree: str, home: pathlib.Path) -> pathlib.Path:
|
def scoring_folder(worktree: str, home: pathlib.Path, env: Mapping[str, str]) -> pathlib.Path:
|
||||||
return pathlib.Path(review_folder(str(home), worktree)) / "scoring"
|
return pathlib.Path(review_folder(str(home), env, worktree)) / "scoring"
|
||||||
|
|
||||||
|
|
||||||
def prepare_scoring(worktree: str, home: pathlib.Path, run: Git = git) -> str | Failure:
|
def prepare_scoring(worktree: str, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> str | Failure:
|
||||||
"""Makes the scoring run's worktree at worktree's HEAD and writes each seat's prompt beside it, in the chunk's review folder; what it made, as the tool prints it."""
|
"""Makes the scoring run's worktree at worktree's HEAD and writes each seat's prompt beside it, in the chunk's review folder; what it made, as the tool prints it."""
|
||||||
folder = scoring_folder(worktree, home)
|
folder = scoring_folder(worktree, home, env)
|
||||||
# A setup record-scoring never removed, as where the seats failed, would otherwise block every later run.
|
# A setup record-scoring never removed, as where the seats failed, would otherwise block every later run.
|
||||||
replaced = folder.exists()
|
replaced = folder.exists()
|
||||||
if replaced and isinstance(removed := removed_setup(worktree, home, run), Failure):
|
if replaced and isinstance(removed := removed_setup(worktree, home, env, run), Failure):
|
||||||
return removed
|
return removed
|
||||||
config = located(worktree, home, run)
|
config = located(worktree, home, env, run)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
source = config.paths["working-rules"]
|
source = config.paths["working-rules"]
|
||||||
@@ -170,7 +171,7 @@ def prepare_scoring(worktree: str, home: pathlib.Path, run: Git = git) -> str |
|
|||||||
if isinstance(head, Failure):
|
if isinstance(head, Failure):
|
||||||
return head
|
return head
|
||||||
main = listing.splitlines()[0].removeprefix("worktree ")
|
main = listing.splitlines()[0].removeprefix("worktree ")
|
||||||
made = made_review_folder(worktree, home)
|
made = made_review_folder(worktree, home, env)
|
||||||
if isinstance(made, Failure):
|
if isinstance(made, Failure):
|
||||||
return made
|
return made
|
||||||
checkout = folder / "checkout"
|
checkout = folder / "checkout"
|
||||||
@@ -206,9 +207,9 @@ def prepare_scoring(worktree: str, home: pathlib.Path, run: Git = git) -> str |
|
|||||||
return before + f"Scoring worktree, at {head.strip()}: {checkout}\nPrompts, each for one {SEAT_AGENT} agent:\n" + "\n".join(written)
|
return before + f"Scoring worktree, at {head.strip()}: {checkout}\nPrompts, each for one {SEAT_AGENT} agent:\n" + "\n".join(written)
|
||||||
|
|
||||||
|
|
||||||
def removed_setup(worktree: str, home: pathlib.Path, run: Git = git) -> Failure | None:
|
def removed_setup(worktree: str, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> Failure | None:
|
||||||
"""Removes the scoring worktree and prompts prepare_scoring made for the chunk at worktree, where they exist."""
|
"""Removes the scoring worktree and prompts prepare_scoring made for the chunk at worktree, where they exist."""
|
||||||
folder = scoring_folder(worktree, home)
|
folder = scoring_folder(worktree, home, env)
|
||||||
if not folder.exists():
|
if not folder.exists():
|
||||||
return None
|
return None
|
||||||
if (folder / "checkout").exists() and isinstance(removed := run("worktree", "remove", "--force", str(folder / "checkout"), cwd=worktree), Failure):
|
if (folder / "checkout").exists() and isinstance(removed := run("worktree", "remove", "--force", str(folder / "checkout"), cwd=worktree), Failure):
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.git("remote", "set-head", "origin", "main")
|
self.git("remote", "set-head", "origin", "main")
|
||||||
self.git("switch", "-q", "-c", "chunk")
|
self.git("switch", "-q", "-c", "chunk")
|
||||||
self.start = self.git("rev-parse", "--short", "HEAD").strip()
|
self.start = self.git("rev-parse", "--short", "HEAD").strip()
|
||||||
self.config = root / ".claude-projects" / "proj" / "config.toml"
|
self.config = root / ".config/build-release" / "proj" / "config.toml"
|
||||||
self.config.parent.mkdir(parents=True)
|
self.config.parent.mkdir(parents=True)
|
||||||
self.config.write_text(PROJECT_CONFIG)
|
self.config.write_text(PROJECT_CONFIG)
|
||||||
(root / "principles").mkdir()
|
(root / "principles").mkdir()
|
||||||
@@ -613,16 +613,16 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
(self.config.parent / "todo.md").write_text(todo(row, "| 2 | 0.2.0 | | **Reach the comprehension floor: do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |"))
|
(self.config.parent / "todo.md").write_text(todo(row, "| 2 | 0.2.0 | | **Reach the comprehension floor: do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |"))
|
||||||
self.addCleanup(os.chdir, os.getcwd())
|
self.addCleanup(os.chdir, os.getcwd())
|
||||||
os.chdir(self.checkout)
|
os.chdir(self.checkout)
|
||||||
home = self.config.parents[2]
|
home = self.config.parents[3]
|
||||||
self.assertEqual(plan_reasons("origin/main", [2], home), ["ships item 2, a floor item", "leaves release 0.2.0 with no plan item"])
|
self.assertEqual(plan_reasons("origin/main", [2], home, {}), ["ships item 2, a floor item", "leaves release 0.2.0 with no plan item"])
|
||||||
(self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n")
|
(self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n")
|
||||||
self.assertEqual(plan_reasons("origin/main", [2], home), [])
|
self.assertEqual(plan_reasons("origin/main", [2], home, {}), [])
|
||||||
(self.config.parent / "decisions.md").unlink()
|
(self.config.parent / "decisions.md").unlink()
|
||||||
gone = plan_reasons("origin/main", [1, 7], home)
|
gone = plan_reasons("origin/main", [1, 7], home, {})
|
||||||
assert isinstance(gone, Failure), gone
|
assert isinstance(gone, Failure), gone
|
||||||
self.assertEqual(gone.reason, f"the plan as it stands holds no item 7, and larv-review doesn't support a plan outside the checkout, so it cannot read the plan as it stood before the item was finished: {self.config.parent}/todo.md")
|
self.assertEqual(gone.reason, f"the plan as it stands holds no item 7, and larv-review doesn't support a plan outside the checkout, so it cannot read the plan as it stood before the item was finished: {self.config.parent}/todo.md")
|
||||||
(self.config.parent / "todo.md").write_bytes(b"\xff")
|
(self.config.parent / "todo.md").write_bytes(b"\xff")
|
||||||
unreadable = plan_reasons("origin/main", [2], home)
|
unreadable = plan_reasons("origin/main", [2], home, {})
|
||||||
assert isinstance(unreadable, Failure), unreadable
|
assert isinstance(unreadable, Failure), unreadable
|
||||||
self.assertEqual(unreadable.reason, f"the project's plan: {self.config.parent}/todo.md: not UTF-8")
|
self.assertEqual(unreadable.reason, f"the project's plan: {self.config.parent}/todo.md: not UTF-8")
|
||||||
|
|
||||||
@@ -782,7 +782,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
def test_refuses_where_the_default_branchs_unreleased_changes_cannot_be_read(self):
|
def test_refuses_where_the_default_branchs_unreleased_changes_cannot_be_read(self):
|
||||||
self.addCleanup(os.chdir, os.getcwd())
|
self.addCleanup(os.chdir, os.getcwd())
|
||||||
os.chdir(self.checkout)
|
os.chdir(self.checkout)
|
||||||
self.assertIsInstance(plan_reasons("no-such-ref", [], pathlib.Path.home()), Failure)
|
self.assertIsInstance(plan_reasons("no-such-ref", [], pathlib.Path.home(), {}), Failure)
|
||||||
|
|
||||||
def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self):
|
def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self):
|
||||||
self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"})
|
self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"})
|
||||||
@@ -935,7 +935,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.plan()
|
self.plan()
|
||||||
ran = self.record_sevens()
|
ran = self.record_sevens()
|
||||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||||
self.assertFalse((self.checkout.parent / ".local" / "state" / "larv-review" / "proj" / "scoring").exists())
|
self.assertFalse((self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj" / "scoring").exists())
|
||||||
self.assertEqual(len(self.git("worktree", "list").splitlines()), 1)
|
self.assertEqual(len(self.git("worktree", "list").splitlines()), 1)
|
||||||
|
|
||||||
VALUES = {"AGENTS.md": "## Scoring run\n\n- Language: Python\n- Kind: a CLI\n- Domain: parsing\n- Domain docs: the spec\n- 3am question: the parse hangs\n"}
|
VALUES = {"AGENTS.md": "## Scoring run\n\n- Language: Python\n- Kind: a CLI\n- Domain: parsing\n- Domain docs: the spec\n- 3am question: the parse hangs\n"}
|
||||||
@@ -991,7 +991,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
(checkout / "todo.md").write_text("the owners' own notes\n")
|
(checkout / "todo.md").write_text("the owners' own notes\n")
|
||||||
self.enterContext(contextlib.chdir(checkout))
|
self.enterContext(contextlib.chdir(checkout))
|
||||||
said: list[str] = []
|
said: list[str] = []
|
||||||
self.assertIsNone(rerank(config.parents[2], said.append))
|
self.assertIsNone(rerank(config.parents[3], {}, said.append))
|
||||||
self.assertEqual((said, (checkout / "todo.md").read_text()), ([], "the owners' own notes\n"))
|
self.assertEqual((said, (checkout / "todo.md").read_text()), ([], "the owners' own notes\n"))
|
||||||
|
|
||||||
def test_reranks_todo_md_by_the_overall_it_records(self):
|
def test_reranks_todo_md_by_the_overall_it_records(self):
|
||||||
@@ -1044,21 +1044,21 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||||
|
|
||||||
def test_makes_and_prints_the_worktrees_review_folder_from_anywhere_in_it(self):
|
def test_makes_and_prints_the_worktrees_review_folder_from_anywhere_in_it(self):
|
||||||
reports = self.checkout.parent / ".local" / "state" / "larv-review"
|
reports = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review"
|
||||||
(self.checkout / "sub").mkdir()
|
(self.checkout / "sub").mkdir()
|
||||||
ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout / "sub", env=self.env, text=True)
|
ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout / "sub", env=self.env, text=True)
|
||||||
self.assertEqual((ran.returncode, ran.stdout), (0, f"{reports}/proj\n"), ran.stderr)
|
self.assertEqual((ran.returncode, ran.stdout), (0, f"{reports}/proj\n"), ran.stderr)
|
||||||
self.assertTrue((reports / "proj").is_dir())
|
self.assertTrue((reports / "proj").is_dir())
|
||||||
|
|
||||||
def test_leaves_the_reports_folder_readable_by_the_user_alone_where_it_was_not(self):
|
def test_leaves_the_reports_folder_readable_by_the_user_alone_where_it_was_not(self):
|
||||||
reports = self.checkout.parent / ".local" / "state" / "larv-review"
|
reports = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review"
|
||||||
reports.mkdir(parents=True, mode=0o755)
|
reports.mkdir(parents=True, mode=0o755)
|
||||||
self.assertEqual(self.run_tool("review-folder").returncode, 0)
|
self.assertEqual(self.run_tool("review-folder").returncode, 0)
|
||||||
self.assertEqual(reports.stat().st_mode & 0o777, 0o700)
|
self.assertEqual(reports.stat().st_mode & 0o777, 0o700)
|
||||||
|
|
||||||
def test_fails_where_it_cannot_make_the_review_folder(self):
|
def test_fails_where_it_cannot_make_the_review_folder(self):
|
||||||
(self.checkout.parent / ".local" / "state").mkdir(parents=True)
|
(self.checkout.parent / ".local" / "state" / "build-release").mkdir(parents=True)
|
||||||
(self.checkout.parent / ".local" / "state" / "larv-review").write_text("")
|
(self.checkout.parent / ".local" / "state" / "build-release" / "larv-review").write_text("")
|
||||||
ran = self.run_tool("review-folder")
|
ran = self.run_tool("review-folder")
|
||||||
self.assertEqual(ran.returncode, 1)
|
self.assertEqual(ran.returncode, 1)
|
||||||
self.assertIn("could not make the review folder", ran.stderr)
|
self.assertIn("could not make the review folder", ran.stderr)
|
||||||
@@ -1125,7 +1125,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.commit("Unpushed fix", {"a.txt": "two\n"})
|
self.commit("Unpushed fix", {"a.txt": "two\n"})
|
||||||
short = self.git("rev-parse", "--short", "HEAD").strip()
|
short = self.git("rev-parse", "--short", "HEAD").strip()
|
||||||
base = self.git("rev-parse", self.start).strip()
|
base = self.git("rev-parse", self.start).strip()
|
||||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
folder = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj"
|
||||||
ran = self.run_tool("reviewer-header", "stability")
|
ran = self.run_tool("reviewer-header", "stability")
|
||||||
self.assertEqual((ran.returncode, ran.stdout), (0, (
|
self.assertEqual((ran.returncode, ran.stdout), (0, (
|
||||||
"Pass: stability, round 1.\n"
|
"Pass: stability, round 1.\n"
|
||||||
@@ -1152,7 +1152,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
|
|
||||||
def test_counts_the_round_from_the_branchs_answers_and_names_the_report_that_asked_for_a_rerun(self):
|
def test_counts_the_round_from_the_branchs_answers_and_names_the_report_that_asked_for_a_rerun(self):
|
||||||
self.commit("Answer prose round 1: a")
|
self.commit("Answer prose round 1: a")
|
||||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
folder = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj"
|
||||||
missing = self.run_tool("reviewer-header", "prose", "--rerun")
|
missing = self.run_tool("reviewer-header", "prose", "--rerun")
|
||||||
self.assertEqual(missing.returncode, 1)
|
self.assertEqual(missing.returncode, 1)
|
||||||
self.assertIn(f"{folder}/prose-round-2.md is missing", missing.stderr)
|
self.assertIn(f"{folder}/prose-round-2.md is missing", missing.stderr)
|
||||||
@@ -1166,7 +1166,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.assertFalse(any(line.startswith("Places:") for line in lines), "only architecture and stability take the places")
|
self.assertFalse(any(line.startswith("Places:") for line in lines), "only architecture and stability take the places")
|
||||||
|
|
||||||
def test_round_title_counts_the_unanswered_rounds_report_and_names_one_that_is_missing(self):
|
def test_round_title_counts_the_unanswered_rounds_report_and_names_one_that_is_missing(self):
|
||||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
folder = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
(folder / "prose-round-1.md").write_text("BLOCK\n\n### 🔴 [misread] `a.md:1`: wrong\n\n### 🟡 `b.md:2`: worse\n\n### 🟢 `c.md:3`: nit\n")
|
(folder / "prose-round-1.md").write_text("BLOCK\n\n### 🔴 [misread] `a.md:1`: wrong\n\n### 🟡 `b.md:2`: worse\n\n### 🟢 `c.md:3`: nit\n")
|
||||||
ran = self.run_tool("round-title", "prose")
|
ran = self.run_tool("round-title", "prose")
|
||||||
@@ -1192,7 +1192,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reviewer_header_leaves_an_unchanged_diff_places_and_plan_untouched_so_an_earlier_rounds_replay_keeps_them(self):
|
def test_reviewer_header_leaves_an_unchanged_diff_places_and_plan_untouched_so_an_earlier_rounds_replay_keeps_them(self):
|
||||||
self.commit("Work", {"a.txt": "one\n"})
|
self.commit("Work", {"a.txt": "one\n"})
|
||||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
folder = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj"
|
||||||
self.assertEqual(self.run_tool("reviewer-header", "stability").returncode, 0)
|
self.assertEqual(self.run_tool("reviewer-header", "stability").returncode, 0)
|
||||||
written = [folder / f"branch-{self.git('rev-parse', '--short', 'HEAD').strip()}.diff", folder / "places.md", folder / "plan.md"]
|
written = [folder / f"branch-{self.git('rev-parse', '--short', 'HEAD').strip()}.diff", folder / "places.md", folder / "plan.md"]
|
||||||
for path in written:
|
for path in written:
|
||||||
@@ -1229,8 +1229,8 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
detached = self.run_tool("reviewer-header", "prose")
|
detached = self.run_tool("reviewer-header", "prose")
|
||||||
self.assertEqual((detached.returncode, detached.stdout), (1, ""))
|
self.assertEqual((detached.returncode, detached.stdout), (1, ""))
|
||||||
self.git("switch", "-q", "chunk")
|
self.git("switch", "-q", "chunk")
|
||||||
(self.checkout.parent / ".local" / "state").mkdir(parents=True)
|
(self.checkout.parent / ".local" / "state" / "build-release").mkdir(parents=True)
|
||||||
(self.checkout.parent / ".local" / "state" / "larv-review").write_text("")
|
(self.checkout.parent / ".local" / "state" / "build-release" / "larv-review").write_text("")
|
||||||
unmade = self.run_tool("reviewer-header", "prose")
|
unmade = self.run_tool("reviewer-header", "prose")
|
||||||
self.assertEqual(unmade.returncode, 1)
|
self.assertEqual(unmade.returncode, 1)
|
||||||
self.assertIn("could not make the review folder", unmade.stderr)
|
self.assertIn("could not make the review folder", unmade.stderr)
|
||||||
@@ -1267,7 +1267,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
def test_reviewer_header_fails_naming_the_epic_where_it_cannot_read_goals_kept_in_jira(self):
|
def test_reviewer_header_fails_naming_the_epic_where_it_cannot_read_goals_kept_in_jira(self):
|
||||||
# Port 1 on the loopback refuses the connection, so the read fails without leaving the machine.
|
# Port 1 on the loopback refuses the connection, so the read fails without leaving the machine.
|
||||||
epic = "jira:https://127.0.0.1:1/browse/ABC-12"
|
epic = "jira:https://127.0.0.1:1/browse/ABC-12"
|
||||||
credentials = self.config.parents[2] / "acme.env"
|
credentials = self.config.parents[3] / "acme.env"
|
||||||
credentials.write_text("ATLASSIAN_EMAIL=me@example.com\nATLASSIAN_API_TOKEN=s3cret\n")
|
credentials.write_text("ATLASSIAN_EMAIL=me@example.com\nATLASSIAN_API_TOKEN=s3cret\n")
|
||||||
credentials.chmod(0o600)
|
credentials.chmod(0o600)
|
||||||
self.config.write_text(PROJECT_CONFIG.replace('"checkout:todo.md"', f'"{epic}"').replace('"checkout:README.md"', f'"{epic}"') + 'env-file = "~/acme.env"\njira-score-formula = "V"\njira-score-bar = 1\n')
|
self.config.write_text(PROJECT_CONFIG.replace('"checkout:todo.md"', f'"{epic}"').replace('"checkout:README.md"', f'"{epic}"') + 'env-file = "~/acme.env"\njira-score-formula = "V"\njira-score-bar = 1\n')
|
||||||
@@ -1317,7 +1317,7 @@ class LarvReviewTool(unittest.TestCase):
|
|||||||
self.assertIn(f"{self.checkout}/CONVENTIONS.md is not a file; {self.config} sets it in `coding-conventions`", ran.stderr)
|
self.assertIn(f"{self.checkout}/CONVENTIONS.md is not a file; {self.config} sets it in `coding-conventions`", ran.stderr)
|
||||||
|
|
||||||
def test_reviewer_header_gives_the_architect_the_places(self):
|
def test_reviewer_header_gives_the_architect_the_places(self):
|
||||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
folder = self.checkout.parent / ".local" / "state" / "build-release" / "larv-review" / "proj"
|
||||||
self.assertEqual(self.header_line("Places:", "architecture"), f"Places: {folder}/places.md")
|
self.assertEqual(self.header_line("Places:", "architecture"), f"Places: {folder}/places.md")
|
||||||
|
|
||||||
def test_reviewer_header_names_the_file_that_holds_the_principles_last_where_the_project_keeps_one(self):
|
def test_reviewer_header_names_the_file_that_holds_the_principles_last_where_the_project_keeps_one(self):
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class PrepareScoring(unittest.TestCase):
|
|||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
"""What prepare-scoring returns in the checkout, run in this process so mutation tests see the lines it runs."""
|
"""What prepare-scoring returns in the checkout, run in this process so mutation tests see the lines it runs."""
|
||||||
return prepare_scoring(str(self.checkout), self.root, functools.partial(git, env=self.env))
|
return prepare_scoring(str(self.checkout), self.root, {}, functools.partial(git, env=self.env))
|
||||||
|
|
||||||
def run_tool(self, *args):
|
def run_tool(self, *args):
|
||||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True)
|
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True)
|
||||||
@@ -112,7 +112,7 @@ class PrepareScoring(unittest.TestCase):
|
|||||||
def test_writes_each_seats_prompt_with_every_placeholder_filled_and_a_worktree_at_head(self):
|
def test_writes_each_seats_prompt_with_every_placeholder_filled_and_a_worktree_at_head(self):
|
||||||
self.commit("# A\n\n## Scoring run\n\n- Language: Python\n- Kind: a CLI\n- Domain: parsing\n- Domain docs: the spec\n- 3am question: the parse hangs\n")
|
self.commit("# A\n\n## Scoring run\n\n- Language: Python\n- Kind: a CLI\n- Domain: parsing\n- Domain docs: the spec\n- 3am question: the parse hangs\n")
|
||||||
ran = self.prepare()
|
ran = self.prepare()
|
||||||
folder = self.root / ".local" / "state" / "larv-review" / "proj" / "scoring"
|
folder = self.root / ".local" / "state" / "build-release" / "larv-review" / "proj" / "scoring"
|
||||||
worktree = folder / "checkout"
|
worktree = folder / "checkout"
|
||||||
prompts = [folder / f"{seat}.md" for seat in ("junior-a", "mid-a", "maintainability-senior", "inherited-architect")]
|
prompts = [folder / f"{seat}.md" for seat in ("junior-a", "mid-a", "maintainability-senior", "inherited-architect")]
|
||||||
self.assertEqual(ran, f"Scoring worktree, at {self.git('rev-parse', '--short', 'HEAD').strip()}: {worktree}\nPrompts, each for one comprehension-seat agent:\n" + "\n".join(str(prompt) for prompt in prompts))
|
self.assertEqual(ran, f"Scoring worktree, at {self.git('rev-parse', '--short', 'HEAD').strip()}: {worktree}\nPrompts, each for one comprehension-seat agent:\n" + "\n".join(str(prompt) for prompt in prompts))
|
||||||
@@ -137,9 +137,9 @@ class PrepareScoring(unittest.TestCase):
|
|||||||
|
|
||||||
def test_says_it_could_not_remove_a_checkout_git_does_not_hold(self):
|
def test_says_it_could_not_remove_a_checkout_git_does_not_hold(self):
|
||||||
self.commit()
|
self.commit()
|
||||||
checkout = self.root / ".local" / "state" / "larv-review" / "proj" / "scoring" / "checkout"
|
checkout = self.root / ".local" / "state" / "build-release" / "larv-review" / "proj" / "scoring" / "checkout"
|
||||||
checkout.mkdir(parents=True)
|
checkout.mkdir(parents=True)
|
||||||
removed = removed_setup(str(self.checkout), self.root, functools.partial(git, env=self.env))
|
removed = removed_setup(str(self.checkout), self.root, {}, functools.partial(git, env=self.env))
|
||||||
self.assertIsInstance(removed, Failure)
|
self.assertIsInstance(removed, Failure)
|
||||||
self.assertTrue(removed.reason.startswith(f"could not remove the scoring worktree {checkout}: "), removed.reason)
|
self.assertTrue(removed.reason.startswith(f"could not remove the scoring worktree {checkout}: "), removed.reason)
|
||||||
self.assertTrue(checkout.exists())
|
self.assertTrue(checkout.exists())
|
||||||
@@ -176,7 +176,7 @@ class PrepareScoring(unittest.TestCase):
|
|||||||
ran = self.prepare()
|
ran = self.prepare()
|
||||||
assert isinstance(ran, str), ran
|
assert isinstance(ran, str), ran
|
||||||
self.assertIn("Your background: ~2 years in Go, first codebase of this kind (a CLI)", pathlib.Path(ran.splitlines()[2]).read_text())
|
self.assertIn("Your background: ~2 years in Go, first codebase of this kind (a CLI)", pathlib.Path(ran.splitlines()[2]).read_text())
|
||||||
self.assertIsNone(removed_setup(str(self.checkout), self.root, functools.partial(git, env=self.env)))
|
self.assertIsNone(removed_setup(str(self.checkout), self.root, {}, functools.partial(git, env=self.env)))
|
||||||
|
|
||||||
def test_keeps_the_working_rules_values_where_the_checkout_has_seat_prompts_too(self):
|
def test_keeps_the_working_rules_values_where_the_checkout_has_seat_prompts_too(self):
|
||||||
own = self.checkout / "skills" / "comprehension-panel" / "seat-prompts.md"
|
own = self.checkout / "skills" / "comprehension-panel" / "seat-prompts.md"
|
||||||
@@ -192,7 +192,7 @@ class PrepareScoring(unittest.TestCase):
|
|||||||
ran = self.run_tool("prepare-scoring")
|
ran = self.run_tool("prepare-scoring")
|
||||||
self.assertEqual(ran.returncode, 1)
|
self.assertEqual(ran.returncode, 1)
|
||||||
self.assertIn("AGENTS.md has no \"Scoring run\" section", ran.stderr)
|
self.assertIn("AGENTS.md has no \"Scoring run\" section", ran.stderr)
|
||||||
self.assertFalse((self.root / ".local" / "state" / "larv-review" / "proj" / "scoring").exists())
|
self.assertFalse((self.root / ".local" / "state" / "build-release" / "larv-review" / "proj" / "scoring").exists())
|
||||||
self.assertEqual(len(self.git("worktree", "list").splitlines()), 1)
|
self.assertEqual(len(self.git("worktree", "list").splitlines()), 1)
|
||||||
|
|
||||||
def test_fails_before_it_makes_the_worktree_where_a_file_it_reads_does_not_decode(self):
|
def test_fails_before_it_makes_the_worktree_where_a_file_it_reads_does_not_decode(self):
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ def system_effects(home: pathlib.Path, env: typing.Mapping[str, str], backends:
|
|||||||
claude=lambda args, cwd, stdin: subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(env), input=stdin, text=True),
|
claude=lambda args, cwd, stdin: subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(env), input=stdin, text=True),
|
||||||
claude_on_terminal=claude_on_terminal,
|
claude_on_terminal=claude_on_terminal,
|
||||||
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
|
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
|
||||||
dm=lambda text, directory: notify(text, directory, home, backends),
|
dm=lambda text, directory: notify(text, directory, home, env, backends),
|
||||||
execv=os.execv,
|
execv=os.execv,
|
||||||
forge=lambda cwd: runner(cwd, forge_timeout),
|
forge=lambda cwd: runner(cwd, forge_timeout),
|
||||||
git=git_repo.git,
|
git=git_repo.git,
|
||||||
|
|||||||
+34
-8
@@ -12,10 +12,14 @@ RELEASE_ROOT = pathlib.Path(__file__).resolve().parents[2]
|
|||||||
|
|
||||||
# The Claude home: Claude Code's own folder, with its settings and transcripts. A release is deployed into it, so its CLAUDE.md, rules/ and agents/ are read from it.
|
# The Claude home: Claude Code's own folder, with its settings and transcripts. A release is deployed into it, so its CLAUDE.md, rules/ and agents/ are read from it.
|
||||||
CLAUDE_HOME = ".claude"
|
CLAUDE_HOME = ".claude"
|
||||||
# The config folder, which holds one folder per project, and do-epic's.
|
# The name of the setup's own folder, in the config home and in the state home.
|
||||||
CONFIG_FOLDER = ".claude-projects"
|
SETUP = "build-release"
|
||||||
# The state folder, which holds one folder per tool.
|
# The config home, which holds the config folder, unless the variable XDG_CONFIG_HOME names another.
|
||||||
STATE_FOLDER = ".local/state"
|
CONFIG_HOME = ".config"
|
||||||
|
XDG_CONFIG_HOME = "XDG_CONFIG_HOME"
|
||||||
|
# The state home, which holds the state folder, unless the variable XDG_STATE_HOME names another.
|
||||||
|
STATE_HOME = ".local/state"
|
||||||
|
XDG_STATE_HOME = "XDG_STATE_HOME"
|
||||||
|
|
||||||
|
|
||||||
# Only a claude started through this has the tools on PATH. One a person starts by hand lacks them, as their shell does: the plan keeps short names such as `wait-for` out of a person's shell. README.md → Tools says how to call a tool there.
|
# Only a claude started through this has the tools on PATH. One a person starts by hand lacks them, as their shell does: the plan keeps short names such as `wait-for` out of a person's shell. README.md → Tools says how to call a tool there.
|
||||||
@@ -28,9 +32,26 @@ def with_release_tools(env: Mapping[str, str]) -> dict[str, str]:
|
|||||||
return {**env, "PATH": f"{tools}{os.pathsep}{rest}" if rest else tools}
|
return {**env, "PATH": f"{tools}{os.pathsep}{rest}" if rest else tools}
|
||||||
|
|
||||||
|
|
||||||
|
def config_folder(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
|
||||||
|
"""The config folder, which a person writes and backs up: one folder per project, do-epic's, and the model of each project."""
|
||||||
|
# The models file is here though the tools write it: it holds a person's choice per project, and is backed up with the configs.
|
||||||
|
return xdg_folder(env.get(XDG_CONFIG_HOME), home / CONFIG_HOME) / SETUP
|
||||||
|
|
||||||
|
|
||||||
def state_folder(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
|
def state_folder(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
|
||||||
"""The state folder of a tool that honours `XDG_STATE_HOME`."""
|
"""The state folder, which the tools write: one folder per tool."""
|
||||||
return pathlib.Path(env.get("XDG_STATE_HOME") or home / STATE_FOLDER)
|
# Every tool keeps its state here, none beside it in the state home. Only an archive that BUILD_RELEASE_TRANSCRIPTS names is elsewhere.
|
||||||
|
return xdg_folder(env.get(XDG_STATE_HOME), home / STATE_HOME) / SETUP
|
||||||
|
|
||||||
|
|
||||||
|
# The XDG Base Directory Specification calls a relative path in one of its variables invalid, to be ignored: https://specifications.freedesktop.org/basedir-spec/latest/
|
||||||
|
def xdg_folder(named: str | None, default: pathlib.Path) -> pathlib.Path:
|
||||||
|
return pathlib.Path(named) if named and os.path.isabs(named) else default
|
||||||
|
|
||||||
|
|
||||||
|
def without_xdg_folders(env: Mapping[str, str]) -> dict[str, str]:
|
||||||
|
"""env without the person's own config and state folders, so that both lie under the home folder a caller names."""
|
||||||
|
return {name: value for name, value in env.items() if name not in (XDG_CONFIG_HOME, XDG_STATE_HOME)}
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
@@ -39,18 +60,23 @@ class Paths:
|
|||||||
claude_dir: pathlib.Path
|
claude_dir: pathlib.Path
|
||||||
# The development clone of this setup, where a change to it is made: claude_dir holds only a release, docs/decisions.md → `deploy:`.
|
# The development clone of this setup, where a change to it is made: claude_dir holds only a release, docs/decisions.md → `deploy:`.
|
||||||
config_clone: pathlib.Path
|
config_clone: pathlib.Path
|
||||||
|
config_folder: pathlib.Path
|
||||||
home: pathlib.Path
|
home: pathlib.Path
|
||||||
model_catalog: pathlib.Path
|
model_catalog: pathlib.Path
|
||||||
models_file: pathlib.Path
|
models_file: pathlib.Path
|
||||||
|
state_folder: pathlib.Path
|
||||||
|
|
||||||
|
|
||||||
def paths_from(home: pathlib.Path) -> Paths:
|
def paths_from(home: pathlib.Path, env: Mapping[str, str]) -> Paths:
|
||||||
claude = home / CLAUDE_HOME
|
claude = home / CLAUDE_HOME
|
||||||
|
config = config_folder(env, home)
|
||||||
return Paths(
|
return Paths(
|
||||||
claude_code_transcripts=claude / "projects",
|
claude_code_transcripts=claude / "projects",
|
||||||
claude_dir=claude,
|
claude_dir=claude,
|
||||||
config_clone=home / "code" / "claude-config",
|
config_clone=home / "code" / "claude-config",
|
||||||
|
config_folder=config,
|
||||||
home=home,
|
home=home,
|
||||||
model_catalog=claude / "cache" / "model-catalog",
|
model_catalog=claude / "cache" / "model-catalog",
|
||||||
models_file=claude / "loop-claude-models.json",
|
models_file=config / "models.json",
|
||||||
|
state_folder=state_folder(env, home),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import unittest
|
|||||||
|
|
||||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||||
|
|
||||||
from loop_state.paths import RELEASE_ROOT, with_release_tools
|
from loop_state.paths import config_folder, paths_from, RELEASE_ROOT, state_folder, with_release_tools, without_xdg_folders
|
||||||
|
|
||||||
TOOLS = str(RELEASE_ROOT / "bin")
|
TOOLS = str(RELEASE_ROOT / "bin")
|
||||||
|
|
||||||
@@ -20,5 +20,33 @@ class WithReleaseTools(unittest.TestCase):
|
|||||||
self.assertEqual(with_release_tools({}), {"PATH": TOOLS})
|
self.assertEqual(with_release_tools({}), {"PATH": TOOLS})
|
||||||
|
|
||||||
|
|
||||||
|
HOME = pathlib.Path("/home/me")
|
||||||
|
|
||||||
|
|
||||||
|
class SetupFolders(unittest.TestCase):
|
||||||
|
def test_both_lie_under_the_home_folder_where_no_xdg_variable_is_set(self):
|
||||||
|
self.assertEqual(config_folder({}, HOME), HOME / ".config" / "build-release")
|
||||||
|
self.assertEqual(state_folder({}, HOME), HOME / ".local" / "state" / "build-release")
|
||||||
|
|
||||||
|
def test_each_lies_under_the_folder_its_xdg_variable_names(self):
|
||||||
|
env = {"XDG_CONFIG_HOME": "/x/config", "XDG_STATE_HOME": "/x/state"}
|
||||||
|
self.assertEqual(config_folder(env, HOME), pathlib.Path("/x/config/build-release"))
|
||||||
|
self.assertEqual(state_folder(env, HOME), pathlib.Path("/x/state/build-release"))
|
||||||
|
|
||||||
|
def test_an_xdg_variable_that_is_empty_or_relative_is_ignored(self):
|
||||||
|
for named in ("", "config", "./state"):
|
||||||
|
with self.subTest(named=named):
|
||||||
|
env = {"XDG_CONFIG_HOME": named, "XDG_STATE_HOME": named}
|
||||||
|
self.assertEqual(config_folder(env, HOME), HOME / ".config" / "build-release")
|
||||||
|
self.assertEqual(state_folder(env, HOME), HOME / ".local" / "state" / "build-release")
|
||||||
|
|
||||||
|
def test_the_models_file_is_in_the_config_folder(self):
|
||||||
|
found = paths_from(HOME, {"XDG_CONFIG_HOME": "/x/config", "XDG_STATE_HOME": "/x/state"})
|
||||||
|
self.assertEqual((found.config_folder, found.models_file, found.state_folder), (pathlib.Path("/x/config/build-release"), pathlib.Path("/x/config/build-release/models.json"), pathlib.Path("/x/state/build-release")))
|
||||||
|
|
||||||
|
def test_an_environment_without_the_xdg_folders_keeps_every_other_variable(self):
|
||||||
|
self.assertEqual(without_xdg_folders({"HOME": "/h", "XDG_CONFIG_HOME": "/c", "XDG_STATE_HOME": "/s", "XDG_DATA_HOME": "/d"}), {"HOME": "/h", "XDG_DATA_HOME": "/d"})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class SlotShare(unittest.TestCase):
|
|||||||
|
|
||||||
class SlotFolder(unittest.TestCase):
|
class SlotFolder(unittest.TestCase):
|
||||||
def test_every_session_shares_the_slots_under_the_users_state_folder(self):
|
def test_every_session_shares_the_slots_under_the_users_state_folder(self):
|
||||||
self.assertEqual(slots.slot_folder({}, pathlib.Path.home()), pathlib.Path.home() / ".local" / "state" / "run-heavy")
|
self.assertEqual(slots.slot_folder({}, pathlib.Path.home()), pathlib.Path.home() / ".local" / "state" / "build-release" / "run-heavy")
|
||||||
self.assertEqual(slots.slot_folder({"XDG_STATE_HOME": "/s"}, pathlib.Path.home()), pathlib.Path("/s/run-heavy"))
|
self.assertEqual(slots.slot_folder({"XDG_STATE_HOME": "/s"}, pathlib.Path.home()), pathlib.Path("/s/build-release/run-heavy"))
|
||||||
|
|
||||||
|
|
||||||
class TakenSlot(unittest.TestCase):
|
class TakenSlot(unittest.TestCase):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""Read a routing ladder from its JSON file: the one this setup ships, or a project's own, kept in its config's folder. docs/decisions.md → `routing: one ladder of (model, effort) rungs`."""
|
"""Read a routing ladder from its JSON file: the one this setup ships, or a project's own, kept in its config's folder. docs/decisions.md → `routing: one ladder of (model, effort) rungs`."""
|
||||||
import json
|
import json
|
||||||
|
from collections.abc import Mapping
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -17,9 +18,9 @@ MODEL = re.compile(r"[^\s-]+(-[^\s-]+)+")
|
|||||||
SHAPE = f'a JSON list of rungs, least competent first, each as {{"model": "claude-opus-5-5", "effort": "medium"}}: a model\'s full name, one model for each family such as opus, and an effort of {", ".join(EFFORTS[:-1])} or {EFFORTS[-1]}'
|
SHAPE = f'a JSON list of rungs, least competent first, each as {{"model": "claude-opus-5-5", "effort": "medium"}}: a model\'s full name, one model for each family such as opus, and an effort of {", ".join(EFFORTS[:-1])} or {EFFORTS[-1]}'
|
||||||
|
|
||||||
|
|
||||||
def project_ladder_file(directory: str | None, home: pathlib.Path, shipped: pathlib.Path = SHIPPED) -> pathlib.Path | Failure:
|
def project_ladder_file(directory: str | None, home: pathlib.Path, env: Mapping[str, str], shipped: pathlib.Path = SHIPPED) -> pathlib.Path | Failure:
|
||||||
"""The file that holds the ladder of the project whose checkout holds directory, else the current directory: the file NAME in its config's folder under home, or shipped where that folder holds none. Also shipped where no config names a checkout there, or git fails there. A Failure where the project's config is faulty or cannot be read, since its folder may hold the ladder."""
|
"""The file that holds the ladder of the project whose checkout holds directory, else the current directory: the file NAME in its config's folder under home, or shipped where that folder holds none. Also shipped where no config names a checkout there, or git fails there. A Failure where the project's config is faulty or cannot be read, since its folder may hold the ladder."""
|
||||||
config = located(directory, home)
|
config = located(directory, home, env)
|
||||||
if isinstance(config, Unnamed):
|
if isinstance(config, Unnamed):
|
||||||
return shipped
|
return shipped
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
@@ -28,9 +29,9 @@ def project_ladder_file(directory: str | None, home: pathlib.Path, shipped: path
|
|||||||
return own if own.exists() else shipped
|
return own if own.exists() else shipped
|
||||||
|
|
||||||
|
|
||||||
def project_ladder(directory: str | None, home: pathlib.Path, shipped: pathlib.Path = SHIPPED) -> Ladder | Failure:
|
def project_ladder(directory: str | None, home: pathlib.Path, env: Mapping[str, str], shipped: pathlib.Path = SHIPPED) -> Ladder | Failure:
|
||||||
"""The ladder project_ladder_file's file holds. A Failure where that file holds a fault too: the shipped ladder never stands in for a project's own, since work routed on it could run on a model the project cannot reach."""
|
"""The ladder project_ladder_file's file holds. A Failure where that file holds a fault too: the shipped ladder never stands in for a project's own, since work routed on it could run on a model the project cannot reach."""
|
||||||
file = project_ladder_file(directory, home, shipped)
|
file = project_ladder_file(directory, home, env, shipped)
|
||||||
return file if isinstance(file, Failure) else read_ladder(file)
|
return file if isinstance(file, Failure) else read_ladder(file)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -106,41 +106,41 @@ class ProjectLadder(LadderCase):
|
|||||||
def test_a_project_runs_on_the_ladder_its_configs_folder_holds_from_a_worktree_too(self):
|
def test_a_project_runs_on_the_ladder_its_configs_folder_holds_from_a_worktree_too(self):
|
||||||
checkout = self.checkout()
|
checkout = self.checkout()
|
||||||
(write_config(self.home, checkout) / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
(write_config(self.home, checkout) / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
||||||
self.assertEqual(project_ladder(str(checkout), self.home, self.shipped), FABLE_LADDER)
|
self.assertEqual(project_ladder(str(checkout), self.home, {}, self.shipped), FABLE_LADDER)
|
||||||
worktree = self.home / "code" / "acme-item-7"
|
worktree = self.home / "code" / "acme-item-7"
|
||||||
self.git(checkout, "worktree", "add", "--quiet", str(worktree), "-b", "item-7")
|
self.git(checkout, "worktree", "add", "--quiet", str(worktree), "-b", "item-7")
|
||||||
self.assertEqual(project_ladder(str(worktree), self.home, self.shipped), FABLE_LADDER)
|
self.assertEqual(project_ladder(str(worktree), self.home, {}, self.shipped), FABLE_LADDER)
|
||||||
|
|
||||||
def test_names_the_file_it_reads_the_projects_own_or_else_the_shipped_one(self):
|
def test_names_the_file_it_reads_the_projects_own_or_else_the_shipped_one(self):
|
||||||
checkout = self.checkout()
|
checkout = self.checkout()
|
||||||
folder = write_config(self.home, checkout)
|
folder = write_config(self.home, checkout)
|
||||||
self.assertEqual(project_ladder_file(str(checkout), self.home, self.shipped), self.shipped)
|
self.assertEqual(project_ladder_file(str(checkout), self.home, {}, self.shipped), self.shipped)
|
||||||
(folder / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
(folder / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
||||||
self.assertEqual(project_ladder_file(str(checkout), self.home, self.shipped), folder / NAME)
|
self.assertEqual(project_ladder_file(str(checkout), self.home, {}, self.shipped), folder / NAME)
|
||||||
self.assertEqual(project_ladder_file(str(self.home), self.home), SHIPPED, "outside a checkout, the ladder this setup ships")
|
self.assertEqual(project_ladder_file(str(self.home), self.home, {}), SHIPPED, "outside a checkout, the ladder this setup ships")
|
||||||
|
|
||||||
def test_another_projects_ladder_is_not_read(self):
|
def test_another_projects_ladder_is_not_read(self):
|
||||||
checkout, other = self.checkout(), self.checkout("other")
|
checkout, other = self.checkout(), self.checkout("other")
|
||||||
write_config(self.home, checkout)
|
write_config(self.home, checkout)
|
||||||
(write_config(self.home, other) / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
(write_config(self.home, other) / NAME).write_text(FABLE_ONLY, encoding="utf-8")
|
||||||
self.assertEqual(project_ladder(str(checkout), self.home, self.shipped), Ladder((Rung("claude-opus-5-5", "medium"),)))
|
self.assertEqual(project_ladder(str(checkout), self.home, {}, self.shipped), Ladder((Rung("claude-opus-5-5", "medium"),)))
|
||||||
|
|
||||||
def test_a_checkout_no_config_names_and_a_folder_outside_any_checkout_run_on_the_shipped_ladder(self):
|
def test_a_checkout_no_config_names_and_a_folder_outside_any_checkout_run_on_the_shipped_ladder(self):
|
||||||
shipped = Ladder((Rung("claude-opus-5-5", "medium"),))
|
shipped = Ladder((Rung("claude-opus-5-5", "medium"),))
|
||||||
self.assertEqual(project_ladder(str(self.checkout()), self.home, self.shipped), shipped)
|
self.assertEqual(project_ladder(str(self.checkout()), self.home, {}, self.shipped), shipped)
|
||||||
self.assertEqual(project_ladder(str(self.home), self.home, self.shipped), shipped)
|
self.assertEqual(project_ladder(str(self.home), self.home, {}, self.shipped), shipped)
|
||||||
|
|
||||||
def test_a_faulty_ladder_of_the_projects_own_fails_and_the_shipped_one_does_not_stand_in(self):
|
def test_a_faulty_ladder_of_the_projects_own_fails_and_the_shipped_one_does_not_stand_in(self):
|
||||||
checkout = self.checkout()
|
checkout = self.checkout()
|
||||||
own = write_config(self.home, checkout) / NAME
|
own = write_config(self.home, checkout) / NAME
|
||||||
own.write_text("[]", encoding="utf-8")
|
own.write_text("[]", encoding="utf-8")
|
||||||
self.assertEqual(project_ladder(str(checkout), self.home, self.shipped).reason.split(". ")[0], f"{own}: it holds no list of rungs")
|
self.assertEqual(project_ladder(str(checkout), self.home, {}, self.shipped).reason.split(". ")[0], f"{own}: it holds no list of rungs")
|
||||||
|
|
||||||
def test_a_faulty_config_fails_since_its_folder_may_hold_the_ladder(self):
|
def test_a_faulty_config_fails_since_its_folder_may_hold_the_ladder(self):
|
||||||
checkout = self.checkout()
|
checkout = self.checkout()
|
||||||
config = write_config(self.home, checkout) / "config.toml"
|
config = write_config(self.home, checkout) / "config.toml"
|
||||||
config.write_text(config.read_text(encoding="utf-8") + 'readme = "checkout:README.md"\n', encoding="utf-8")
|
config.write_text(config.read_text(encoding="utf-8") + 'readme = "checkout:README.md"\n', encoding="utf-8")
|
||||||
self.assertIn("`readme` is not a setting", project_ladder(str(checkout), self.home, self.shipped).reason)
|
self.assertIn("`readme` is not a setting", project_ladder(str(checkout), self.home, {}, self.shipped).reason)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ usage: notify [<message>]
|
|||||||
|
|
||||||
Sends <message>, or else stdin, through the notifier that a project's config names, from the bot to the
|
Sends <message>, or else stdin, through the notifier that a project's config names, from the bot to the
|
||||||
recipient that the project's env file names. Run it inside the project's checkout, or a worktree of it.
|
recipient that the project's env file names. Run it inside the project's checkout, or a worktree of it.
|
||||||
The project's config, ~/.claude-projects/<key>/config.toml, sets `notifier` to "mattermost" or "slack"
|
The project's config, ~/.config/build-release/<key>/config.toml, sets `notifier` to "mattermost" or "slack"
|
||||||
and `env-file` to a path outside the checkout and the config's folder, such as
|
and `env-file` to a path outside the checkout and the config's folder, such as
|
||||||
"~/.claude-projects/<key>.env". The env file holds the notifier's KEY=value lines, and only its owner
|
"~/.config/build-release/<key>.env". The env file holds the notifier's KEY=value lines, and only its owner
|
||||||
may read it, since it holds the bot's token. For mattermost:
|
may read it, since it holds the bot's token. For mattermost:
|
||||||
|
|
||||||
MATTERMOST_URL=https://chat.example
|
MATTERMOST_URL=https://chat.example
|
||||||
@@ -25,6 +25,8 @@ Exit 2, saying why, on misuse: bad arguments, an empty message, a directory with
|
|||||||
a config that sets no `notifier` or no `env-file`, or an env file that is missing or unreadable, lacks
|
a config that sets no `notifier` or no `env-file`, or an env file that is missing or unreadable, lacks
|
||||||
a key, names a Mattermost server off https, or that others may read. None of these messages holds the
|
a key, names a Mattermost server off https, or that others may read. None of these messages holds the
|
||||||
token.
|
token.
|
||||||
|
|
||||||
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path.
|
||||||
"""
|
"""
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
|
|||||||
@@ -43,18 +43,18 @@ def sender_of(project: ProjectConfig, backends: typing.Mapping[Notifier, Backend
|
|||||||
return lambda message: backend.send(config, message, backend.http)
|
return lambda message: backend.send(config, message, backend.http)
|
||||||
|
|
||||||
|
|
||||||
def notify(text: str, directory: str | None, home: pathlib.Path, backends: typing.Mapping[Notifier, Backend[typing.Any]]) -> Failure | None:
|
def notify(text: str, directory: str | None, home: pathlib.Path, env: typing.Mapping[str, str], backends: typing.Mapping[Notifier, Backend[typing.Any]]) -> Failure | None:
|
||||||
"""Sends text through the notifier of the project whose checkout holds directory.
|
"""Sends text through the notifier of the project whose checkout holds directory.
|
||||||
|
|
||||||
The DM is skipped where the config names no notifier, since the project hasn't asked for DMs. It is skipped too where no config can be read: build-release has stopped with that reason, and without a config there is no notifier to ask."""
|
The DM is skipped where the config names no notifier, since the project hasn't asked for DMs. It is skipped too where no config can be read: build-release has stopped with that reason, and without a config there is no notifier to ask."""
|
||||||
project = located(directory, home)
|
project = located(directory, home, env)
|
||||||
if isinstance(project, Failure) or project.notifier is None:
|
if isinstance(project, Failure) or project.notifier is None:
|
||||||
return None
|
return None
|
||||||
sender = sender_of(project, backends)
|
sender = sender_of(project, backends)
|
||||||
return sender if isinstance(sender, Failure) else sender(text)
|
return sender if isinstance(sender, Failure) else sender(text)
|
||||||
|
|
||||||
|
|
||||||
def sender_in(directory: str | None, home: pathlib.Path, backends: typing.Mapping[Notifier, Backend[typing.Any]]) -> Sender | Failure:
|
def sender_in(directory: str | None, home: pathlib.Path, env: typing.Mapping[str, str], backends: typing.Mapping[Notifier, Backend[typing.Any]]) -> Sender | Failure:
|
||||||
"""sender_of the project whose checkout holds directory."""
|
"""sender_of the project whose checkout holds directory."""
|
||||||
project = located(directory, home)
|
project = located(directory, home, env)
|
||||||
return project if isinstance(project, Failure) else sender_of(project, backends)
|
return project if isinstance(project, Failure) else sender_of(project, backends)
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ class Project(unittest.TestCase):
|
|||||||
self.folder = configured(self, self.checkout, home=self.home)
|
self.folder = configured(self, self.checkout, home=self.home)
|
||||||
|
|
||||||
def name_notifier(self, notifier: str | None, keys: str | None = None) -> pathlib.Path:
|
def name_notifier(self, notifier: str | None, keys: str | None = None) -> pathlib.Path:
|
||||||
"""Makes the config name ~/.claude-projects/proj.env as its env file, and the notifier where there is one; the file holds keys where that is not None."""
|
"""Makes the config name ~/.config/build-release/proj.env as its env file, and the notifier where there is one; the file holds keys where that is not None."""
|
||||||
with (self.folder / "config.toml").open("a") as config:
|
with (self.folder / "config.toml").open("a") as config:
|
||||||
config.write('env-file = "~/.claude-projects/proj.env"\n' + (f'notifier = "{notifier}"\n' if notifier else ""))
|
config.write('env-file = "~/.config/build-release/proj.env"\n' + (f'notifier = "{notifier}"\n' if notifier else ""))
|
||||||
path = self.home / ".claude-projects" / "proj.env"
|
path = self.home / ".config/build-release" / "proj.env"
|
||||||
if keys is not None:
|
if keys is not None:
|
||||||
path.write_text(keys)
|
path.write_text(keys)
|
||||||
path.chmod(0o600)
|
path.chmod(0o600)
|
||||||
@@ -61,13 +61,13 @@ class Notify(Project):
|
|||||||
def test_sends_through_mattermost_where_the_config_names_it(self):
|
def test_sends_through_mattermost_where_the_config_names_it(self):
|
||||||
self.name_notifier("mattermost", MATTERMOST_KEYS)
|
self.name_notifier("mattermost", MATTERMOST_KEYS)
|
||||||
server = mattermost()
|
server = mattermost()
|
||||||
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, through("mattermost", server)))
|
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, {}, through("mattermost", server)))
|
||||||
self.assertEqual(server.requests[-1], MATTERMOST_POST)
|
self.assertEqual(server.requests[-1], MATTERMOST_POST)
|
||||||
|
|
||||||
def test_sends_through_slack_where_the_config_names_it(self):
|
def test_sends_through_slack_where_the_config_names_it(self):
|
||||||
self.name_notifier("slack", SLACK_KEYS)
|
self.name_notifier("slack", SLACK_KEYS)
|
||||||
slack = Slack({"ok": True})
|
slack = Slack({"ok": True})
|
||||||
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, through("slack", slack)))
|
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, {}, through("slack", slack)))
|
||||||
self.assertEqual(slack.requests, [SLACK_POST])
|
self.assertEqual(slack.requests, [SLACK_POST])
|
||||||
|
|
||||||
def test_build_releases_dm_goes_through_the_notifier_for_the_project_holding_the_current_directory(self):
|
def test_build_releases_dm_goes_through_the_notifier_for_the_project_holding_the_current_directory(self):
|
||||||
@@ -87,7 +87,7 @@ class Notify(Project):
|
|||||||
def test_skips_the_notice_for_a_project_that_names_no_notifier_even_where_its_env_file_holds_the_keys(self):
|
def test_skips_the_notice_for_a_project_that_names_no_notifier_even_where_its_env_file_holds_the_keys(self):
|
||||||
self.name_notifier(None, MATTERMOST_KEYS)
|
self.name_notifier(None, MATTERMOST_KEYS)
|
||||||
server = mattermost()
|
server = mattermost()
|
||||||
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, through("mattermost", server)))
|
self.assertIsNone(notify.notify("Which one?", str(self.checkout), self.home, {}, through("mattermost", server)))
|
||||||
self.assertEqual(server.requests, [])
|
self.assertEqual(server.requests, [])
|
||||||
|
|
||||||
def test_skips_the_notice_where_no_config_names_the_checkout_since_build_release_stops_on_that_itself(self):
|
def test_skips_the_notice_where_no_config_names_the_checkout_since_build_release_stops_on_that_itself(self):
|
||||||
@@ -95,32 +95,32 @@ class Notify(Project):
|
|||||||
other.mkdir()
|
other.mkdir()
|
||||||
subprocess.run(["git", "init", "--quiet", str(other)], check=True, env=isolated_env())
|
subprocess.run(["git", "init", "--quiet", str(other)], check=True, env=isolated_env())
|
||||||
server = mattermost()
|
server = mattermost()
|
||||||
self.assertIsNone(notify.notify("Which one?", str(other), self.home, through("mattermost", server)))
|
self.assertIsNone(notify.notify("Which one?", str(other), self.home, {}, through("mattermost", server)))
|
||||||
self.assertEqual(server.requests, [])
|
self.assertEqual(server.requests, [])
|
||||||
|
|
||||||
def test_fails_naming_the_file_or_the_key_where_the_env_file_is_missing_or_wrong(self):
|
def test_fails_naming_the_file_or_the_key_where_the_env_file_is_missing_or_wrong(self):
|
||||||
path = self.name_notifier("slack")
|
path = self.name_notifier("slack")
|
||||||
self.assertEqual(notify.notify("hi", str(self.checkout), self.home, through("slack", Slack({"ok": True}))), Failure(f"{path} does not exist; it needs SLACK_TOKEN and SLACK_RECIPIENT"))
|
self.assertEqual(notify.notify("hi", str(self.checkout), self.home, {}, through("slack", Slack({"ok": True}))), Failure(f"{path} does not exist; it needs SLACK_TOKEN and SLACK_RECIPIENT"))
|
||||||
path.write_text("SLACK_TOKEN=xoxb-secret\n")
|
path.write_text("SLACK_TOKEN=xoxb-secret\n")
|
||||||
path.chmod(0o600)
|
path.chmod(0o600)
|
||||||
self.assertEqual(notify.notify("hi", str(self.checkout), self.home, through("slack", Slack({"ok": True}))), Failure(f"{path} lacks SLACK_RECIPIENT"))
|
self.assertEqual(notify.notify("hi", str(self.checkout), self.home, {}, through("slack", Slack({"ok": True}))), Failure(f"{path} lacks SLACK_RECIPIENT"))
|
||||||
|
|
||||||
def test_the_failure_for_an_unreachable_server_names_the_server_and_not_the_token(self):
|
def test_the_failure_for_an_unreachable_server_names_the_server_and_not_the_token(self):
|
||||||
self.name_notifier("mattermost", MATTERMOST_KEYS.replace("https://chat.example", "https://127.0.0.1:1"))
|
self.name_notifier("mattermost", MATTERMOST_KEYS.replace("https://chat.example", "https://127.0.0.1:1"))
|
||||||
failed = notify.notify("Which one?", str(self.checkout), self.home, notify.BACKENDS)
|
failed = notify.notify("Which one?", str(self.checkout), self.home, {}, notify.BACKENDS)
|
||||||
assert isinstance(failed, Failure), failed
|
assert isinstance(failed, Failure), failed
|
||||||
self.assertIn("cannot reach https://127.0.0.1:1", failed.reason)
|
self.assertIn("cannot reach https://127.0.0.1:1", failed.reason)
|
||||||
self.assertNotIn("secret-token", failed.reason)
|
self.assertNotIn("secret-token", failed.reason)
|
||||||
|
|
||||||
def test_sender_in_fails_for_an_env_file_that_no_notifier_reads(self):
|
def test_sender_in_fails_for_an_env_file_that_no_notifier_reads(self):
|
||||||
self.name_notifier(None, MATTERMOST_KEYS)
|
self.name_notifier(None, MATTERMOST_KEYS)
|
||||||
failed = notify.sender_in(str(self.checkout), self.home, notify.BACKENDS)
|
failed = notify.sender_in(str(self.checkout), self.home, {}, notify.BACKENDS)
|
||||||
assert isinstance(failed, Failure), failed
|
assert isinstance(failed, Failure), failed
|
||||||
self.assertIn("sets no `notifier`", failed.reason)
|
self.assertIn("sets no `notifier`", failed.reason)
|
||||||
|
|
||||||
def test_sender_of_names_the_missing_env_file_for_a_config_built_by_hand_with_a_notifier_and_none(self):
|
def test_sender_of_names_the_missing_env_file_for_a_config_built_by_hand_with_a_notifier_and_none(self):
|
||||||
self.name_notifier("slack", SLACK_KEYS)
|
self.name_notifier("slack", SLACK_KEYS)
|
||||||
project = located(str(self.checkout), self.home)
|
project = located(str(self.checkout), self.home, {})
|
||||||
assert not isinstance(project, Failure), project
|
assert not isinstance(project, Failure), project
|
||||||
failed = notify.sender_of(dataclasses.replace(project, env_file=None), notify.BACKENDS)
|
failed = notify.sender_of(dataclasses.replace(project, env_file=None), notify.BACKENDS)
|
||||||
self.assertEqual(failed, Failure(f"{self.folder / 'config.toml'} sets `notifier` but no `env-file`, the file that holds its credentials"))
|
self.assertEqual(failed, Failure(f"{self.folder / 'config.toml'} sets `notifier` but no `env-file`, the file that holds its credentials"))
|
||||||
@@ -129,10 +129,10 @@ class Notify(Project):
|
|||||||
other = self.home / "code" / "other"
|
other = self.home / "code" / "other"
|
||||||
other.mkdir()
|
other.mkdir()
|
||||||
subprocess.run(["git", "init", "--quiet", str(other)], check=True, env=isolated_env())
|
subprocess.run(["git", "init", "--quiet", str(other)], check=True, env=isolated_env())
|
||||||
self.assertIsInstance(notify.sender_in(str(other), self.home, notify.BACKENDS), Failure)
|
self.assertIsInstance(notify.sender_in(str(other), self.home, {}, notify.BACKENDS), Failure)
|
||||||
|
|
||||||
def test_sender_in_names_the_settings_to_add_where_the_config_names_no_notifier(self):
|
def test_sender_in_names_the_settings_to_add_where_the_config_names_no_notifier(self):
|
||||||
failed = notify.sender_in(str(self.checkout), self.home, notify.BACKENDS)
|
failed = notify.sender_in(str(self.checkout), self.home, {}, notify.BACKENDS)
|
||||||
assert isinstance(failed, Failure), failed
|
assert isinstance(failed, Failure), failed
|
||||||
self.assertEqual(failed.reason, f"{self.folder / 'config.toml'} sets no `notifier`; set `notifier` to mattermost or slack, and `env-file` to the file that holds that service's keys (mattermost: MATTERMOST_URL, MATTERMOST_TOKEN, MATTERMOST_RECIPIENT; slack: SLACK_TOKEN, SLACK_RECIPIENT)")
|
self.assertEqual(failed.reason, f"{self.folder / 'config.toml'} sets no `notifier`; set `notifier` to mattermost or slack, and `env-file` to the file that holds that service's keys (mattermost: MATTERMOST_URL, MATTERMOST_TOKEN, MATTERMOST_RECIPIENT; slack: SLACK_TOKEN, SLACK_RECIPIENT)")
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -6,4 +7,4 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
|||||||
|
|
||||||
from notifier import main, notify
|
from notifier import main, notify
|
||||||
|
|
||||||
sys.exit(main.main(sys.argv[1:], sys.stdin, lambda: notify.sender_in(None, pathlib.Path.home(), notify.BACKENDS), sys.stderr))
|
sys.exit(main.main(sys.argv[1:], sys.stdin, lambda: notify.sender_in(None, pathlib.Path.home(), os.environ, notify.BACKENDS), sys.stderr))
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class CodeHealth(unittest.TestCase):
|
|||||||
pathlib.Path(temp, "docs").mkdir()
|
pathlib.Path(temp, "docs").mkdir()
|
||||||
pathlib.Path(temp, "docs", "comprehension-history.md").write_text(SCORED.format(overall="7.00"))
|
pathlib.Path(temp, "docs", "comprehension-history.md").write_text(SCORED.format(overall="7.00"))
|
||||||
with contextlib.redirect_stderr(io.StringIO()):
|
with contextlib.redirect_stderr(io.StringIO()):
|
||||||
ranked = file_plan(located(temp, folder.parents[1]), todo).rank()
|
ranked = file_plan(located(temp, folder.parents[2], {}), todo).rank()
|
||||||
self.assertIsInstance(ranked, ranking.Ranked)
|
self.assertIsInstance(ranked, ranking.Ranked)
|
||||||
self.assertEqual(ranked.under_bar, [])
|
self.assertEqual(ranked.under_bar, [])
|
||||||
self.assertIn("| code health by 1 | 25.4 |", todo.read_text())
|
self.assertIn("| code health by 1 | 25.4 |", todo.read_text())
|
||||||
@@ -310,10 +310,10 @@ class CodeHealth(unittest.TestCase):
|
|||||||
pathlib.Path(temp, "docs").mkdir()
|
pathlib.Path(temp, "docs").mkdir()
|
||||||
pathlib.Path(temp, "docs", "comprehension-history.md").write_text(SCORED.format(overall="6.50"))
|
pathlib.Path(temp, "docs", "comprehension-history.md").write_text(SCORED.format(overall="6.50"))
|
||||||
with contextlib.redirect_stderr(io.StringIO()):
|
with contextlib.redirect_stderr(io.StringIO()):
|
||||||
ranked = file_plan(located(temp, folder.parents[1]), todo).rank()
|
ranked = file_plan(located(temp, folder.parents[2], {}), todo).rank()
|
||||||
self.assertIsInstance(ranked, ranking.Ranked)
|
self.assertIsInstance(ranked, ranking.Ranked)
|
||||||
self.assertIn("| code health by 1 | 25.4 |", todo.read_text())
|
self.assertIn("| code health by 1 | 25.4 |", todo.read_text())
|
||||||
self.assertEqual(file_plan(located(temp, folder.parents[1]), todo).check(), [])
|
self.assertEqual(file_plan(located(temp, folder.parents[2], {}), todo).check(), [])
|
||||||
|
|
||||||
|
|
||||||
class Risk(unittest.TestCase):
|
class Risk(unittest.TestCase):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from loop_state.paths import CONFIG_FOLDER
|
from loop_state.paths import config_folder
|
||||||
from test_env import isolated_env
|
from test_env import isolated_env
|
||||||
|
|
||||||
CLIENT = """checkout = "~/code/acme-billing"
|
CLIENT = """checkout = "~/code/acme-billing"
|
||||||
@@ -26,14 +26,14 @@ JIRA_SCORING = 'jira-score-formula = "100 * V / (2**S + 8)"\njira-score-bar = 1\
|
|||||||
|
|
||||||
def write_config(home: pathlib.Path, checkout: pathlib.Path, goals: str = "checkout:README.md") -> pathlib.Path:
|
def write_config(home: pathlib.Path, checkout: pathlib.Path, goals: str = "checkout:README.md") -> pathlib.Path:
|
||||||
"""A config under home that names checkout, every setting inside it but goals-and-audience; for the tests of each tool that reads the config."""
|
"""A config under home that names checkout, every setting inside it but goals-and-audience; for the tests of each tool that reads the config."""
|
||||||
folder = home / CONFIG_FOLDER / checkout.name
|
folder = config_folder({}, home) / checkout.name
|
||||||
folder.mkdir(parents=True, exist_ok=True)
|
folder.mkdir(parents=True, exist_ok=True)
|
||||||
(folder / "config.toml").write_text(CLIENT.replace('"~/code/acme-billing"', f'"{checkout}"').replace('"folder:', '"checkout:').replace('"checkout:goals.md"', f'"{goals}"'), encoding="utf-8")
|
(folder / "config.toml").write_text(CLIENT.replace('"~/code/acme-billing"', f'"{checkout}"').replace('"folder:', '"checkout:').replace('"checkout:goals.md"', f'"{goals}"'), encoding="utf-8")
|
||||||
return folder
|
return folder
|
||||||
|
|
||||||
|
|
||||||
def configured(test: unittest.TestCase, checkout: pathlib.Path, goals: str = "checkout:README.md", home: pathlib.Path | None = None) -> pathlib.Path:
|
def configured(test: unittest.TestCase, checkout: pathlib.Path, goals: str = "checkout:README.md", home: pathlib.Path | None = None) -> pathlib.Path:
|
||||||
"""Makes checkout a git checkout that a config names, under home, else under a folder of its own for the rest of the test; the config's folder, two levels under that home."""
|
"""Makes checkout a git checkout that a config names, under home, else under a folder of its own for the rest of the test; the config's folder, three levels under that home."""
|
||||||
subprocess.run(["git", "init", "--quiet", str(checkout)], check=True, env=isolated_env())
|
subprocess.run(["git", "init", "--quiet", str(checkout)], check=True, env=isolated_env())
|
||||||
if home is None:
|
if home is None:
|
||||||
made = tempfile.TemporaryDirectory()
|
made = tempfile.TemporaryDirectory()
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
usage: project-config [<setting>]
|
usage: project-config [<setting>]
|
||||||
|
|
||||||
Run inside a checkout, or a worktree of one. It finds the config that names the checkout,
|
Run inside a checkout, or a worktree of one. It finds the config that names the checkout,
|
||||||
~/.claude-projects/<key>/config.toml, and prints each setting and its absolute path, as in
|
~/.config/build-release/<key>/config.toml, and prints each setting and its absolute path, as in
|
||||||
`plan: /home/me/code/acme/todo.md`. Given a setting, it prints only that setting's path.
|
`plan: /home/me/code/acme/todo.md`. Given a setting, it prints only that setting's path.
|
||||||
|
|
||||||
`~/.claude-projects/do-epic/` holds do-epic's machine-wide settings, not a project's. It needs no `checkout`,
|
`~/.config/build-release/do-epic/` holds do-epic's machine-wide settings, not a project's. It needs no `checkout`,
|
||||||
and project-config doesn't read anything from it, so no project may use `do-epic` as its key.
|
and project-config doesn't read anything from it, so no project may use `do-epic` as its key.
|
||||||
|
|
||||||
The config is TOML. `checkout` names the project's main checkout, and every setting in the example below is a path:
|
The config is TOML. `checkout` names the project's main checkout, and every setting in the example below is a path:
|
||||||
@@ -74,7 +74,7 @@ rule-hook ranks a plan kept as a file before tool calls, and a read from Conflue
|
|||||||
|
|
||||||
`env-file` is an optional setting: the file of KEY=value credentials the project's tools read,
|
`env-file` is an optional setting: the file of KEY=value credentials the project's tools read,
|
||||||
a path that starts with / or ~/ and lies outside the checkout and the config's folder, such as
|
a path that starts with / or ~/ and lies outside the checkout and the config's folder, such as
|
||||||
"~/.claude-projects/acme-billing.env". Where it is left out, the project has no credentials file, and
|
"~/.config/build-release/acme-billing.env". Where it is left out, the project has no credentials file, and
|
||||||
a tool that needs one fails naming the setting. It is printed with the others only where it is set.
|
a tool that needs one fails naming the setting. It is printed with the others only where it is set.
|
||||||
|
|
||||||
`touch-predictions` is an optional setting, a path spelt as the others are, never a page: the record
|
`touch-predictions` is an optional setting, a path spelt as the others are, never a page: the record
|
||||||
@@ -178,7 +178,11 @@ without a `plan` in Jira, names a Jira `plan` and leaves out `jira-score-formula
|
|||||||
one of those two without a `plan` in Jira, sets the formula to one that doesn't parse or the bar to anything
|
one of those two without a `plan` in Jira, sets the formula to one that doesn't parse or the bar to anything
|
||||||
but a number, sets `readability-floor` to anything but a number
|
but a number, sets `readability-floor` to anything but a number
|
||||||
from 1 to 10, sets `parallel-chunks` to anything but a whole number of 1 or more, or sets `jira-finding-type` to anything but a name or without a `plan` in Jira, and where `bench-tasks`, `coding-conventions`, `env-file`, `epic-branch`, `jira-finish-transition`, `jira-finish-status`, `notifier`, `review-request-comment` or `touch-predictions` is asked for and not set. No path setting has a default.
|
from 1 to 10, sets `parallel-chunks` to anything but a whole number of 1 or more, or sets `jira-finding-type` to anything but a name or without a `plan` in Jira, and where `bench-tasks`, `coding-conventions`, `env-file`, `epic-branch`, `jira-finish-transition`, `jira-finish-status`, `notifier`, `review-request-comment` or `touch-predictions` is asked for and not set. No path setting has a default.
|
||||||
|
|
||||||
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path.
|
||||||
"""
|
"""
|
||||||
|
from collections.abc import Mapping
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -195,7 +199,7 @@ def main(argv: list[str]) -> int:
|
|||||||
if len(argv) > 1 or (argv and argv[0] not in (*SETTINGS, *OPTIONAL)):
|
if len(argv) > 1 or (argv and argv[0] not in (*SETTINGS, *OPTIONAL)):
|
||||||
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join((*SETTINGS, *OPTIONAL))}", file=sys.stderr)
|
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join((*SETTINGS, *OPTIONAL))}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
config = located(None, pathlib.Path.home())
|
config = located(None, pathlib.Path.home(), os.environ)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
print(config.reason, file=sys.stderr)
|
print(config.reason, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
@@ -216,7 +220,7 @@ def main(argv: list[str]) -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def located(directory: str | None, home: pathlib.Path, run: Git = git) -> ProjectConfig | Failure:
|
def located(directory: str | None, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> ProjectConfig | Failure:
|
||||||
"""The config under home of the checkout that holds directory, else the current directory."""
|
"""The config under home of the checkout that holds directory, else the current directory."""
|
||||||
found = run("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir", cwd=directory)
|
found = run("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir", cwd=directory)
|
||||||
if isinstance(found, Failure):
|
if isinstance(found, Failure):
|
||||||
@@ -224,12 +228,12 @@ def located(directory: str | None, home: pathlib.Path, run: Git = git) -> Projec
|
|||||||
if len(lines := found.splitlines()) != 2:
|
if len(lines := found.splitlines()) != 2:
|
||||||
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
|
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
|
||||||
# The common dir is the main checkout's .git, whichever worktree runs this.
|
# The common dir is the main checkout's .git, whichever worktree runs this.
|
||||||
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, home)
|
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, home, env)
|
||||||
|
|
||||||
|
|
||||||
def title_templates(directory: str | None, home: pathlib.Path, run: Git = git) -> templates.Titles | Failure:
|
def title_templates(directory: str | None, home: pathlib.Path, env: Mapping[str, str], run: Git = git) -> templates.Titles | Failure:
|
||||||
"""The title templates of the project whose checkout holds directory, else the current directory. Bare summaries where no config names a checkout there, as in a third party's clone, so every title is read as it stands. A Failure where a config is faulty or cannot be read: read bare, a templated project's round titles would count for nothing."""
|
"""The title templates of the project whose checkout holds directory, else the current directory. Bare summaries where no config names a checkout there, as in a third party's clone, so every title is read as it stands. A Failure where a config is faulty or cannot be read: read bare, a templated project's round titles would count for nothing."""
|
||||||
config = located(directory, home, run)
|
config = located(directory, home, env, run)
|
||||||
if isinstance(config, Unnamed):
|
if isinstance(config, Unnamed):
|
||||||
return templates.BARE
|
return templates.BARE
|
||||||
return config if isinstance(config, Failure) else config.titles
|
return config if isinstance(config, Failure) else config.titles
|
||||||
@@ -237,5 +241,5 @@ def title_templates(directory: str | None, home: pathlib.Path, run: Git = git) -
|
|||||||
|
|
||||||
def project() -> ProjectConfig | Failure:
|
def project() -> ProjectConfig | Failure:
|
||||||
"""The config of the project whose checkout holds the current directory, under the user's home."""
|
"""The config of the project whose checkout holds the current directory, under the user's home."""
|
||||||
return located(None, pathlib.Path.home())
|
return located(None, pathlib.Path.home(), os.environ)
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
"""A project's settings, read from the one config that names its checkout: `~/.claude-projects/<key>/config.toml`.
|
"""A project's settings, read from the one config that names its checkout: `<key>/config.toml` in the config folder, `~/.config/build-release/` unless `XDG_CONFIG_HOME` holds an absolute path.
|
||||||
|
|
||||||
No path setting has a default, so that a client's project never runs on another project's files: a missing config or setting is a Failure that names it."""
|
No path setting has a default, so that a client's project never runs on another project's files: a missing config or setting is a Failure that names it."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import decimal
|
import decimal
|
||||||
|
from collections.abc import Mapping
|
||||||
import math
|
import math
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import tomllib
|
import tomllib
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from loop_state.paths import CONFIG_FOLDER
|
from loop_state.paths import config_folder
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from plan.formula import parse_formula
|
from plan.formula import parse_formula
|
||||||
from plan.todo_table import SHAPE
|
from plan.todo_table import SHAPE
|
||||||
from project_config import templates
|
from project_config import templates
|
||||||
from plan.ranking import variables
|
from plan.ranking import variables
|
||||||
|
|
||||||
PROJECTS = CONFIG_FOLDER
|
|
||||||
CONFIG = "config.toml"
|
CONFIG = "config.toml"
|
||||||
# The key of do-epic's machine-wide settings: the folder's config.toml has no `checkout`, so no project may use the key.
|
# The key of do-epic's machine-wide settings: the folder's config.toml has no `checkout`, so no project may use the key.
|
||||||
DO_EPIC = "do-epic"
|
DO_EPIC = "do-epic"
|
||||||
@@ -133,7 +133,7 @@ class Unnamed(Failure):
|
|||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class ProjectConfig:
|
class ProjectConfig:
|
||||||
"""folder is `~/.claude-projects/<key>`, top is the worktree that asked, and paths holds each of SETTINGS as an absolute path, except three kinds that pages or epics hold instead: `plan` and `goals-and-audience` where they are kept in Jira, and a record kept on a Confluence page."""
|
"""folder is `<key>` in the config folder, top is the worktree that asked, and paths holds each of SETTINGS as an absolute path, except three kinds that pages or epics hold instead: `plan` and `goals-and-audience` where they are kept in Jira, and a record kept on a Confluence page."""
|
||||||
key: str
|
key: str
|
||||||
folder: pathlib.Path
|
folder: pathlib.Path
|
||||||
top: pathlib.Path
|
top: pathlib.Path
|
||||||
@@ -203,13 +203,13 @@ class ProjectConfig:
|
|||||||
return path.relative_to(self.top).as_posix() if path.is_relative_to(self.top) else None
|
return path.relative_to(self.top).as_posix() if path.is_relative_to(self.top) else None
|
||||||
|
|
||||||
|
|
||||||
def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectConfig | Failure:
|
def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path, env: Mapping[str, str]) -> ProjectConfig | Failure:
|
||||||
"""The config that names main, the project's main checkout.
|
"""The config that names main, the project's main checkout.
|
||||||
|
|
||||||
top is the worktree that asks, and main itself outside a worktree. A `checkout:` path lands in top.
|
top is the worktree that asks, and main itself outside a worktree. A `checkout:` path lands in top.
|
||||||
A config that cannot be read fails every project, since it may be the one that names main."""
|
A config that cannot be read fails every project, since it may be the one that names main."""
|
||||||
named: list[tuple[pathlib.Path, dict[str, object]]] = []
|
named: list[tuple[pathlib.Path, dict[str, object]]] = []
|
||||||
for file in configs(home):
|
for file in configs(home, env):
|
||||||
config = read(file, home)
|
config = read(file, home)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
@@ -217,7 +217,7 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
|
|||||||
if config[0].resolve() == main.resolve():
|
if config[0].resolve() == main.resolve():
|
||||||
named.append((file, config[1]))
|
named.append((file, config[1]))
|
||||||
if not named:
|
if not named:
|
||||||
return Unnamed(f"no config names the checkout {main}: write ~/{PROJECTS}/<key>/{CONFIG}, as `project-config --help` shows")
|
return Unnamed(f"no config names the checkout {main}: write {config_folder(env, home)}/<key>/{CONFIG}, as `project-config --help` shows")
|
||||||
if len(named) > 1:
|
if len(named) > 1:
|
||||||
return Failure(f"{' and '.join(str(file) for file, _ in named)} each name the checkout {main}; only one config may")
|
return Failure(f"{' and '.join(str(file) for file, _ in named)} each name the checkout {main}; only one config may")
|
||||||
file, values = named[0]
|
file, values = named[0]
|
||||||
@@ -413,20 +413,20 @@ def lies_in(path: pathlib.Path, *places: pathlib.Path) -> bool:
|
|||||||
return any(path.resolve().is_relative_to(place.resolve()) for place in places)
|
return any(path.resolve().is_relative_to(place.resolve()) for place in places)
|
||||||
|
|
||||||
|
|
||||||
def held(folder: pathlib.Path, home: pathlib.Path) -> ProjectConfig | Failure | None:
|
def held(folder: pathlib.Path, home: pathlib.Path, env: Mapping[str, str]) -> ProjectConfig | Failure | None:
|
||||||
"""The config in folder, read as its project's main checkout reads it; None where folder is not a config's folder under home."""
|
"""The config in folder, read as its project's main checkout reads it; None where folder is not a config's folder under home."""
|
||||||
# Matched on resolved paths, as git names a folder, so a config's folder reached through a symlink is still found.
|
# Matched on resolved paths, as git names a folder, so a config's folder reached through a symlink is still found.
|
||||||
file = next((file for file in configs(home) if file.parent.resolve() == folder.resolve()), None)
|
file = next((file for file in configs(home, env) if file.parent.resolve() == folder.resolve()), None)
|
||||||
if file is None:
|
if file is None:
|
||||||
return None
|
return None
|
||||||
config = read(file, home)
|
config = read(file, home)
|
||||||
return config if isinstance(config, Failure) else load(config[0], config[0], home)
|
return config if isinstance(config, Failure) else load(config[0], config[0], home, env)
|
||||||
|
|
||||||
|
|
||||||
def by_name(name: str, home: pathlib.Path) -> ProjectConfig | Failure | None:
|
def by_name(name: str, home: pathlib.Path, env: Mapping[str, str]) -> ProjectConfig | Failure | None:
|
||||||
"""The config of the project whose main checkout is a folder called name, though that folder may not exist yet, loaded as `held` does; None where no config names one. A config that cannot be read fails every name, since it may be the one asked for."""
|
"""The config of the project whose main checkout is a folder called name, though that folder may not exist yet, loaded as `held` does; None where no config names one. A config that cannot be read fails every name, since it may be the one asked for."""
|
||||||
files = []
|
files = []
|
||||||
for file in configs(home):
|
for file in configs(home, env):
|
||||||
config = read(file, home)
|
config = read(file, home)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
@@ -434,17 +434,17 @@ def by_name(name: str, home: pathlib.Path) -> ProjectConfig | Failure | None:
|
|||||||
files.append(file)
|
files.append(file)
|
||||||
if len(files) > 1:
|
if len(files) > 1:
|
||||||
return Failure(f"{' and '.join(str(file) for file in files)} each name a checkout called {name}; only one config may")
|
return Failure(f"{' and '.join(str(file) for file in files)} each name a checkout called {name}; only one config may")
|
||||||
return held(files[0].parent, home) if files else None
|
return held(files[0].parent, home, env) if files else None
|
||||||
|
|
||||||
|
|
||||||
def configs(home: pathlib.Path) -> list[pathlib.Path]:
|
def configs(home: pathlib.Path, env: Mapping[str, str]) -> list[pathlib.Path]:
|
||||||
"""Every project's config file under home, in key order. do-epic's machine-wide config is not a project's."""
|
"""Every project's config file in the config folder, in key order. do-epic's machine-wide config is not a project's."""
|
||||||
return sorted(file for file in (home / PROJECTS).glob(f"*/{CONFIG}") if file.parent.name != DO_EPIC)
|
return sorted(file for file in config_folder(env, home).glob(f"*/{CONFIG}") if file.parent.name != DO_EPIC)
|
||||||
|
|
||||||
|
|
||||||
def env_files(home: pathlib.Path) -> list[pathlib.Path]:
|
def env_files(home: pathlib.Path, env: Mapping[str, str]) -> list[pathlib.Path]:
|
||||||
"""Every config's env-file, do-epic's included. Each is read without the checks load makes, so a config that fails them still keeps its credentials guarded. A config that can't be read doesn't name one."""
|
"""Every config's env-file, do-epic's included. Each is read without the checks load makes, so a config that fails them still keeps its credentials guarded. A config that can't be read doesn't name one."""
|
||||||
values = [parsed(file) for file in (*configs(home), home / PROJECTS / DO_EPIC / CONFIG)]
|
values = [parsed(file) for file in (*configs(home, env), config_folder(env, home) / DO_EPIC / CONFIG)]
|
||||||
return [path for found in values if not isinstance(found, Failure) and (path := anywhere(found.get(ENV_FILE), home))]
|
return [path for found in values if not isinstance(found, Failure) and (path := anywhere(found.get(ENV_FILE), home))]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ConfigCase(unittest.TestCase):
|
|||||||
self.checkout.mkdir(parents=True)
|
self.checkout.mkdir(parents=True)
|
||||||
|
|
||||||
def write(self, key: str, text: str) -> pathlib.Path:
|
def write(self, key: str, text: str) -> pathlib.Path:
|
||||||
folder = self.home / ".claude-projects" / key
|
folder = self.home / ".config/build-release" / key
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
(folder / "config.toml").write_text(text, encoding="utf-8")
|
(folder / "config.toml").write_text(text, encoding="utf-8")
|
||||||
return folder
|
return folder
|
||||||
@@ -37,14 +37,14 @@ class ConfigCase(unittest.TestCase):
|
|||||||
|
|
||||||
class LoadTest(ConfigCase):
|
class LoadTest(ConfigCase):
|
||||||
def failure(self, top: pathlib.Path | None = None) -> str:
|
def failure(self, top: pathlib.Path | None = None) -> str:
|
||||||
found = load(top or self.checkout, self.checkout, self.home)
|
found = load(top or self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
return found.reason
|
return found.reason
|
||||||
|
|
||||||
def test_resolves_each_setting_by_its_prefix(self) -> None:
|
def test_resolves_each_setting_by_its_prefix(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
self.write("other", CLIENT.replace("acme-billing", "other"))
|
self.write("other", CLIENT.replace("acme-billing", "other"))
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.key, found.folder), ("acme", folder))
|
self.assertEqual((found.key, found.folder), ("acme", folder))
|
||||||
self.assertEqual(found.paths["plan"], folder / "todo.md")
|
self.assertEqual(found.paths["plan"], folder / "todo.md")
|
||||||
@@ -57,13 +57,13 @@ class LoadTest(ConfigCase):
|
|||||||
def test_the_do_epic_folder_is_no_projects_config_so_it_needs_no_checkout(self) -> None:
|
def test_the_do_epic_folder_is_no_projects_config_so_it_needs_no_checkout(self) -> None:
|
||||||
self.write("do-epic", 'jira-url = "https://acme.atlassian.net"\n')
|
self.write("do-epic", 'jira-url = "https://acme.atlassian.net"\n')
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.key, "acme")
|
self.assertEqual(found.key, "acme")
|
||||||
|
|
||||||
def test_a_plan_spelt_as_a_jira_epic_is_no_path(self) -> None:
|
def test_a_plan_spelt_as_a_jira_epic_is_no_path(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT)
|
self.write("acme", JIRA_CLIENT)
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.epic, Epic("https://acme.atlassian.net", "ABC-12"))
|
self.assertEqual(found.epic, Epic("https://acme.atlassian.net", "ABC-12"))
|
||||||
self.assertEqual((found.plan_file, found.tracked("plan"), found.plan_label), (None, None, JIRA_PLAN))
|
self.assertEqual((found.plan_file, found.tracked("plan"), found.plan_label), (None, None, JIRA_PLAN))
|
||||||
@@ -73,7 +73,7 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_a_plan_kept_as_a_file_has_no_epic(self) -> None:
|
def test_a_plan_kept_as_a_file_has_no_epic(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.epic, found.plan_file, found.plan_label, found.places["plan"]), (None, folder / "todo.md", str(folder / "todo.md"), str(folder / "todo.md")))
|
self.assertEqual((found.epic, found.plan_file, found.plan_label, found.places["plan"]), (None, folder / "todo.md", str(folder / "todo.md"), str(folder / "todo.md")))
|
||||||
|
|
||||||
@@ -88,12 +88,12 @@ class LoadTest(ConfigCase):
|
|||||||
reason = self.failure()
|
reason = self.failure()
|
||||||
self.assertIn(f"`plan` is {spelled!r}, not ", reason)
|
self.assertIn(f"`plan` is {spelled!r}, not ", reason)
|
||||||
self.assertIn("jira:https://<site>/browse/<epic's key>", reason)
|
self.assertIn("jira:https://<site>/browse/<epic's key>", reason)
|
||||||
for config in (self.home / ".claude-projects").glob("*/config.toml"):
|
for config in (self.home / ".config/build-release").glob("*/config.toml"):
|
||||||
config.unlink()
|
config.unlink()
|
||||||
|
|
||||||
def test_goals_and_audience_spelt_as_a_jira_epic_is_no_path(self) -> None:
|
def test_goals_and_audience_spelt_as_a_jira_epic_is_no_path(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT.replace("folder:goals.md", "jira:https://acme.atlassian.net/browse/ABC-7"))
|
self.write("acme", JIRA_CLIENT.replace("folder:goals.md", "jira:https://acme.atlassian.net/browse/ABC-7"))
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.goals_epic, Epic("https://acme.atlassian.net", "ABC-7"))
|
self.assertEqual(found.goals_epic, Epic("https://acme.atlassian.net", "ABC-7"))
|
||||||
self.assertEqual(found.places["goals-and-audience"], "jira:https://acme.atlassian.net/browse/ABC-7")
|
self.assertEqual(found.places["goals-and-audience"], "jira:https://acme.atlassian.net/browse/ABC-7")
|
||||||
@@ -102,7 +102,7 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_goals_and_the_plan_may_name_the_same_epic(self) -> None:
|
def test_goals_and_the_plan_may_name_the_same_epic(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT.replace("folder:goals.md", JIRA_PLAN))
|
self.write("acme", JIRA_CLIENT.replace("folder:goals.md", JIRA_PLAN))
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.goals_epic, found.epic)
|
self.assertEqual(found.goals_epic, found.epic)
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_goals_kept_as_a_file_have_no_epic(self) -> None:
|
def test_goals_kept_as_a_file_have_no_epic(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.goals_epic, found.places["goals-and-audience"]), (None, str(folder / "goals.md")))
|
self.assertEqual((found.goals_epic, found.places["goals-and-audience"]), (None, str(folder / "goals.md")))
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_a_record_spelt_as_a_confluence_page_is_no_path_and_prints_as_written(self) -> None:
|
def test_a_record_spelt_as_a_confluence_page_is_no_path_and_prints_as_written(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT.replace("folder:docs/decisions.md", DECISIONS_PAGE))
|
self.write("acme", JIRA_CLIENT.replace("folder:docs/decisions.md", DECISIONS_PAGE))
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.pages, {"decisions": Page("https://acme.atlassian.net", "2293761", DECISIONS_PAGE)})
|
self.assertEqual(found.pages, {"decisions": Page("https://acme.atlassian.net", "2293761", DECISIONS_PAGE)})
|
||||||
self.assertEqual(found.places["decisions"], DECISIONS_PAGE)
|
self.assertEqual(found.places["decisions"], DECISIONS_PAGE)
|
||||||
@@ -140,11 +140,11 @@ class LoadTest(ConfigCase):
|
|||||||
def test_a_confluence_page_may_leave_out_its_title(self) -> None:
|
def test_a_confluence_page_may_leave_out_its_title(self) -> None:
|
||||||
for spelled in ("confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761", "confluence:https://acme.atlassian.net/wiki/spaces/~5b1e/pages/2293761/R%C3%A5d+och+beslut"):
|
for spelled in ("confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761", "confluence:https://acme.atlassian.net/wiki/spaces/~5b1e/pages/2293761/R%C3%A5d+och+beslut"):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
for config in (self.home / ".claude-projects").glob("*/config.toml"):
|
for config in (self.home / ".config/build-release").glob("*/config.toml"):
|
||||||
config.unlink()
|
config.unlink()
|
||||||
config.parent.rmdir()
|
config.parent.rmdir()
|
||||||
self.write("acme", CLIENT.replace("checkout:CHANGELOG.md", spelled) + 'env-file = "~/acme.env"\n')
|
self.write("acme", CLIENT.replace("checkout:CHANGELOG.md", spelled) + 'env-file = "~/acme.env"\n')
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.pages["changelog"].page_id, "2293761")
|
self.assertEqual(found.pages["changelog"].page_id, "2293761")
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ class LoadTest(ConfigCase):
|
|||||||
reason = self.failure()
|
reason = self.failure()
|
||||||
self.assertIn(f"`decisions` is {spelled!r}, not ", reason)
|
self.assertIn(f"`decisions` is {spelled!r}, not ", reason)
|
||||||
self.assertIn("confluence:https://<site>/wiki/spaces/<space>/pages/<page ID>", reason)
|
self.assertIn("confluence:https://<site>/wiki/spaces/<space>/pages/<page ID>", reason)
|
||||||
for config in (self.home / ".claude-projects").glob("*/config.toml"):
|
for config in (self.home / ".config/build-release").glob("*/config.toml"):
|
||||||
config.unlink()
|
config.unlink()
|
||||||
|
|
||||||
def test_only_a_record_may_name_a_confluence_page(self) -> None:
|
def test_only_a_record_may_name_a_confluence_page(self) -> None:
|
||||||
@@ -177,14 +177,14 @@ class LoadTest(ConfigCase):
|
|||||||
def test_a_worktree_finds_the_main_checkouts_config_and_reads_its_own_files(self) -> None:
|
def test_a_worktree_finds_the_main_checkouts_config_and_reads_its_own_files(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
worktree = self.home / "code" / "acme-billing-item-3"
|
worktree = self.home / "code" / "acme-billing-item-3"
|
||||||
found = load(worktree, self.checkout, self.home)
|
found = load(worktree, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.paths["changelog"], worktree / "CHANGELOG.md")
|
self.assertEqual(found.paths["changelog"], worktree / "CHANGELOG.md")
|
||||||
|
|
||||||
def test_names_a_file_in_the_checkout_as_git_does_and_none_outside_it(self) -> None:
|
def test_names_a_file_in_the_checkout_as_git_does_and_none_outside_it(self) -> None:
|
||||||
self.write("acme", CLIENT.replace("folder:docs/decisions.md", "checkout:project/decisions.md"))
|
self.write("acme", CLIENT.replace("folder:docs/decisions.md", "checkout:project/decisions.md"))
|
||||||
worktree = self.home / "code" / "acme-billing-item-3"
|
worktree = self.home / "code" / "acme-billing-item-3"
|
||||||
found = load(worktree, self.checkout, self.home)
|
found = load(worktree, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.tracked("changelog"), "CHANGELOG.md")
|
self.assertEqual(found.tracked("changelog"), "CHANGELOG.md")
|
||||||
self.assertEqual(found.tracked("decisions"), "project/decisions.md")
|
self.assertEqual(found.tracked("decisions"), "project/decisions.md")
|
||||||
@@ -192,7 +192,7 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_an_absolute_checkout_and_path_are_taken_as_written(self) -> None:
|
def test_an_absolute_checkout_and_path_are_taken_as_written(self) -> None:
|
||||||
self.write("acme", CLIENT.replace("~/code/acme-billing", str(self.checkout)).replace("~/.claude/principles", "/srv/principles"))
|
self.write("acme", CLIENT.replace("~/code/acme-billing", str(self.checkout)).replace("~/.claude/principles", "/srv/principles"))
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.paths["principles"], pathlib.Path("/srv/principles"))
|
self.assertEqual(found.paths["principles"], pathlib.Path("/srv/principles"))
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ class LoadTest(ConfigCase):
|
|||||||
(self.home / "work").symlink_to(self.home / "code")
|
(self.home / "work").symlink_to(self.home / "code")
|
||||||
for case, main in {"a symlink": self.home / "work" / "acme-billing", "dots": self.home / "code" / "other" / ".." / "acme-billing"}.items():
|
for case, main in {"a symlink": self.home / "work" / "acme-billing", "dots": self.home / "code" / "other" / ".." / "acme-billing"}.items():
|
||||||
with self.subTest(case=case):
|
with self.subTest(case=case):
|
||||||
self.assertIsInstance(load(main, main, self.home), ProjectConfig)
|
self.assertIsInstance(load(main, main, self.home, {}), ProjectConfig)
|
||||||
|
|
||||||
def test_no_config_fails_naming_the_checkout_and_the_file_to_write(self) -> None:
|
def test_no_config_fails_naming_the_checkout_and_the_file_to_write(self) -> None:
|
||||||
for write_other in (False, True):
|
for write_other in (False, True):
|
||||||
@@ -210,10 +210,10 @@ class LoadTest(ConfigCase):
|
|||||||
self.write("other", CLIENT.replace("acme-billing", "other"))
|
self.write("other", CLIENT.replace("acme-billing", "other"))
|
||||||
reason = self.failure()
|
reason = self.failure()
|
||||||
self.assertIn(str(self.checkout), reason)
|
self.assertIn(str(self.checkout), reason)
|
||||||
self.assertIn("~/.claude-projects/<key>/config.toml", reason)
|
self.assertIn(f"{self.home}/.config/build-release/<key>/config.toml", reason)
|
||||||
|
|
||||||
def test_a_folder_that_is_no_checkout_fails_as_unnamed_with_gits_reason(self) -> None:
|
def test_a_folder_that_is_no_checkout_fails_as_unnamed_with_gits_reason(self) -> None:
|
||||||
outside = located(str(self.checkout), self.home)
|
outside = located(str(self.checkout), self.home, {})
|
||||||
self.assertIsInstance(outside, Unnamed)
|
self.assertIsInstance(outside, Unnamed)
|
||||||
self.assertIn("not a git repository", outside.reason)
|
self.assertIn("not a git repository", outside.reason)
|
||||||
|
|
||||||
@@ -249,77 +249,77 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_env_file_is_the_one_optional_setting_and_names_a_file_outside_the_checkout_and_the_configs_folder(self) -> None:
|
def test_env_file_is_the_one_optional_setting_and_names_a_file_outside_the_checkout_and_the_configs_folder(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertIsNone(found.env_file, "a project that sets none has asked for no credentials, and never falls back to another project's")
|
self.assertIsNone(found.env_file, "a project that sets none has asked for no credentials, and never falls back to another project's")
|
||||||
for case, spelled in {"~/": '"~/.claude-projects/acme.env"', "absolute": f'"{self.home}/.claude-projects/acme.env"'}.items():
|
for case, spelled in {"~/": '"~/.config/build-release/acme.env"', "absolute": f'"{self.home}/.config/build-release/acme.env"'}.items():
|
||||||
with self.subTest(case=case):
|
with self.subTest(case=case):
|
||||||
self.write(f"acme-{case[0]}", CLIENT.replace("acme-billing", f"acme-{case[0]}") + f"env-file = {spelled}\n")
|
self.write(f"acme-{case[0]}", CLIENT.replace("acme-billing", f"acme-{case[0]}") + f"env-file = {spelled}\n")
|
||||||
named = load(self.home / "code" / f"acme-{case[0]}", self.home / "code" / f"acme-{case[0]}", self.home)
|
named = load(self.home / "code" / f"acme-{case[0]}", self.home / "code" / f"acme-{case[0]}", self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual(named.env_file, self.home / ".claude-projects" / "acme.env")
|
self.assertEqual(named.env_file, self.home / ".config/build-release" / "acme.env")
|
||||||
|
|
||||||
def test_the_notifier_is_optional_and_names_mattermost_or_slack_beside_an_env_file(self) -> None:
|
def test_the_notifier_is_optional_and_names_mattermost_or_slack_beside_an_env_file(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertIsNone(left_out.notifier, "a project that names none has asked for no notices")
|
self.assertIsNone(left_out.notifier, "a project that names none has asked for no notices")
|
||||||
for index, name in enumerate(NOTIFIERS):
|
for index, name in enumerate(NOTIFIERS):
|
||||||
with self.subTest(name):
|
with self.subTest(name):
|
||||||
self.write(f"acme-{index}", CLIENT.replace("acme-billing", f"acme-{index}") + f'env-file = "~/acme.env"\nnotifier = "{name}"\n')
|
self.write(f"acme-{index}", CLIENT.replace("acme-billing", f"acme-{index}") + f'env-file = "~/acme.env"\nnotifier = "{name}"\n')
|
||||||
named = load(self.home / "code" / f"acme-{index}", self.home / "code" / f"acme-{index}", self.home)
|
named = load(self.home / "code" / f"acme-{index}", self.home / "code" / f"acme-{index}", self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual(named.notifier, name)
|
self.assertEqual(named.notifier, name)
|
||||||
|
|
||||||
def test_the_epic_branch_and_its_review_request_comment_are_optional(self) -> None:
|
def test_the_epic_branch_and_its_review_request_comment_are_optional(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual((left_out.epic_branch, left_out.review_request_comment), (None, None))
|
self.assertEqual((left_out.epic_branch, left_out.review_request_comment), (None, None))
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "epic/{epic}"\nreview-request-comment = "@coderabbitai review"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "epic/{epic}"\nreview-request-comment = "@coderabbitai review"\n')
|
||||||
named = load(self.checkout, self.checkout, self.home)
|
named = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual((named.epic_branch, named.review_request_comment), ("epic/{epic}", "@coderabbitai review"))
|
self.assertEqual((named.epic_branch, named.review_request_comment), ("epic/{epic}", "@coderabbitai review"))
|
||||||
|
|
||||||
def test_an_epic_branch_without_the_epic_or_a_comment_without_an_epic_branch_fails_naming_it(self) -> None:
|
def test_an_epic_branch_without_the_epic_or_a_comment_without_an_epic_branch_fails_naming_it(self) -> None:
|
||||||
self.write("acme", CLIENT + 'epic-branch = "develop"\n')
|
self.write("acme", CLIENT + 'epic-branch = "develop"\n')
|
||||||
self.assertIn("`epic-branch` is 'develop', not text with exactly one {epic}", self.failure())
|
self.assertIn("`epic-branch` is 'develop', not text with exactly one {epic}", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'review-request-comment = "@coderabbitai review"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'review-request-comment = "@coderabbitai review"\n')
|
||||||
self.assertIn("`review-request-comment` is set, so `epic-branch` must be set", self.failure())
|
self.assertIn("`review-request-comment` is set, so `epic-branch` must be set", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = " "\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = " "\n')
|
||||||
self.assertIn("`review-request-comment` is ' ', not one line of text", self.failure())
|
self.assertIn("`review-request-comment` is ' ', not one line of text", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "--help"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "--help"\n')
|
||||||
self.assertIn("`review-request-comment` is '--help', not one line of text that doesn't start with `-`", self.failure())
|
self.assertIn("`review-request-comment` is '--help', not one line of text that doesn't start with `-`", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "@coderabbitai\\nreview"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "@coderabbitai\\nreview"\n')
|
||||||
self.assertIn("`review-request-comment` is '@coderabbitai\\nreview', not one line of text", self.failure())
|
self.assertIn("`review-request-comment` is '@coderabbitai\\nreview', not one line of text", self.failure())
|
||||||
|
|
||||||
def test_a_jira_plan_may_name_the_transition_and_status_that_finish_an_item(self) -> None:
|
def test_a_jira_plan_may_name_the_transition_and_status_that_finish_an_item(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT)
|
self.write("acme", JIRA_CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertIsNone(left_out.jira_finish)
|
self.assertIsNone(left_out.jira_finish)
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||||
named = load(self.checkout, self.checkout, self.home)
|
named = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual(named.jira_finish, Finish("Mark as done", "Done"))
|
self.assertEqual(named.jira_finish, Finish("Mark as done", "Done"))
|
||||||
|
|
||||||
def test_a_finish_setting_alone_misspelt_or_beside_a_plan_in_a_file_fails_naming_it(self) -> None:
|
def test_a_finish_setting_alone_misspelt_or_beside_a_plan_in_a_file_fails_naming_it(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT + 'jira-finish-status = "Done"\n')
|
self.write("acme", JIRA_CLIENT + 'jira-finish-status = "Done"\n')
|
||||||
self.assertIn("`jira-finish-status` is set, so `jira-finish-transition` must be too", self.failure())
|
self.assertIn("`jira-finish-status` is set, so `jira-finish-transition` must be too", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = "Mark as done"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = "Mark as done"\n')
|
||||||
self.assertIn("`jira-finish-transition` is set, so `jira-finish-status` must be too", self.failure())
|
self.assertIn("`jira-finish-transition` is set, so `jira-finish-status` must be too", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = 31\njira-finish-status = " "\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(JIRA_CLIENT + 'jira-finish-transition = 31\njira-finish-status = " "\n')
|
||||||
self.assertIn("`jira-finish-transition` is 31, not the name Jira shows, such as \"Mark as done\"; `jira-finish-status` is ' ', not the name Jira shows, such as \"Done\"", self.failure())
|
self.assertIn("`jira-finish-transition` is 31, not the name Jira shows, such as \"Mark as done\"; `jira-finish-status` is ' ', not the name Jira shows, such as \"Done\"", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||||
self.assertIn("`jira-finish-transition` is set, so `plan` must name a Jira epic; `jira-finish-status` is set, so `plan` must name a Jira epic", self.failure())
|
self.assertIn("`jira-finish-transition` is set, so `plan` must name a Jira epic; `jira-finish-status` is set, so `plan` must name a Jira epic", self.failure())
|
||||||
|
|
||||||
def test_a_jira_plan_may_name_the_issue_type_it_files_items_as_which_is_task_where_left_out(self) -> None:
|
def test_a_jira_plan_may_name_the_issue_type_it_files_items_as_which_is_task_where_left_out(self) -> None:
|
||||||
folder = self.write("acme", JIRA_CLIENT)
|
folder = self.write("acme", JIRA_CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual(left_out.jira_finding_type, "Task")
|
self.assertEqual(left_out.jira_finding_type, "Task")
|
||||||
(folder / "config.toml").write_text(JIRA_CLIENT + 'jira-finding-type = "Feature"\n')
|
(folder / "config.toml").write_text(JIRA_CLIENT + 'jira-finding-type = "Feature"\n')
|
||||||
named = load(self.checkout, self.checkout, self.home)
|
named = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual(named.jira_finding_type, "Feature")
|
self.assertEqual(named.jira_finding_type, "Feature")
|
||||||
|
|
||||||
@@ -333,13 +333,13 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_a_jira_plan_holds_the_formula_and_bar_it_scores_by(self) -> None:
|
def test_a_jira_plan_holds_the_formula_and_bar_it_scores_by(self) -> None:
|
||||||
self.write("acme", JIRA_CLIENT.replace("jira-score-bar = 1", "jira-score-bar = 0.5"))
|
self.write("acme", JIRA_CLIENT.replace("jira-score-bar = 1", "jira-score-bar = 0.5"))
|
||||||
named = load(self.checkout, self.checkout, self.home)
|
named = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertEqual(named.jira_scoring, JiraScoring("100 * V / (2**S + 8)", 0.5))
|
self.assertEqual(named.jira_scoring, JiraScoring("100 * V / (2**S + 8)", 0.5))
|
||||||
|
|
||||||
def test_a_plan_in_a_file_holds_no_formula_or_bar_of_the_configs(self) -> None:
|
def test_a_plan_in_a_file_holds_no_formula_or_bar_of_the_configs(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
named = load(self.checkout, self.checkout, self.home)
|
named = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(named, ProjectConfig), named
|
assert isinstance(named, ProjectConfig), named
|
||||||
self.assertIsNone(named.jira_scoring)
|
self.assertIsNone(named.jira_scoring)
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ class LoadTest(ConfigCase):
|
|||||||
def test_a_notifier_that_is_unknown_or_has_no_env_file_fails_naming_it(self) -> None:
|
def test_a_notifier_that_is_unknown_or_has_no_env_file_fails_naming_it(self) -> None:
|
||||||
self.write("acme", CLIENT + 'env-file = "~/acme.env"\nnotifier = "teams"\n')
|
self.write("acme", CLIENT + 'env-file = "~/acme.env"\nnotifier = "teams"\n')
|
||||||
self.assertIn("`notifier` is 'teams', not mattermost or slack", self.failure())
|
self.assertIn("`notifier` is 'teams', not mattermost or slack", self.failure())
|
||||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'notifier = "slack"\n')
|
(self.home / ".config/build-release" / "acme" / "config.toml").write_text(CLIENT + 'notifier = "slack"\n')
|
||||||
self.assertIn("`notifier` names a notifier, so `env-file` must name the file that holds its credentials", self.failure())
|
self.assertIn("`notifier` names a notifier, so `env-file` must name the file that holds its credentials", self.failure())
|
||||||
|
|
||||||
def test_an_env_file_in_the_checkout_or_the_configs_folder_or_spelt_loosely_fails_naming_it(self) -> None:
|
def test_an_env_file_in_the_checkout_or_the_configs_folder_or_spelt_loosely_fails_naming_it(self) -> None:
|
||||||
@@ -377,7 +377,7 @@ class LoadTest(ConfigCase):
|
|||||||
"a folder: path": lambda home: '"folder:acme.env"',
|
"a folder: path": lambda home: '"folder:acme.env"',
|
||||||
"no prefix": lambda home: '".env"',
|
"no prefix": lambda home: '".env"',
|
||||||
"a path in the checkout": lambda home: f'"{home}/code/acme-billing/.env"',
|
"a path in the checkout": lambda home: f'"{home}/code/acme-billing/.env"',
|
||||||
"a path in the config's folder": lambda home: f'"{home}/.claude-projects/acme/acme.env"',
|
"a path in the config's folder": lambda home: f'"{home}/.config/build-release/acme/acme.env"',
|
||||||
"not text": lambda home: "3",
|
"not text": lambda home: "3",
|
||||||
}
|
}
|
||||||
for case, spelled in cases.items():
|
for case, spelled in cases.items():
|
||||||
@@ -395,17 +395,17 @@ class LoadTest(ConfigCase):
|
|||||||
self.home = pathlib.Path(made).resolve()
|
self.home = pathlib.Path(made).resolve()
|
||||||
self.checkout = self.home / "code" / "acme-billing"
|
self.checkout = self.home / "code" / "acme-billing"
|
||||||
self.write("acme", CLIENT + f'env-file = "{self.home}/code/{folder}/.env"\n')
|
self.write("acme", CLIENT + f'env-file = "{self.home}/code/{folder}/.env"\n')
|
||||||
found = load(self.home / "code" / "acme-billing-item-3", self.checkout, self.home)
|
found = load(self.home / "code" / "acme-billing-item-3", self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("`env-file`", found.reason)
|
self.assertIn("`env-file`", found.reason)
|
||||||
|
|
||||||
def test_bench_tasks_is_an_optional_path_listed_last_only_where_set(self) -> None:
|
def test_bench_tasks_is_an_optional_path_listed_last_only_where_set(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig)
|
assert isinstance(left_out, ProjectConfig)
|
||||||
self.assertNotIn("bench-tasks", left_out.places)
|
self.assertNotIn("bench-tasks", left_out.places)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'bench-tasks = "checkout:bench-tasks"\ntouch-predictions = "folder:docs/touch-predictions.md"\n', encoding="utf-8")
|
(folder / "config.toml").write_text(CLIENT + 'bench-tasks = "checkout:bench-tasks"\ntouch-predictions = "folder:docs/touch-predictions.md"\n', encoding="utf-8")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig)
|
assert isinstance(found, ProjectConfig)
|
||||||
self.assertEqual(list(found.places)[-3:], ["standards", "touch-predictions", "bench-tasks"])
|
self.assertEqual(list(found.places)[-3:], ["standards", "touch-predictions", "bench-tasks"])
|
||||||
self.assertEqual(found.paths["bench-tasks"], self.checkout / "bench-tasks")
|
self.assertEqual(found.paths["bench-tasks"], self.checkout / "bench-tasks")
|
||||||
@@ -414,11 +414,11 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_touch_predictions_is_an_optional_path_listed_after_the_others_only_where_set(self) -> None:
|
def test_touch_predictions_is_an_optional_path_listed_after_the_others_only_where_set(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig)
|
assert isinstance(left_out, ProjectConfig)
|
||||||
self.assertNotIn("touch-predictions", left_out.places)
|
self.assertNotIn("touch-predictions", left_out.places)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'touch-predictions = "folder:docs/touch-predictions.md"\n', encoding="utf-8")
|
(folder / "config.toml").write_text(CLIENT + 'touch-predictions = "folder:docs/touch-predictions.md"\n', encoding="utf-8")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig)
|
assert isinstance(found, ProjectConfig)
|
||||||
self.assertEqual(list(found.places)[-2:], ["standards", "touch-predictions"])
|
self.assertEqual(list(found.places)[-2:], ["standards", "touch-predictions"])
|
||||||
self.assertEqual(found.paths["touch-predictions"], folder / "docs/touch-predictions.md")
|
self.assertEqual(found.paths["touch-predictions"], folder / "docs/touch-predictions.md")
|
||||||
@@ -428,11 +428,11 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_coding_conventions_is_an_optional_list_of_paths_spelt_as_the_others_are(self) -> None:
|
def test_coding_conventions_is_an_optional_list_of_paths_spelt_as_the_others_are(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig)
|
assert isinstance(left_out, ProjectConfig)
|
||||||
self.assertEqual(left_out.coding_conventions, ())
|
self.assertEqual(left_out.coding_conventions, ())
|
||||||
(folder / "config.toml").write_text(CLIENT + 'coding-conventions = ["checkout:CONVENTIONS.md", "folder:style.md", "~/shared/php.md"]\n', encoding="utf-8")
|
(folder / "config.toml").write_text(CLIENT + 'coding-conventions = ["checkout:CONVENTIONS.md", "folder:style.md", "~/shared/php.md"]\n', encoding="utf-8")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig)
|
assert isinstance(found, ProjectConfig)
|
||||||
self.assertEqual(found.coding_conventions, (self.checkout / "CONVENTIONS.md", folder / "style.md", self.home / "shared/php.md"))
|
self.assertEqual(found.coding_conventions, (self.checkout / "CONVENTIONS.md", folder / "style.md", self.home / "shared/php.md"))
|
||||||
|
|
||||||
@@ -445,13 +445,13 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_merge_is_chunk_where_left_out_and_takes_human(self) -> None:
|
def test_merge_is_chunk_where_left_out_and_takes_human(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual(left_out.merge, "chunk")
|
self.assertEqual(left_out.merge, "chunk")
|
||||||
for spelled in ("chunk", "human"):
|
for spelled in ("chunk", "human"):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f'merge = "{spelled}"\n')
|
(folder / "config.toml").write_text(CLIENT + f'merge = "{spelled}"\n')
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.merge, spelled)
|
self.assertEqual(found.merge, spelled)
|
||||||
|
|
||||||
@@ -460,19 +460,19 @@ class LoadTest(ConfigCase):
|
|||||||
for spelled, named in (('"person"', "'person'"), ("true", "True")):
|
for spelled, named in (('"person"', "'person'"), ("true", "True")):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"merge = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"merge = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn(f'`merge` is {named}, not "chunk" or "human"', found.reason)
|
self.assertIn(f'`merge` is {named}, not "chunk" or "human"', found.reason)
|
||||||
|
|
||||||
def test_wait_for_approval_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
|
def test_wait_for_approval_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertFalse(left_out.wait_for_approval)
|
self.assertFalse(left_out.wait_for_approval)
|
||||||
for spelled, expected in (("true", True), ("false", False)):
|
for spelled, expected in (("true", True), ("false", False)):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"wait-for-approval = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"wait-for-approval = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.wait_for_approval, expected)
|
self.assertEqual(found.wait_for_approval, expected)
|
||||||
|
|
||||||
@@ -481,35 +481,35 @@ class LoadTest(ConfigCase):
|
|||||||
for spelled in ('"yes"', "1", '"true"'):
|
for spelled in ('"yes"', "1", '"true"'):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"wait-for-approval = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"wait-for-approval = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn(f"`wait-for-approval` is {eval(spelled)!r}, not true or false", found.reason)
|
self.assertIn(f"`wait-for-approval` is {eval(spelled)!r}, not true or false", found.reason)
|
||||||
|
|
||||||
def test_tooling_on_host_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
|
def test_tooling_on_host_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertFalse(left_out.tooling_on_host)
|
self.assertFalse(left_out.tooling_on_host)
|
||||||
for spelled, expected in (("true", True), ("false", False)):
|
for spelled, expected in (("true", True), ("false", False)):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"tooling-on-host = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"tooling-on-host = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.tooling_on_host, expected)
|
self.assertEqual(found.tooling_on_host, expected)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'tooling-on-host = "yes"\n')
|
(folder / "config.toml").write_text(CLIENT + 'tooling-on-host = "yes"\n')
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("`tooling-on-host` is 'yes', not true or false", found.reason)
|
self.assertIn("`tooling-on-host` is 'yes', not true or false", found.reason)
|
||||||
|
|
||||||
def test_the_readability_floor_is_an_optional_number_from_1_to_10_that_is_7_where_left_out(self) -> None:
|
def test_the_readability_floor_is_an_optional_number_from_1_to_10_that_is_7_where_left_out(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual(left_out.readability_floor, decimal.Decimal("7.0"))
|
self.assertEqual(left_out.readability_floor, decimal.Decimal("7.0"))
|
||||||
for spelled, expected in (("5", "5"), ("6.5", "6.5"), ("1", "1"), ("10.0", "10.0")):
|
for spelled, expected in (("5", "5"), ("6.5", "6.5"), ("1", "1"), ("10.0", "10.0")):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"readability-floor = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"readability-floor = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.readability_floor, decimal.Decimal(expected))
|
self.assertEqual(found.readability_floor, decimal.Decimal(expected))
|
||||||
|
|
||||||
@@ -518,20 +518,20 @@ class LoadTest(ConfigCase):
|
|||||||
for spelled in ('"7.0"', "0.5", "11", "true", "nan", "inf", "1" + "0" * 400):
|
for spelled in ('"7.0"', "0.5", "11", "true", "nan", "inf", "1" + "0" * 400):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"readability-floor = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"readability-floor = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("`readability-floor` is ", found.reason)
|
self.assertIn("`readability-floor` is ", found.reason)
|
||||||
self.assertIn(", not a number from 1 to 10; write a bare number, such as `readability-floor = 7.0`", found.reason)
|
self.assertIn(", not a number from 1 to 10; write a bare number, such as `readability-floor = 7.0`", found.reason)
|
||||||
|
|
||||||
def test_parallel_chunks_is_an_optional_whole_number_from_1_that_is_1_where_left_out(self) -> None:
|
def test_parallel_chunks_is_an_optional_whole_number_from_1_that_is_1_where_left_out(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual(left_out.parallel_chunks, 1)
|
self.assertEqual(left_out.parallel_chunks, 1)
|
||||||
for spelled in (1, 3, 12):
|
for spelled in (1, 3, 12):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"parallel-chunks = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"parallel-chunks = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual(found.parallel_chunks, spelled)
|
self.assertEqual(found.parallel_chunks, spelled)
|
||||||
|
|
||||||
@@ -540,18 +540,18 @@ class LoadTest(ConfigCase):
|
|||||||
for spelled in ('"2"', "0", "-1", "2.0", "true", "inf"):
|
for spelled in ('"2"', "0", "-1", "2.0", "true", "inf"):
|
||||||
with self.subTest(spelled):
|
with self.subTest(spelled):
|
||||||
(folder / "config.toml").write_text(CLIENT + f"parallel-chunks = {spelled}\n")
|
(folder / "config.toml").write_text(CLIENT + f"parallel-chunks = {spelled}\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("`parallel-chunks` is ", found.reason)
|
self.assertIn("`parallel-chunks` is ", found.reason)
|
||||||
self.assertIn(", not a whole number of 1 or more, such as `parallel-chunks = 2`", found.reason)
|
self.assertIn(", not a whole number of 1 or more, such as `parallel-chunks = 2`", found.reason)
|
||||||
|
|
||||||
def test_the_language_and_the_templates_are_optional_and_default_to_english_bare_summaries_and_item_branches(self) -> None:
|
def test_the_language_and_the_templates_are_optional_and_default_to_english_bare_summaries_and_item_branches(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
left_out = load(self.checkout, self.checkout, self.home)
|
left_out = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(left_out, ProjectConfig), left_out
|
assert isinstance(left_out, ProjectConfig), left_out
|
||||||
self.assertEqual((left_out.language, left_out.commit_title, left_out.pull_request_title, left_out.branch), ("English", "{summary}", "{summary}", "item-{id}"))
|
self.assertEqual((left_out.language, left_out.commit_title, left_out.pull_request_title, left_out.branch), ("English", "{summary}", "{summary}", "item-{id}"))
|
||||||
(folder / "config.toml").write_text(CLIENT + 'language = "Swedish"\ncommit-title = "PAY-{id} - {summary}"\npull-request-title = "fix: {summary} (#{id})"\nbranch = "feature/PAY-{id}"\n')
|
(folder / "config.toml").write_text(CLIENT + 'language = "Swedish"\ncommit-title = "PAY-{id} - {summary}"\npull-request-title = "fix: {summary} (#{id})"\nbranch = "feature/PAY-{id}"\n')
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.language, found.commit_title, found.pull_request_title, found.branch), ("Swedish", "PAY-{id} - {summary}", "fix: {summary} (#{id})", "feature/PAY-{id}"))
|
self.assertEqual((found.language, found.commit_title, found.pull_request_title, found.branch), ("Swedish", "PAY-{id} - {summary}", "fix: {summary} (#{id})", "feature/PAY-{id}"))
|
||||||
|
|
||||||
@@ -561,22 +561,22 @@ class LoadTest(ConfigCase):
|
|||||||
for line, named in cases.items():
|
for line, named in cases.items():
|
||||||
with self.subTest(line):
|
with self.subTest(line):
|
||||||
(folder / "config.toml").write_text(CLIENT + line + "\n")
|
(folder / "config.toml").write_text(CLIENT + line + "\n")
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn(named, found.reason)
|
self.assertIn(named, found.reason)
|
||||||
|
|
||||||
def test_a_language_of_more_than_words_fails_saying_what_is_accepted(self) -> None:
|
def test_a_language_of_more_than_words_fails_saying_what_is_accepted(self) -> None:
|
||||||
folder = self.write("acme", CLIENT + 'language = "Chinese (Simplified)"\n')
|
folder = self.write("acme", CLIENT + 'language = "Chinese (Simplified)"\n')
|
||||||
found = load(self.checkout, self.checkout, self.home)
|
found = load(self.checkout, self.checkout, self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("`language` is 'Chinese (Simplified)', not a language's English name in words of letters, such as \"Swedish\" or \"Brazilian Portuguese\"", found.reason)
|
self.assertIn("`language` is 'Chinese (Simplified)', not a language's English name in words of letters, such as \"Swedish\" or \"Brazilian Portuguese\"", found.reason)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'language = "Brazilian Portuguese"\n')
|
(folder / "config.toml").write_text(CLIENT + 'language = "Brazilian Portuguese"\n')
|
||||||
self.assertIsInstance(load(self.checkout, self.checkout, self.home), ProjectConfig)
|
self.assertIsInstance(load(self.checkout, self.checkout, self.home, {}), ProjectConfig)
|
||||||
|
|
||||||
def test_a_checkout_no_config_names_fails_as_unnamed_and_a_faulty_config_does_not(self) -> None:
|
def test_a_checkout_no_config_names_fails_as_unnamed_and_a_faulty_config_does_not(self) -> None:
|
||||||
self.assertIsInstance(load(self.checkout, self.checkout, self.home), Unnamed)
|
self.assertIsInstance(load(self.checkout, self.checkout, self.home, {}), Unnamed)
|
||||||
self.write("acme", CLIENT + "language = 3\n")
|
self.write("acme", CLIENT + "language = 3\n")
|
||||||
self.assertNotIsInstance(load(self.checkout, self.checkout, self.home), Unnamed)
|
self.assertNotIsInstance(load(self.checkout, self.checkout, self.home, {}), Unnamed)
|
||||||
|
|
||||||
def test_the_failure_for_a_misplaced_env_file_and_a_missing_setting_names_both_and_lists_every_setting(self) -> None:
|
def test_the_failure_for_a_misplaced_env_file_and_a_missing_setting_names_both_and_lists_every_setting(self) -> None:
|
||||||
folder = self.write("acme", "".join(line + "\n" for line in CLIENT.splitlines() if not line.startswith("plan")) + 'env-file = "checkout:.env"\n')
|
folder = self.write("acme", "".join(line + "\n" for line in CLIENT.splitlines() if not line.startswith("plan")) + 'env-file = "checkout:.env"\n')
|
||||||
@@ -600,27 +600,27 @@ class LoadTest(ConfigCase):
|
|||||||
|
|
||||||
def test_a_folder_with_no_config_is_skipped(self) -> None:
|
def test_a_folder_with_no_config_is_skipped(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
(self.home / ".claude-projects" / "notes").mkdir()
|
(self.home / ".config/build-release" / "notes").mkdir()
|
||||||
self.assertIsInstance(load(self.checkout, self.checkout, self.home), ProjectConfig)
|
self.assertIsInstance(load(self.checkout, self.checkout, self.home, {}), ProjectConfig)
|
||||||
|
|
||||||
|
|
||||||
class TitleTemplatesTest(ConfigCase):
|
class TitleTemplatesTest(ConfigCase):
|
||||||
def test_names_the_configs_templates_and_bare_summaries_where_no_config_names_the_checkout_or_git_finds_none(self) -> None:
|
def test_names_the_configs_templates_and_bare_summaries_where_no_config_names_the_checkout_or_git_finds_none(self) -> None:
|
||||||
subprocess.run(["git", "init", "--quiet", str(self.checkout)], check=True, env=isolated_env())
|
subprocess.run(["git", "init", "--quiet", str(self.checkout)], check=True, env=isolated_env())
|
||||||
self.assertEqual(title_templates(str(self.checkout), self.home), Titles("{summary}", "{summary}"))
|
self.assertEqual(title_templates(str(self.checkout), self.home, {}), Titles("{summary}", "{summary}"))
|
||||||
self.write("acme", CLIENT + 'commit-title = "PAY-{id} - {summary}"\npull-request-title = "fix: {summary} (#{id})"\n')
|
self.write("acme", CLIENT + 'commit-title = "PAY-{id} - {summary}"\npull-request-title = "fix: {summary} (#{id})"\n')
|
||||||
self.assertEqual(title_templates(str(self.checkout), self.home), Titles("PAY-{id} - {summary}", "fix: {summary} (#{id})"))
|
self.assertEqual(title_templates(str(self.checkout), self.home, {}), Titles("PAY-{id} - {summary}", "fix: {summary} (#{id})"))
|
||||||
self.assertEqual(title_templates(str(self.home), self.home), Titles("{summary}", "{summary}"))
|
self.assertEqual(title_templates(str(self.home), self.home, {}), Titles("{summary}", "{summary}"))
|
||||||
|
|
||||||
def test_fails_where_the_checkouts_config_or_any_other_cannot_be_read(self) -> None:
|
def test_fails_where_the_checkouts_config_or_any_other_cannot_be_read(self) -> None:
|
||||||
subprocess.run(["git", "init", "--quiet", str(self.checkout)], check=True, env=isolated_env())
|
subprocess.run(["git", "init", "--quiet", str(self.checkout)], check=True, env=isolated_env())
|
||||||
folder = self.write("acme", CLIENT + 'commit-title = "PAY-{id}"\n')
|
folder = self.write("acme", CLIENT + 'commit-title = "PAY-{id}"\n')
|
||||||
faulty = title_templates(str(self.checkout), self.home)
|
faulty = title_templates(str(self.checkout), self.home, {})
|
||||||
assert isinstance(faulty, Failure), faulty
|
assert isinstance(faulty, Failure), faulty
|
||||||
self.assertIn("`commit-title` is 'PAY-{id}'", faulty.reason)
|
self.assertIn("`commit-title` is 'PAY-{id}'", faulty.reason)
|
||||||
(folder / "config.toml").write_text(CLIENT)
|
(folder / "config.toml").write_text(CLIENT)
|
||||||
other = self.write("other", "checkout = [")
|
other = self.write("other", "checkout = [")
|
||||||
unread = title_templates(str(self.checkout), self.home)
|
unread = title_templates(str(self.checkout), self.home, {})
|
||||||
assert isinstance(unread, Failure), unread
|
assert isinstance(unread, Failure), unread
|
||||||
self.assertIn(f"cannot read {other / 'config.toml'}", unread.reason)
|
self.assertIn(f"cannot read {other / 'config.toml'}", unread.reason)
|
||||||
|
|
||||||
@@ -628,54 +628,54 @@ class TitleTemplatesTest(ConfigCase):
|
|||||||
class HeldTest(ConfigCase):
|
class HeldTest(ConfigCase):
|
||||||
def test_a_configs_folder_holds_its_config_as_the_main_checkout_reads_it(self) -> None:
|
def test_a_configs_folder_holds_its_config_as_the_main_checkout_reads_it(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
found = held(folder, self.home)
|
found = held(folder, self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.folder, found.top, found.paths["plan"]), (folder, self.checkout, folder / "todo.md"), "the config's ~/ checkout read under home")
|
self.assertEqual((found.folder, found.top, found.paths["plan"]), (folder, self.checkout, folder / "todo.md"), "the config's ~/ checkout read under home")
|
||||||
|
|
||||||
def test_a_folder_holds_no_config_unless_it_is_under_the_projects_folder_and_has_one(self) -> None:
|
def test_a_folder_holds_no_config_unless_it_is_under_the_projects_folder_and_has_one(self) -> None:
|
||||||
self.assertIsNone(held(self.home / ".claude-projects" / "empty", self.home), "no config.toml")
|
self.assertIsNone(held(self.home / ".config/build-release" / "empty", self.home, {}), "no config.toml")
|
||||||
elsewhere = self.home / "code" / "acme"
|
elsewhere = self.home / "code" / "acme"
|
||||||
elsewhere.mkdir()
|
elsewhere.mkdir()
|
||||||
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
|
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
|
||||||
self.assertIsNone(held(elsewhere, self.home), "a config.toml outside ~/.claude-projects/")
|
self.assertIsNone(held(elsewhere, self.home, {}), "a config.toml outside ~/.config/build-release/")
|
||||||
|
|
||||||
def test_the_do_epic_folder_holds_no_projects_config(self) -> None:
|
def test_the_do_epic_folder_holds_no_projects_config(self) -> None:
|
||||||
folder = self.write("do-epic", CLIENT)
|
folder = self.write("do-epic", CLIENT)
|
||||||
self.assertIsNone(held(folder, self.home))
|
self.assertIsNone(held(folder, self.home, {}))
|
||||||
|
|
||||||
def test_a_configs_folder_reached_through_a_symlink_holds_its_config(self) -> None:
|
def test_a_configs_folder_reached_through_a_symlink_holds_its_config(self) -> None:
|
||||||
target = self.home / "kept" / "acme"
|
target = self.home / "kept" / "acme"
|
||||||
target.mkdir(parents=True)
|
target.mkdir(parents=True)
|
||||||
(target / "config.toml").write_text(CLIENT, encoding="utf-8")
|
(target / "config.toml").write_text(CLIENT, encoding="utf-8")
|
||||||
(self.home / ".claude-projects").mkdir()
|
(self.home / ".config/build-release").mkdir(parents=True)
|
||||||
(self.home / ".claude-projects" / "acme").symlink_to(target)
|
(self.home / ".config/build-release" / "acme").symlink_to(target)
|
||||||
self.assertIsInstance(held(target, self.home), ProjectConfig, "git names the folder by its resolved path")
|
self.assertIsInstance(held(target, self.home, {}), ProjectConfig, "git names the folder by its resolved path")
|
||||||
|
|
||||||
|
|
||||||
class ByNameTest(ConfigCase):
|
class ByNameTest(ConfigCase):
|
||||||
def test_finds_the_config_of_the_project_whose_main_checkout_has_the_name_though_the_checkout_is_missing(self) -> None:
|
def test_finds_the_config_of_the_project_whose_main_checkout_has_the_name_though_the_checkout_is_missing(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
found = by_name("acme-billing", self.home)
|
found = by_name("acme-billing", self.home, {})
|
||||||
assert isinstance(found, ProjectConfig), found
|
assert isinstance(found, ProjectConfig), found
|
||||||
self.assertEqual((found.folder, found.top), (folder, self.checkout))
|
self.assertEqual((found.folder, found.top), (folder, self.checkout))
|
||||||
|
|
||||||
def test_finds_none_where_no_config_names_a_checkout_of_that_name(self) -> None:
|
def test_finds_none_where_no_config_names_a_checkout_of_that_name(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
self.assertIsNone(by_name("billing", self.home), "a part of a name is not the name")
|
self.assertIsNone(by_name("billing", self.home, {}), "a part of a name is not the name")
|
||||||
self.assertIsNone(by_name("acme", self.home), "a config's key is not a repo's name")
|
self.assertIsNone(by_name("acme", self.home, {}), "a config's key is not a repo's name")
|
||||||
self.assertIsNone(by_name("do-epic", self.home))
|
self.assertIsNone(by_name("do-epic", self.home, {}))
|
||||||
|
|
||||||
def test_fails_where_two_configs_name_a_checkout_of_that_name(self) -> None:
|
def test_fails_where_two_configs_name_a_checkout_of_that_name(self) -> None:
|
||||||
self.write("acme", CLIENT)
|
self.write("acme", CLIENT)
|
||||||
self.write("acme-two", CLIENT.replace("~/code/acme-billing", "~/other/acme-billing"))
|
self.write("acme-two", CLIENT.replace("~/code/acme-billing", "~/other/acme-billing"))
|
||||||
found = by_name("acme-billing", self.home)
|
found = by_name("acme-billing", self.home, {})
|
||||||
assert isinstance(found, Failure), found
|
assert isinstance(found, Failure), found
|
||||||
self.assertIn("acme/config.toml and ", found.reason)
|
self.assertIn("acme/config.toml and ", found.reason)
|
||||||
self.assertIn("acme-two/config.toml each name a checkout called acme-billing", found.reason)
|
self.assertIn("acme-two/config.toml each name a checkout called acme-billing", found.reason)
|
||||||
|
|
||||||
def test_fails_where_a_config_cannot_be_read_since_it_may_be_the_one_asked_for(self) -> None:
|
def test_fails_where_a_config_cannot_be_read_since_it_may_be_the_one_asked_for(self) -> None:
|
||||||
self.write("acme", "this is not toml")
|
self.write("acme", "this is not toml")
|
||||||
self.assertIsInstance(by_name("acme-billing", self.home), Failure)
|
self.assertIsInstance(by_name("acme-billing", self.home, {}), Failure)
|
||||||
|
|
||||||
|
|
||||||
class EnvFilesTest(ConfigCase):
|
class EnvFilesTest(ConfigCase):
|
||||||
@@ -684,11 +684,11 @@ class EnvFilesTest(ConfigCase):
|
|||||||
self.write("misplaced", 'checkout = "~/code/other"\nenv-file = "/srv/other.env"\n')
|
self.write("misplaced", 'checkout = "~/code/other"\nenv-file = "/srv/other.env"\n')
|
||||||
self.write("broken", "checkout = ")
|
self.write("broken", "checkout = ")
|
||||||
self.write("none", CLIENT)
|
self.write("none", CLIENT)
|
||||||
self.assertEqual(env_files(self.home), [self.home / "acme.env", pathlib.Path("/srv/other.env")])
|
self.assertEqual(env_files(self.home, {}), [self.home / "acme.env", pathlib.Path("/srv/other.env")])
|
||||||
|
|
||||||
def test_lists_do_epics_env_file_though_its_config_names_no_checkout(self) -> None:
|
def test_lists_do_epics_env_file_though_its_config_names_no_checkout(self) -> None:
|
||||||
self.write("do-epic", 'env-file = "~/jira.env"\n')
|
self.write("do-epic", 'env-file = "~/jira.env"\n')
|
||||||
self.assertEqual(env_files(self.home), [self.home / "jira.env"])
|
self.assertEqual(env_files(self.home, {}), [self.home / "jira.env"])
|
||||||
|
|
||||||
|
|
||||||
class ToolTest(ConfigCase):
|
class ToolTest(ConfigCase):
|
||||||
@@ -729,17 +729,17 @@ class ToolTest(ConfigCase):
|
|||||||
unset = self.run_tool("env-file")
|
unset = self.run_tool("env-file")
|
||||||
self.assertEqual((unset.returncode, unset.stdout, unset.stderr), (1, "", f"{folder / 'config.toml'} sets no `env-file`\n"))
|
self.assertEqual((unset.returncode, unset.stdout, unset.stderr), (1, "", f"{folder / 'config.toml'} sets no `env-file`\n"))
|
||||||
self.assertNotIn("env-file", self.run_tool().stdout)
|
self.assertNotIn("env-file", self.run_tool().stdout)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'env-file = "~/.claude-projects/acme.env"\n')
|
(folder / "config.toml").write_text(CLIENT + 'env-file = "~/.config/build-release/acme.env"\n')
|
||||||
one = self.run_tool("env-file")
|
one = self.run_tool("env-file")
|
||||||
self.assertEqual((one.returncode, one.stdout), (0, f"{self.home}/.claude-projects/acme.env\n"))
|
self.assertEqual((one.returncode, one.stdout), (0, f"{self.home}/.config/build-release/acme.env\n"))
|
||||||
self.assertEqual(self.run_tool().stdout.splitlines()[-1], f"env-file: {self.home}/.claude-projects/acme.env")
|
self.assertEqual(self.run_tool().stdout.splitlines()[-1], f"env-file: {self.home}/.config/build-release/acme.env")
|
||||||
|
|
||||||
def test_prints_the_notifier_where_the_config_sets_one_and_fails_asking_for_it_where_it_does_not(self) -> None:
|
def test_prints_the_notifier_where_the_config_sets_one_and_fails_asking_for_it_where_it_does_not(self) -> None:
|
||||||
folder = self.write("acme", CLIENT)
|
folder = self.write("acme", CLIENT)
|
||||||
unset = self.run_tool("notifier")
|
unset = self.run_tool("notifier")
|
||||||
self.assertEqual((unset.returncode, unset.stdout, unset.stderr), (1, "", f"{folder / 'config.toml'} sets no `notifier`\n"))
|
self.assertEqual((unset.returncode, unset.stdout, unset.stderr), (1, "", f"{folder / 'config.toml'} sets no `notifier`\n"))
|
||||||
self.assertNotIn("notifier", self.run_tool().stdout)
|
self.assertNotIn("notifier", self.run_tool().stdout)
|
||||||
(folder / "config.toml").write_text(CLIENT + 'env-file = "~/.claude-projects/acme.env"\nnotifier = "slack"\n')
|
(folder / "config.toml").write_text(CLIENT + 'env-file = "~/.config/build-release/acme.env"\nnotifier = "slack"\n')
|
||||||
self.assertEqual(self.run_tool("notifier").stdout, "slack\n")
|
self.assertEqual(self.run_tool("notifier").stdout, "slack\n")
|
||||||
self.assertEqual(self.run_tool().stdout.splitlines()[-1], "notifier: slack")
|
self.assertEqual(self.run_tool().stdout.splitlines()[-1], "notifier: slack")
|
||||||
|
|
||||||
|
|||||||
+16
-13
@@ -10,7 +10,7 @@ kept in a Jira epic's description: edit those two in Jira.
|
|||||||
|
|
||||||
open prints the path of a file holding the record's text, and nothing else. Read and edit that
|
open prints the path of a file holding the record's text, and nothing else. Read and edit that
|
||||||
file. Where the record is kept as a file, the path is that file. Where it is kept elsewhere, the
|
file. Where the record is kept as a file, the path is that file. Where it is kept elsewhere, the
|
||||||
path is a copy under ~/.local/state/project-record/<key>/<worktree>/, a folder named for the
|
path is a copy under ~/.local/state/build-release/project-record/<key>/<worktree>/, a folder named for the
|
||||||
worktree that ran open, so two worktrees of one project don't share a copy. The copy is written
|
worktree that ran open, so two worktrees of one project don't share a copy. The copy is written
|
||||||
afresh with the record as it stands, so open it again before each edit. open also removes the
|
afresh with the record as it stands, so open it again before each edit. open also removes the
|
||||||
folders of worktrees git no longer lists. A record that doesn't exist yet has no file at the path:
|
folders of worktrees git no longer lists. A record that doesn't exist yet has no file at the path:
|
||||||
@@ -25,8 +25,11 @@ saved it after open read it or after save last wrote it, and the human decides w
|
|||||||
until open runs again and writes the copy afresh.
|
until open runs again and writes the copy afresh.
|
||||||
|
|
||||||
Exit 2 on bad arguments, and 1, saying why, on any other failure.
|
Exit 2 on bad arguments, and 1, saying why, on any other failure.
|
||||||
|
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@@ -36,12 +39,12 @@ from record_store.stores import FileStore, goals_store, local_file, RECORDS, Rec
|
|||||||
from git_cli.git_repo import git, Git
|
from git_cli.git_repo import git, Git
|
||||||
from project_config.main import located
|
from project_config.main import located
|
||||||
from project_config.settings import ProjectConfig
|
from project_config.settings import ProjectConfig
|
||||||
from loop_state.paths import STATE_FOLDER
|
from loop_state.paths import state_folder
|
||||||
|
|
||||||
# Not git's verbs, such as checkout and commit: those read as acting on the repo.
|
# Not git's verbs, such as checkout and commit: those read as acting on the repo.
|
||||||
COMMANDS = ("open", "save")
|
COMMANDS = ("open", "save")
|
||||||
# Where the copy of a record kept outside files goes, under the user's home, in a folder per project and worktree.
|
# Where the copy of a record kept outside files goes, under the state folder, in a folder per project and worktree.
|
||||||
COPIES = f"{STATE_FOLDER}/project-record"
|
COPIES = "project-record"
|
||||||
# The goals file opens like a record, though it is a setting of its own.
|
# The goals file opens like a record, though it is a setting of its own.
|
||||||
GOALS = "goals-and-audience"
|
GOALS = "goals-and-audience"
|
||||||
|
|
||||||
@@ -54,8 +57,8 @@ def main(argv: list[str]) -> int:
|
|||||||
print(f"usage: project-record {'|'.join(COMMANDS)} <record>, where <record> is one of {', '.join((*RECORDS, GOALS))}", file=sys.stderr)
|
print(f"usage: project-record {'|'.join(COMMANDS)} <record>, where <record> is one of {', '.join((*RECORDS, GOALS))}", file=sys.stderr)
|
||||||
return 2
|
return 2
|
||||||
home = pathlib.Path.home()
|
home = pathlib.Path.home()
|
||||||
config = located(None, home)
|
config = located(None, home, os.environ)
|
||||||
done = config if isinstance(config, Failure) else performed(config, argv[0], argv[1], home)
|
done = config if isinstance(config, Failure) else performed(config, argv[0], argv[1], state_folder(os.environ, home))
|
||||||
if isinstance(done, Failure):
|
if isinstance(done, Failure):
|
||||||
print(f"project-record: {done.reason}", file=sys.stderr)
|
print(f"project-record: {done.reason}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
@@ -63,16 +66,16 @@ def main(argv: list[str]) -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def performed(config: ProjectConfig, command: str, name: str, home: pathlib.Path, run: Git = git) -> str | Failure:
|
def performed(config: ProjectConfig, command: str, name: str, state: pathlib.Path, run: Git = git) -> str | Failure:
|
||||||
"""What command, one of COMMANDS, prints for the record called name. An open also prunes the copies of removed worktrees."""
|
"""What command, one of COMMANDS, prints for the record called name. An open also prunes the copies of removed worktrees."""
|
||||||
if command == "open":
|
if command == "open":
|
||||||
pruned(config, home, run)
|
pruned(config, state, run)
|
||||||
return act(command, *opened(config, name, home))
|
return act(command, *opened(config, name, state))
|
||||||
|
|
||||||
|
|
||||||
def opened(config: ProjectConfig, name: str, home: pathlib.Path) -> tuple[RecordStore, pathlib.Path]:
|
def opened(config: ProjectConfig, name: str, state: pathlib.Path) -> tuple[RecordStore, pathlib.Path]:
|
||||||
"""The store of the record called name, and the copy it gets where it isn't kept as a file."""
|
"""The store of the record called name, and the copy it gets where it isn't kept as a file."""
|
||||||
copy = home / COPIES / config.key / worktree_folder(config.top) / f"{name}.md"
|
copy = state / COPIES / config.key / worktree_folder(config.top) / f"{name}.md"
|
||||||
return (goals_store(config) if name == GOALS else store(config, name)), copy
|
return (goals_store(config) if name == GOALS else store(config, name)), copy
|
||||||
|
|
||||||
|
|
||||||
@@ -81,10 +84,10 @@ def worktree_folder(top: pathlib.Path) -> str:
|
|||||||
return f"{top.name}-{hashlib.sha256(str(top).encode()).hexdigest()[:8]}"
|
return f"{top.name}-{hashlib.sha256(str(top).encode()).hexdigest()[:8]}"
|
||||||
|
|
||||||
|
|
||||||
def pruned(config: ProjectConfig, home: pathlib.Path, run: Git = git) -> None:
|
def pruned(config: ProjectConfig, state: pathlib.Path, run: Git = git) -> None:
|
||||||
"""Remove the copies of the worktrees git no longer lists, so the folders don't pile up one per chunk. Best effort: a folder that stays only takes disk, and where git can't list the worktrees nothing is removed."""
|
"""Remove the copies of the worktrees git no longer lists, so the folders don't pile up one per chunk. Best effort: a folder that stays only takes disk, and where git can't list the worktrees nothing is removed."""
|
||||||
listed = run("worktree", "list", "--porcelain")
|
listed = run("worktree", "list", "--porcelain")
|
||||||
folders = home / COPIES / config.key
|
folders = state / COPIES / config.key
|
||||||
if isinstance(listed, Failure) or not folders.is_dir():
|
if isinstance(listed, Failure) or not folders.is_dir():
|
||||||
return
|
return
|
||||||
worktrees = [config.top, *(pathlib.Path(line.removeprefix("worktree ")) for line in listed.splitlines() if line.startswith("worktree "))]
|
worktrees = [config.top, *(pathlib.Path(line.removeprefix("worktree ")) for line in listed.splitlines() if line.startswith("worktree "))]
|
||||||
|
|||||||
@@ -17,38 +17,39 @@ from project_config.settings import Page, ProjectConfig
|
|||||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-record"
|
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-record"
|
||||||
|
|
||||||
|
|
||||||
COPIES = pathlib.Path("/home/me/.local/state/project-record/acme")
|
STATE = pathlib.Path("/home/me/.local/state/build-release")
|
||||||
|
COPIES = STATE / "project-record/acme"
|
||||||
|
|
||||||
|
|
||||||
def worktree_config(top: str, **kept: Page) -> ProjectConfig:
|
def worktree_config(top: str, **kept: Page) -> ProjectConfig:
|
||||||
return ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path(top), {"goals-and-audience": pathlib.Path(top, "README.md")}, pathlib.Path("/home/me/acme.env"), pages=kept)
|
return ProjectConfig("acme", pathlib.Path("/home/me/.config/build-release/acme"), pathlib.Path(top), {"goals-and-audience": pathlib.Path(top, "README.md")}, pathlib.Path("/home/me/acme.env"), pages=kept)
|
||||||
|
|
||||||
|
|
||||||
class Opened(unittest.TestCase):
|
class Opened(unittest.TestCase):
|
||||||
def test_a_record_on_a_confluence_page_gets_a_copy_in_a_folder_of_its_worktree(self):
|
def test_a_record_on_a_confluence_page_gets_a_copy_in_a_folder_of_its_worktree(self):
|
||||||
page = Page("https://acme.atlassian.net", "2293761", "confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761")
|
page = Page("https://acme.atlassian.net", "2293761", "confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761")
|
||||||
record, copy = main.opened(worktree_config("/code/acme", decisions=page), "decisions", pathlib.Path("/home/me"))
|
record, copy = main.opened(worktree_config("/code/acme", decisions=page), "decisions", STATE)
|
||||||
self.assertEqual((copy.parent.parent, copy.name), (COPIES, "decisions.md"))
|
self.assertEqual((copy.parent.parent, copy.name), (COPIES, "decisions.md"))
|
||||||
self.assertRegex(copy.parent.name, r"^acme-[0-9a-f]{8}$")
|
self.assertRegex(copy.parent.name, r"^acme-[0-9a-f]{8}$")
|
||||||
self.assertIsInstance(record, ConfluencePage)
|
self.assertIsInstance(record, ConfluencePage)
|
||||||
|
|
||||||
def test_the_goals_file_opens_through_the_goals_store(self):
|
def test_the_goals_file_opens_through_the_goals_store(self):
|
||||||
record, copy = main.opened(worktree_config("/code/acme"), "goals-and-audience", pathlib.Path("/home/me"))
|
record, copy = main.opened(worktree_config("/code/acme"), "goals-and-audience", STATE)
|
||||||
self.assertEqual((record.label, copy.parent.parent, copy.name), ("/code/acme/README.md", COPIES, "goals-and-audience.md"))
|
self.assertEqual((record.label, copy.parent.parent, copy.name), ("/code/acme/README.md", COPIES, "goals-and-audience.md"))
|
||||||
|
|
||||||
def test_two_worktrees_of_one_project_get_copies_that_differ(self):
|
def test_two_worktrees_of_one_project_get_copies_that_differ(self):
|
||||||
home = pathlib.Path("/home/me")
|
home = STATE
|
||||||
main_checkout = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
main_checkout = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
||||||
other = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
other = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
||||||
self.assertNotEqual(main_checkout, other)
|
self.assertNotEqual(main_checkout, other)
|
||||||
|
|
||||||
def test_one_worktree_always_gets_the_same_copy(self):
|
def test_one_worktree_always_gets_the_same_copy(self):
|
||||||
home = pathlib.Path("/home/me")
|
home = STATE
|
||||||
first = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
first = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
||||||
self.assertEqual(first, main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1])
|
self.assertEqual(first, main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1])
|
||||||
|
|
||||||
def test_two_worktrees_named_alike_in_different_folders_get_copies_that_differ(self):
|
def test_two_worktrees_named_alike_in_different_folders_get_copies_that_differ(self):
|
||||||
home = pathlib.Path("/home/me")
|
home = STATE
|
||||||
first = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
first = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
||||||
second = main.opened(worktree_config("/other/acme-item-5"), "goals-and-audience", home)[1]
|
second = main.opened(worktree_config("/other/acme-item-5"), "goals-and-audience", home)[1]
|
||||||
self.assertNotEqual(first, second)
|
self.assertNotEqual(first, second)
|
||||||
@@ -58,9 +59,10 @@ class Pruned(unittest.TestCase):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||||
self.config = worktree_config("/code/acme-item-5")
|
self.config = worktree_config("/code/acme-item-5")
|
||||||
self.folders = self.home / ".local/state/project-record/acme"
|
self.state = self.home / ".local/state/build-release"
|
||||||
|
self.folders = self.state / "project-record/acme"
|
||||||
for top in ("/code/acme", "/code/acme-item-5", "/code/acme-item-6"):
|
for top in ("/code/acme", "/code/acme-item-5", "/code/acme-item-6"):
|
||||||
copy = main.opened(worktree_config(top), "goals-and-audience", self.home)[1]
|
copy = main.opened(worktree_config(top), "goals-and-audience", self.state)[1]
|
||||||
copy.parent.mkdir(parents=True)
|
copy.parent.mkdir(parents=True)
|
||||||
copy.write_text("edit")
|
copy.write_text("edit")
|
||||||
|
|
||||||
@@ -71,37 +73,37 @@ class Pruned(unittest.TestCase):
|
|||||||
return lambda *args, **kwargs: "" if args != ("worktree", "list", "--porcelain") else "".join(f"worktree {top}\nHEAD abc\nbranch refs/heads/x\n\n" for top in tops)
|
return lambda *args, **kwargs: "" if args != ("worktree", "list", "--porcelain") else "".join(f"worktree {top}\nHEAD abc\nbranch refs/heads/x\n\n" for top in tops)
|
||||||
|
|
||||||
def test_removes_the_copies_of_worktrees_git_no_longer_lists_and_keeps_the_others(self):
|
def test_removes_the_copies_of_worktrees_git_no_longer_lists_and_keeps_the_others(self):
|
||||||
main.pruned(self.config, self.home, self.listed("/code/acme", "/code/acme-item-5"))
|
main.pruned(self.config, self.state, self.listed("/code/acme", "/code/acme-item-5"))
|
||||||
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
||||||
|
|
||||||
def test_always_keeps_the_copy_of_the_worktree_that_asked(self):
|
def test_always_keeps_the_copy_of_the_worktree_that_asked(self):
|
||||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
main.pruned(self.config, self.state, self.listed("/code/acme"))
|
||||||
self.assertIn(main.worktree_folder(pathlib.Path("/code/acme-item-5")), self.kept())
|
self.assertIn(main.worktree_folder(pathlib.Path("/code/acme-item-5")), self.kept())
|
||||||
|
|
||||||
def test_removes_nothing_where_git_cannot_list_the_worktrees(self):
|
def test_removes_nothing_where_git_cannot_list_the_worktrees(self):
|
||||||
main.pruned(self.config, self.home, lambda *args, **kwargs: Failure("not a repository"))
|
main.pruned(self.config, self.state, lambda *args, **kwargs: Failure("not a repository"))
|
||||||
self.assertEqual(len(self.kept()), 3)
|
self.assertEqual(len(self.kept()), 3)
|
||||||
|
|
||||||
def test_leaves_files_beside_the_folders_alone(self):
|
def test_leaves_files_beside_the_folders_alone(self):
|
||||||
(self.folders / "decisions.md").write_text("from before the folders")
|
(self.folders / "decisions.md").write_text("from before the folders")
|
||||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
main.pruned(self.config, self.state, self.listed("/code/acme"))
|
||||||
self.assertTrue((self.folders / "decisions.md").exists())
|
self.assertTrue((self.folders / "decisions.md").exists())
|
||||||
|
|
||||||
def test_a_copy_that_cannot_be_removed_does_not_fail_the_open(self):
|
def test_a_copy_that_cannot_be_removed_does_not_fail_the_open(self):
|
||||||
self.folders.chmod(0o500)
|
self.folders.chmod(0o500)
|
||||||
self.addCleanup(self.folders.chmod, 0o700)
|
self.addCleanup(self.folders.chmod, 0o700)
|
||||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
main.pruned(self.config, self.state, self.listed("/code/acme"))
|
||||||
self.assertEqual(len(self.kept()), 3)
|
self.assertEqual(len(self.kept()), 3)
|
||||||
|
|
||||||
def test_an_open_prunes_and_a_save_does_not(self):
|
def test_an_open_prunes_and_a_save_does_not(self):
|
||||||
run = self.listed("/code/acme", "/code/acme-item-5")
|
run = self.listed("/code/acme", "/code/acme-item-5")
|
||||||
self.assertEqual(main.performed(self.config, "save", "goals-and-audience", self.home, run), "/code/acme-item-5/README.md is the record itself, so nothing is left to store.")
|
self.assertEqual(main.performed(self.config, "save", "goals-and-audience", self.state, run), "/code/acme-item-5/README.md is the record itself, so nothing is left to store.")
|
||||||
self.assertEqual(len(self.kept()), 3)
|
self.assertEqual(len(self.kept()), 3)
|
||||||
self.assertEqual(main.performed(self.config, "open", "goals-and-audience", self.home, run), "/code/acme-item-5/README.md")
|
self.assertEqual(main.performed(self.config, "open", "goals-and-audience", self.state, run), "/code/acme-item-5/README.md")
|
||||||
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
||||||
|
|
||||||
def test_does_nothing_where_the_project_has_no_copies(self):
|
def test_does_nothing_where_the_project_has_no_copies(self):
|
||||||
main.pruned(worktree_config("/code/acme"), self.home / "elsewhere", self.listed("/code/acme"))
|
main.pruned(worktree_config("/code/acme"), self.state / "elsewhere", self.listed("/code/acme"))
|
||||||
|
|
||||||
|
|
||||||
class Act(unittest.TestCase):
|
class Act(unittest.TestCase):
|
||||||
@@ -130,7 +132,7 @@ class Act(unittest.TestCase):
|
|||||||
class BlackBox(unittest.TestCase):
|
class BlackBox(unittest.TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.top = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())).resolve()
|
self.top = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())).resolve()
|
||||||
self.home = configured(self, self.top).parents[1]
|
self.home = configured(self, self.top).parents[2]
|
||||||
|
|
||||||
def run_tool(self, *args: str) -> subprocess.CompletedProcess[str]:
|
def run_tool(self, *args: str) -> subprocess.CompletedProcess[str]:
|
||||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.top, env=os.environ | {"HOME": str(self.home)}, text=True)
|
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.top, env=os.environ | {"HOME": str(self.home)}, text=True)
|
||||||
@@ -153,7 +155,7 @@ class BlackBox(unittest.TestCase):
|
|||||||
self.assertIn("usage: project-record open|save <record>, where <record> is one of decisions, score-anchors, comprehension-history, reading-cost, changelog, goals-and-audience", ran.stderr)
|
self.assertIn("usage: project-record open|save <record>, where <record> is one of decisions, score-anchors, comprehension-history, reading-cost, changelog, goals-and-audience", ran.stderr)
|
||||||
|
|
||||||
def test_exits_1_saying_why_where_no_config_names_the_checkout(self):
|
def test_exits_1_saying_why_where_no_config_names_the_checkout(self):
|
||||||
(self.home / ".claude-projects" / self.top.name / "config.toml").unlink()
|
(self.home / ".config/build-release" / self.top.name / "config.toml").unlink()
|
||||||
ran = self.run_tool("open", "decisions")
|
ran = self.run_tool("open", "decisions")
|
||||||
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
||||||
self.assertIn("no config names the checkout", ran.stderr)
|
self.assertIn("no config names the checkout", ran.stderr)
|
||||||
|
|||||||
+5
-3
@@ -91,6 +91,8 @@ rules above, a scoring run on docs/comprehension-history.md's newest scored comm
|
|||||||
ending in its overall, an item that is not exempt scoring under the bar, or --check finding the file
|
ending in its overall, an item that is not exempt scoring under the bar, or --check finding the file
|
||||||
unranked, or an item's `Touches:` list unreadable.
|
unranked, or an item's `Touches:` list unreadable.
|
||||||
"""
|
"""
|
||||||
|
from collections.abc import Mapping
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -99,14 +101,14 @@ from plan_store.stores import file_plan
|
|||||||
from project_config.main import located
|
from project_config.main import located
|
||||||
|
|
||||||
|
|
||||||
def main(argv: list[str], home: pathlib.Path) -> int:
|
def main(argv: list[str], home: pathlib.Path, env: Mapping[str, str]) -> int:
|
||||||
if argv[:1] in (["-h"], ["--help"]):
|
if argv[:1] in (["-h"], ["--help"]):
|
||||||
print(__doc__.strip())
|
print(__doc__.strip())
|
||||||
return 0
|
return 0
|
||||||
args = parse_args(argv)
|
args = parse_args(argv)
|
||||||
if isinstance(args, Failure):
|
if isinstance(args, Failure):
|
||||||
return fail(args)
|
return fail(args)
|
||||||
config = located(None, home)
|
config = located(None, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return fail(config)
|
return fail(config)
|
||||||
if config.plan_file is None and args == (True, None):
|
if config.plan_file is None and args == (True, None):
|
||||||
@@ -145,4 +147,4 @@ def parse_args(argv: list[str]) -> tuple[bool, pathlib.Path | None] | Failure:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main(sys.argv[1:], pathlib.Path.home()))
|
sys.exit(main(sys.argv[1:], pathlib.Path.home(), os.environ))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ usage: reading-cost [--reset] [record]
|
|||||||
|
|
||||||
Run it inside a project checkout or one of its worktrees. record defaults to the
|
Run it inside a project checkout or one of its worktrees. record defaults to the
|
||||||
docs/reading-cost.md the project's config names, created when missing. It reads build-release's archive of the project,
|
docs/reading-cost.md the project's config names, created when missing. It reads build-release's archive of the project,
|
||||||
$BUILD_RELEASE_TRANSCRIPTS/<key> (default ~/.claude/loop-claude-transcripts), <key> being the
|
$BUILD_RELEASE_TRANSCRIPTS/<key> (default ~/.local/state/build-release/transcripts), <key> being the
|
||||||
checkout's path relative to ~/code, or to / outside it. For each finished chunk the record does not
|
checkout's path relative to ~/code, or to / outside it. For each finished chunk the record does not
|
||||||
yet hold, it measures what the worker and its subagents read before the worker's first commit: their
|
yet hold, it measures what the worker and its subagents read before the worker's first commit: their
|
||||||
new input tokens (uncached and cache-written; cache reads excluded), and how often they opened or
|
new input tokens (uncached and cache-written; cache reads excluded), and how often they opened or
|
||||||
@@ -21,6 +21,8 @@ lists the files the last 5 chunks read most. With fewer than 10 figures, it says
|
|||||||
|
|
||||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the
|
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the
|
||||||
archive or the record cannot be read or written, or a figure in the record cannot be read back.
|
archive or the record cannot be read or written, or a figure in the record cannot be read back.
|
||||||
|
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class ReadingCostTool(unittest.TestCase):
|
|||||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd, env=self.env, text=True)
|
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd, env=self.env, text=True)
|
||||||
|
|
||||||
def test_writes_the_record_where_the_config_puts_it_and_fails_without_a_config(self):
|
def test_writes_the_record_where_the_config_puts_it_and_fails_without_a_config(self):
|
||||||
config = self.home / ".claude-projects" / "proj" / "config.toml"
|
config = self.home / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(config.read_text().replace('"checkout:docs/reading-cost.md"', '"folder:docs/reading-cost.md"'))
|
config.write_text(config.read_text().replace('"checkout:docs/reading-cost.md"', '"folder:docs/reading-cost.md"'))
|
||||||
record = config.parent / "docs" / "reading-cost.md"
|
record = config.parent / "docs" / "reading-cost.md"
|
||||||
record.parent.mkdir()
|
record.parent.mkdir()
|
||||||
@@ -194,17 +194,17 @@ class ReadingCostTool(unittest.TestCase):
|
|||||||
ran = self.run_tool(worktree)
|
ran = self.run_tool(worktree)
|
||||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||||
history = worktree / "docs" / "reading-cost.md"
|
history = worktree / "docs" / "reading-cost.md"
|
||||||
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} to {history}.\n2 chunks measured since the last reset; the trend needs 10.\n")
|
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.local/state/build-release' / 'transcripts' / 'proj'} to {history}.\n2 chunks measured since the last reset; the trend needs 10.\n")
|
||||||
figure = "## Reading cost, chunk {}, finished {}\n\n33 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 1\n"
|
figure = "## Reading cost, chunk {}, finished {}\n\n33 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 1\n"
|
||||||
self.assertEqual(history.read_text(), "# Reading cost\n\n" + "\n".join(figure.format(chunk.folder[:12], chunk.finished) for chunk in chunks))
|
self.assertEqual(history.read_text(), "# Reading cost\n\n" + "\n".join(figure.format(chunk.folder[:12], chunk.finished) for chunk in chunks))
|
||||||
self.assertTrue(self.run_tool(worktree).stdout.startswith(f"Appended 0 reading-cost figures from"))
|
self.assertTrue(self.run_tool(worktree).stdout.startswith(f"Appended 0 reading-cost figures from"))
|
||||||
self.assertEqual(history.read_text().count("## Reading cost"), 2)
|
self.assertEqual(history.read_text().count("## Reading cost"), 2)
|
||||||
reset = self.run_tool(worktree, "--reset")
|
reset = self.run_tool(worktree, "--reset")
|
||||||
self.assertEqual(reset.stdout, f"Appended 0 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} and a reset to {history}.\n0 chunks measured since the last reset; the trend needs 10.\n")
|
self.assertEqual(reset.stdout, f"Appended 0 reading-cost figures from {self.home / '.local/state/build-release' / 'transcripts' / 'proj'} and a reset to {history}.\n0 chunks measured since the last reset; the trend needs 10.\n")
|
||||||
self.assertRegex(history.read_text(), r"\n## Reading cost reset, \d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\n$")
|
self.assertRegex(history.read_text(), r"\n## Reading cost reset, \d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\n$")
|
||||||
|
|
||||||
def test_counts_a_file_read_in_a_worktree_the_configs_branch_template_names(self):
|
def test_counts_a_file_read_in_a_worktree_the_configs_branch_template_names(self):
|
||||||
config = self.home / ".claude-projects" / "proj" / "config.toml"
|
config = self.home / ".config/build-release" / "proj" / "config.toml"
|
||||||
config.write_text(config.read_text() + 'branch = "feature/PAY-{id}"\n')
|
config.write_text(config.read_text() + 'branch = "feature/PAY-{id}"\n')
|
||||||
self.archive_chunk(1790000100, worktree=self.home / "code" / "proj-feature-PAY-7")
|
self.archive_chunk(1790000100, worktree=self.home / "code" / "proj-feature-PAY-7")
|
||||||
ran = self.run_tool(self.checkout)
|
ran = self.run_tool(self.checkout)
|
||||||
|
|||||||
@@ -168,33 +168,33 @@ class Store(unittest.TestCase):
|
|||||||
return ProjectConfig("acme", folder, top, paths)
|
return ProjectConfig("acme", folder, top, paths)
|
||||||
|
|
||||||
def test_a_record_in_the_checkout_is_tracked_by_its_path_from_the_top(self):
|
def test_a_record_in_the_checkout_is_tracked_by_its_path_from_the_top(self):
|
||||||
store = stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.claude-projects/acme")), "decisions")
|
store = stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.config/build-release/acme")), "decisions")
|
||||||
self.assertEqual((store.label, store.tracked), ("/code/acme/decisions.md", "decisions.md"))
|
self.assertEqual((store.label, store.tracked), ("/code/acme/decisions.md", "decisions.md"))
|
||||||
|
|
||||||
def test_a_record_in_the_configs_folder_is_not_tracked(self):
|
def test_a_record_in_the_configs_folder_is_not_tracked(self):
|
||||||
store = stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.claude-projects/acme")), "changelog")
|
store = stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.config/build-release/acme")), "changelog")
|
||||||
self.assertEqual((store.label, store.tracked), ("/home/me/.claude-projects/acme/CHANGELOG.md", None))
|
self.assertEqual((store.label, store.tracked), ("/home/me/.config/build-release/acme/CHANGELOG.md", None))
|
||||||
|
|
||||||
def test_the_plan_is_not_a_record(self):
|
def test_the_plan_is_not_a_record(self):
|
||||||
with self.assertRaises(ValueError) as refused:
|
with self.assertRaises(ValueError) as refused:
|
||||||
stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.claude-projects/acme")), "plan")
|
stores.store(self.config(pathlib.Path("/code/acme"), pathlib.Path("/home/me/.config/build-release/acme")), "plan")
|
||||||
self.assertEqual(str(refused.exception), "plan is not a record; the records are decisions, score-anchors, comprehension-history, reading-cost, changelog")
|
self.assertEqual(str(refused.exception), "plan is not a record; the records are decisions, score-anchors, comprehension-history, reading-cost, changelog")
|
||||||
|
|
||||||
def test_a_record_on_a_confluence_page_is_that_page(self):
|
def test_a_record_on_a_confluence_page_is_that_page(self):
|
||||||
page = Page("https://acme.atlassian.net", "2293761", "confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761")
|
page = Page("https://acme.atlassian.net", "2293761", "confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761")
|
||||||
config = ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path("/code/acme"), {}, pathlib.Path("/home/me/acme.env"), pages={"decisions": page})
|
config = ProjectConfig("acme", pathlib.Path("/home/me/.config/build-release/acme"), pathlib.Path("/code/acme"), {}, pathlib.Path("/home/me/acme.env"), pages={"decisions": page})
|
||||||
self.assertEqual(stores.store(config, "decisions"), ConfluencePage(page, pathlib.Path("/home/me/acme.env")))
|
self.assertEqual(stores.store(config, "decisions"), ConfluencePage(page, pathlib.Path("/home/me/acme.env")))
|
||||||
|
|
||||||
|
|
||||||
class GoalsStore(unittest.TestCase):
|
class GoalsStore(unittest.TestCase):
|
||||||
def test_goals_kept_as_a_file_are_that_file(self):
|
def test_goals_kept_as_a_file_are_that_file(self):
|
||||||
top = pathlib.Path("/code/acme")
|
top = pathlib.Path("/code/acme")
|
||||||
store = stores.goals_store(ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), top, {"goals-and-audience": top / "README.md"}))
|
store = stores.goals_store(ProjectConfig("acme", pathlib.Path("/home/me/.config/build-release/acme"), top, {"goals-and-audience": top / "README.md"}))
|
||||||
self.assertEqual((store.label, store.tracked), ("/code/acme/README.md", "README.md"))
|
self.assertEqual((store.label, store.tracked), ("/code/acme/README.md", "README.md"))
|
||||||
|
|
||||||
def test_goals_kept_in_jira_are_the_epics_description(self):
|
def test_goals_kept_in_jira_are_the_epics_description(self):
|
||||||
epic = Epic("https://acme.atlassian.net", "ABC-12")
|
epic = Epic("https://acme.atlassian.net", "ABC-12")
|
||||||
store = stores.goals_store(ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path("/code/acme"), {}, pathlib.Path("/home/me/acme.env"), goals_epic=epic))
|
store = stores.goals_store(ProjectConfig("acme", pathlib.Path("/home/me/.config/build-release/acme"), pathlib.Path("/code/acme"), {}, pathlib.Path("/home/me/acme.env"), goals_epic=epic))
|
||||||
self.assertEqual(store, EpicDescription(epic, pathlib.Path("/home/me/acme.env")))
|
self.assertEqual(store, EpicDescription(epic, pathlib.Path("/home/me/acme.env")))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,9 @@ PRIVATE = [
|
|||||||
"daemon.log",
|
"daemon.log",
|
||||||
"daemon/control.key",
|
"daemon/control.key",
|
||||||
"debug/a.txt",
|
"debug/a.txt",
|
||||||
"do-epic-transcripts/a/b.jsonl",
|
|
||||||
"file-history/a/b.md",
|
"file-history/a/b.md",
|
||||||
"history.jsonl",
|
"history.jsonl",
|
||||||
"jobs/a/b.json",
|
"jobs/a/b.json",
|
||||||
"loop-claude-transcripts/a/b.jsonl",
|
|
||||||
"memory/MEMORY.md",
|
"memory/MEMORY.md",
|
||||||
"paste-cache/a.txt",
|
"paste-cache/a.txt",
|
||||||
"projects/-home-a/a.jsonl",
|
"projects/-home-a/a.jsonl",
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ OWNER = "bin/loop_state/paths.py"
|
|||||||
# How code spells one of those folders itself, in place of asking OWNER. Prose such as help text, which names `~/.claude` to its reader, is not matched.
|
# How code spells one of those folders itself, in place of asking OWNER. Prose such as help text, which names `~/.claude` to its reader, is not matched.
|
||||||
RESOLVED_ELSEWHERE = re.compile(
|
RESOLVED_ELSEWHERE = re.compile(
|
||||||
r"""["']\.claude["'/]"""
|
r"""["']\.claude["'/]"""
|
||||||
r"""|["']\.claude-projects["'/]"""
|
r"""|["']\.config["'/]"""
|
||||||
r"""|["']\.local["'/]"""
|
r"""|["']\.local["'/]"""
|
||||||
r"""|["']XDG_STATE_HOME["']"""
|
r"""|["']XDG_(CONFIG|STATE)_HOME["']"""
|
||||||
r"""|__file__\)\.resolve\(\)\.parents\["""
|
r"""|__file__\)\.resolve\(\)\.parents\["""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ usage: review-replay <pass> <model> [--omit-claude-md | --bash-ceiling | --read-
|
|||||||
<pass> is one of architecture, principles, overrides, stability, product-owner or prose.
|
<pass> is one of architecture, principles, overrides, stability, product-owner or prose.
|
||||||
<model> is a project model on the routing ladder this setup ships, such as claude-opus-5-5. The tool replays the
|
<model> is a project model on the routing ladder this setup ships, such as claude-opus-5-5. The tool replays the
|
||||||
latest 10 archived rounds of the pass whose report holds a 🔴 or 🟡 finding, from the projects
|
latest 10 archived rounds of the pass whose report holds a 🔴 or 🟡 finding, from the projects
|
||||||
that ~/.claude/loop-claude-models.json runs on the model. It replays each round on the code it
|
that ~/.config/build-release/models.json runs on the model. It replays each round on the code it
|
||||||
reviewed: in a throwaway clone of the project's checkout, at the newest commit of origin/HEAD
|
reviewed: in a throwaway clone of the project's checkout, at the newest commit of origin/HEAD
|
||||||
authored by the time the round began, on the branch the reviewer started on. The clone's default
|
authored by the time the round began, on the branch the reviewer started on. The clone's default
|
||||||
branch stands at the newest commit authored before the round's chunk began, so a diff against it
|
branch stands at the newest commit authored before the round's chunk began, so a diff against it
|
||||||
@@ -57,7 +57,7 @@ result, is in the archive. It refuses to run where its own environment already h
|
|||||||
replays as archived would inherit it.
|
replays as archived would inherit it.
|
||||||
|
|
||||||
It keeps each run, a reviewer's tool calls included, and the report it prints in build-release's archive, in
|
It keeps each run, a reviewer's tool calls included, and the report it prints in build-release's archive, in
|
||||||
replays/review-replay-<pass>-<model>[-<flag without its leading dashes>]-<UTC stamp>/ under ~/.claude/loop-claude-transcripts
|
replays/review-replay-<pass>-<model>[-<flag without its leading dashes>]-<UTC stamp>/ under ~/.local/state/build-release/transcripts
|
||||||
or $BUILD_RELEASE_TRANSCRIPTS. A run's .jsonl file starts with a line holding claude's arguments, working
|
or $BUILD_RELEASE_TRANSCRIPTS. A run's .jsonl file starts with a line holding claude's arguments, working
|
||||||
directory, prompt, exit code and stderr, then holds claude's stream-json output; result.md holds the report.
|
directory, prompt, exit code and stderr, then holds claude's stream-json output; result.md holds the report.
|
||||||
|
|
||||||
@@ -65,6 +65,9 @@ Like the loop, it tries claude three times running before it counts a reply as f
|
|||||||
review or match leaves its round out, except on a rung below the project's, where it finds
|
review or match leaves its round out, except on a rung below the project's, where it finds
|
||||||
none. Exit 1, saying why, on bad arguments, an unreadable archive or models file, no archived
|
none. Exit 1, saying why, on bad arguments, an unreadable archive or models file, no archived
|
||||||
round to replay, or a usage limit.
|
round to replay, or a usage limit.
|
||||||
|
|
||||||
|
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path.
|
||||||
|
Where XDG_STATE_HOME holds an absolute path, read ~/.local/state in this help as that path.
|
||||||
"""
|
"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import typing
|
import typing
|
||||||
@@ -103,7 +106,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
|||||||
# The replays as archived start under this environment too, so a change it already holds would reach all four.
|
# The replays as archived start under this environment too, so a change it already holds would reach all four.
|
||||||
if change and (inherited := [name for name in change.env if name in env]):
|
if change and (inherited := [name for name in change.env if name in env]):
|
||||||
return failed(TOOL, f"the replays as archived would inherit {', '.join(inherited)} from this environment, and the comparison needs them without it: unset it and run again")
|
return failed(TOOL, f"the replays as archived would inherit {', '.join(inherited)} from this environment, and the comparison needs them without it: unset it and run again")
|
||||||
rounds = archived_rounds(REVIEWERS[reviewed], project.model, archive_root(home, env), home)
|
rounds = archived_rounds(REVIEWERS[reviewed], project.model, archive_root(home, env), home, env)
|
||||||
if isinstance(rounds, Failure):
|
if isinstance(rounds, Failure):
|
||||||
return failed(TOOL, rounds.reason)
|
return failed(TOOL, rounds.reason)
|
||||||
codes = codes_found(rounds, effects, say)
|
codes = codes_found(rounds, effects, say)
|
||||||
@@ -113,14 +116,14 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
|||||||
folder = replay_folder(archive_root(home, env), TOOL, argv, effects.now())
|
folder = replay_folder(archive_root(home, env), TOOL, argv, effects.now())
|
||||||
effects = archiving(effects, folder, say)
|
effects = archiving(effects, folder, say)
|
||||||
if change:
|
if change:
|
||||||
report = compared(reviewed, project, chosen, change, lambda found, applied: findings_replayed(found, codes[found], project, project, home, effects, applied, scratch), say, at_once)
|
report = compared(reviewed, project, chosen, change, lambda found, applied: findings_replayed(found, codes[found], project, project, home, env, effects, applied, scratch), say, at_once)
|
||||||
if isinstance(report, Limited):
|
if isinstance(report, Limited):
|
||||||
return limited_exit(TOOL, report)
|
return limited_exit(TOOL, report)
|
||||||
print_report(folder, report)
|
print_report(folder, report)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def replay_one(found: Round, rung: Rung) -> set[int] | Failure | Limited:
|
def replay_one(found: Round, rung: Rung) -> set[int] | Failure | Limited:
|
||||||
matched = findings_replayed(found, codes[found], rung, project, home, effects, None, scratch)
|
matched = findings_replayed(found, codes[found], rung, project, home, env, effects, None, scratch)
|
||||||
if isinstance(matched, Failure):
|
if isinstance(matched, Failure):
|
||||||
say(f" {found.root} {found.at} on {rung} failed: {matched.reason}")
|
say(f" {found.root} {found.at} on {rung} failed: {matched.reason}")
|
||||||
return matched
|
return matched
|
||||||
|
|||||||
+27
-17
@@ -1,6 +1,7 @@
|
|||||||
"""Replay one archived review round on one rung: the code the round reviewed, found again in a throwaway clone, the reviewer's report on it, and the match of that report to the round's archived findings: docs/decisions.md → `routing: a review pass runs below the project's rung only on a rung whose replay of its rounds finds a share of their 🔴 and 🟡 findings no more than a margin below the project's rung's own replay`."""
|
"""Replay one archived review round on one rung: the code the round reviewed, found again in a throwaway clone, the reviewer's report on it, and the match of that report to the round's archived findings: docs/decisions.md → `routing: a review pass runs below the project's rung only on a rung whose replay of its rounds finds a share of their 🔴 and 🟡 findings no more than a margin below the project's rung's own replay`."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
|
from collections.abc import Mapping
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
@@ -18,10 +19,13 @@ from record_store.stores import local_file, store
|
|||||||
from project_config.main import located
|
from project_config.main import located
|
||||||
from review_rules.reviewer_context import principles_line, reviewer_context
|
from review_rules.reviewer_context import principles_line, reviewer_context
|
||||||
from text_files.compressed import read_stored, SUFFIX
|
from text_files.compressed import read_stored, SUFFIX
|
||||||
from review_rules.review_folder import REPORTS, review_folder
|
from review_rules.review_folder import reports_folder, review_folder
|
||||||
from model_routing.ladder import Rung
|
from model_routing.ladder import Rung
|
||||||
|
from loop_state.paths import STATE_HOME
|
||||||
from claude_code.entries import structured_output
|
from claude_code.entries import structured_output
|
||||||
|
|
||||||
|
# Where, under the home folder, the review folders were until 0.18.0: the prompt of a round archived before then names its review folder there.
|
||||||
|
REPORTS_BEFORE_0_18 = f"{STATE_HOME}/larv-review"
|
||||||
MATCH_SCHEMA = {"type": "object", "properties": {"found": {"type": "array", "items": {"type": "integer"}}}, "required": ["found"], "additionalProperties": False}
|
MATCH_SCHEMA = {"type": "object", "properties": {"found": {"type": "array", "items": {"type": "integer"}}}, "required": ["found"], "additionalProperties": False}
|
||||||
|
|
||||||
|
|
||||||
@@ -75,9 +79,9 @@ def commit_log(listed: str) -> list[tuple[str, float]]:
|
|||||||
return [(commit, float(authored)) for commit, authored in (line.split() for line in listed.splitlines())]
|
return [(commit, float(authored)) for commit, authored in (line.split() for line in listed.splitlines())]
|
||||||
|
|
||||||
|
|
||||||
def findings_replayed(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects, change: Change | None, scratch: pathlib.Path | None) -> set[int] | Failure | Limited:
|
def findings_replayed(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, env: Mapping[str, str], effects: Effects, change: Change | None, scratch: pathlib.Path | None) -> set[int] | Failure | Limited:
|
||||||
"""The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them, or the Failure of the review or the match; where change is given, the replay runs with it, as `launch` says. The clone is made under scratch, or under the system's temporary folder where it is None."""
|
"""The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them, or the Failure of the review or the match; where change is given, the replay runs with it, as `launch` says. The clone is made under scratch, or under the system's temporary folder where it is None."""
|
||||||
reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects, change, scratch))
|
reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, env, effects, change, scratch))
|
||||||
if isinstance(reviewed, (Failure, Limited)):
|
if isinstance(reviewed, (Failure, Limited)):
|
||||||
return reviewed
|
return reviewed
|
||||||
return first_reply(lambda: match(found.findings, reviewed, found.root, project, effects))
|
return first_reply(lambda: match(found.findings, reviewed, found.root, project, effects))
|
||||||
@@ -91,27 +95,27 @@ class Copies:
|
|||||||
|
|
||||||
|
|
||||||
# The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is.
|
# The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is.
|
||||||
def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, change: Change | None, scratch: pathlib.Path | None) -> str | Failure | Limited:
|
def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, env: Mapping[str, str], effects: Effects, change: Change | None, scratch: pathlib.Path | None) -> str | Failure | Limited:
|
||||||
try:
|
try:
|
||||||
(home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True)
|
reports_folder(home, env).mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||||
with tempfile.TemporaryDirectory(prefix="review-replay-", dir=scratch, ignore_cleanup_errors=True) as clone, tempfile.TemporaryDirectory(prefix="review-replay-", dir=home / REPORTS, ignore_cleanup_errors=True) as reports:
|
with tempfile.TemporaryDirectory(prefix="review-replay-", dir=scratch, ignore_cleanup_errors=True) as clone, tempfile.TemporaryDirectory(prefix="review-replay-", dir=reports_folder(home, env), ignore_cleanup_errors=True) as reports:
|
||||||
return reviewed_in(found, code, rung, Copies(clone, reports), home, effects, change)
|
return reviewed_in(found, code, rung, Copies(clone, reports), home, env, effects, change)
|
||||||
except OSError as failure:
|
except OSError as failure:
|
||||||
return Failure(f"could not prepare the replay: {failure}")
|
return Failure(f"could not prepare the replay: {failure}")
|
||||||
|
|
||||||
|
|
||||||
def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: pathlib.Path, effects: Effects, change: Change | None) -> str | Failure | Limited:
|
def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: pathlib.Path, env: Mapping[str, str], effects: Effects, change: Change | None) -> str | Failure | Limited:
|
||||||
"""The report of found's reviewer on rung, replayed on code cloned into copies.clone, with its review folder copied into copies.reports; with change where given."""
|
"""The report of found's reviewer on rung, replayed on code cloned into copies.clone, with its review folder copied into copies.reports; with change where given."""
|
||||||
folder = pathlib.Path(review_folder(str(home), code.path))
|
folder = pathlib.Path(review_folder(str(home), env, code.path))
|
||||||
copy_reports(found, folder, copies.reports)
|
copy_reports(found, folder, copies.reports)
|
||||||
prompt = redirected(found.prompt, home, folder, code.path, copies)
|
prompt = redirected(found.prompt, home, folder, reports_folder(home, env), code.path, copies)
|
||||||
if isinstance(prompt, Failure):
|
if isinstance(prompt, Failure):
|
||||||
return prompt
|
return prompt
|
||||||
if lost := lost_inputs(prompt, copies.reports, lambda name: (pathlib.Path(copies.reports) / name).exists()):
|
if lost := lost_inputs(prompt, copies.reports, lambda name: (pathlib.Path(copies.reports) / name).exists()):
|
||||||
return Failure(f"the prompt names {', '.join(lost)}, which the review folder did not hold from the chunk's start until the round's")
|
return Failure(f"the prompt names {', '.join(lost)}, which the review folder did not hold from the chunk's start until the round's")
|
||||||
if isinstance(cloned := clone_reviewed(found, code, copies.clone, effects), Failure):
|
if isinstance(cloned := clone_reviewed(found, code, copies.clone, effects), Failure):
|
||||||
return cloned
|
return cloned
|
||||||
launched = launch(found.reviewer, rung, prompt, found.root, copies, home, change)
|
launched = launch(found.reviewer, rung, prompt, found.root, copies, home, env, change)
|
||||||
if isinstance(launched, Failure):
|
if isinstance(launched, Failure):
|
||||||
return launched
|
return launched
|
||||||
reply = claude_reply(effects.claude, launched[0], copies.clone, launched[1], "claude")
|
reply = claude_reply(effects.claude, launched[0], copies.clone, launched[1], "claude")
|
||||||
@@ -120,7 +124,7 @@ def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: path
|
|||||||
return reply["result"] if isinstance(reply.get("result"), str) else Failure("the reviewer replied with no report")
|
return reply["result"] if isinstance(reply.get("result"), str) else Failure("the reviewer replied with no report")
|
||||||
|
|
||||||
|
|
||||||
def launch(reviewer: str, rung: Rung, prompt: str, checkout: str, copies: Copies, home: pathlib.Path, change: Change | None) -> tuple[list[str], str] | Failure:
|
def launch(reviewer: str, rung: Rung, prompt: str, checkout: str, copies: Copies, home: pathlib.Path, env: Mapping[str, str], change: Change | None) -> tuple[list[str], str] | Failure:
|
||||||
"""claude's arguments and prompt for reviewer on rung, in copies.clone, a copy of the project whose checkout is checkout. Where change is given, claude starts under the environment change holds, which claude's settings set; where change turns the instruction files off, the prompt holds what the SubagentStart hook and the header's last line hand such a reviewer."""
|
"""claude's arguments and prompt for reviewer on rung, in copies.clone, a copy of the project whose checkout is checkout. Where change is given, claude starts under the environment change holds, which claude's settings set; where change turns the instruction files off, the prompt holds what the SubagentStart hook and the header's last line hand such a reviewer."""
|
||||||
args = ["--agent", reviewer, *rung.flags()]
|
args = ["--agent", reviewer, *rung.flags()]
|
||||||
if change is None:
|
if change is None:
|
||||||
@@ -132,7 +136,7 @@ def launch(reviewer: str, rung: Rung, prompt: str, checkout: str, copies: Copies
|
|||||||
context = reviewer_context(home)
|
context = reviewer_context(home)
|
||||||
if isinstance(context, Failure):
|
if isinstance(context, Failure):
|
||||||
return context
|
return context
|
||||||
config = located(checkout, home)
|
config = located(checkout, home, env)
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
return config
|
return config
|
||||||
record = store(config, "decisions")
|
record = store(config, "decisions")
|
||||||
@@ -160,12 +164,18 @@ def copy_reports(found: Round, folder: pathlib.Path, reports: str) -> None:
|
|||||||
(pathlib.Path(reports) / name).write_bytes(read_stored(folder / name))
|
(pathlib.Path(reports) / name).write_bytes(read_stored(folder / name))
|
||||||
|
|
||||||
|
|
||||||
def redirected(prompt: str, home: pathlib.Path, folder: pathlib.Path, worktree: str, copies: Copies) -> str | Failure:
|
def redirected(prompt: str, home: pathlib.Path, folder: pathlib.Path, reports: pathlib.Path, worktree: str, copies: Copies) -> str | Failure:
|
||||||
"""prompt naming copies.reports in place of the review folder, in either spelling, and copies.clone in place of the worktree; a Failure where it still names the review folder."""
|
"""prompt naming copies.reports in place of the review folder, in each spelling, and copies.clone in place of the worktree; a Failure where it still names a review folder. folder is the chunk's review folder, in the reports folder reports."""
|
||||||
# Replace the folder's path first: outside home it contains the worktree's path, which replacing the worktree's would otherwise turn into the clone's.
|
# Replace the folder's path first: outside home it contains the worktree's path, which replacing the worktree's would otherwise turn into the clone's.
|
||||||
prompt = prompt.replace(str(folder), copies.reports).replace(f"~/{folder.relative_to(home)}", copies.reports).replace(worktree, copies.clone)
|
for root in (reports, home / REPORTS_BEFORE_0_18):
|
||||||
|
named = root / folder.relative_to(reports)
|
||||||
|
prompt = prompt.replace(str(named), copies.reports)
|
||||||
|
if named.is_relative_to(home):
|
||||||
|
prompt = prompt.replace(f"~/{named.relative_to(home)}", copies.reports)
|
||||||
|
prompt = prompt.replace(worktree, copies.clone)
|
||||||
# A spelling the rewrite misses, such as $HOME/, would leave the reviewer the live folder and the findings in it.
|
# A spelling the rewrite misses, such as $HOME/, would leave the reviewer the live folder and the findings in it.
|
||||||
if REPORTS in prompt.replace(copies.reports, ""):
|
rest = prompt.replace(copies.reports, "")
|
||||||
|
if any(spelling in rest for spelling in (REPORTS_BEFORE_0_18, f"{reports.parent.name}/{reports.name}")):
|
||||||
return Failure("the prompt names the review folder in a spelling the replay does not redirect")
|
return Failure("the prompt names the review folder in a spelling the replay does not redirect")
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ def sample(rounds: list[Round], latest: int) -> list[Round]:
|
|||||||
return sorted(rounds, key=lambda found: (found.seconds, found.root))[-latest:]
|
return sorted(rounds, key=lambda found: (found.seconds, found.root))[-latest:]
|
||||||
|
|
||||||
|
|
||||||
def archived_rounds(reviewer: str, model: str, root: pathlib.Path, home: pathlib.Path) -> list[Round] | Failure:
|
def archived_rounds(reviewer: str, model: str, root: pathlib.Path, home: pathlib.Path, env: typing.Mapping[str, str]) -> list[Round] | Failure:
|
||||||
projects = projects_on(model, home)
|
projects = projects_on(model, home, env)
|
||||||
if isinstance(projects, Failure):
|
if isinstance(projects, Failure):
|
||||||
return projects
|
return projects
|
||||||
found = []
|
found = []
|
||||||
|
|||||||
@@ -129,11 +129,11 @@ class Launch(unittest.TestCase):
|
|||||||
self.config = configured(self, self.checkout, home=self.home) / "config.toml"
|
self.config = configured(self, self.checkout, home=self.home) / "config.toml"
|
||||||
|
|
||||||
def test_runs_the_reviewer_as_archived_with_claude_md(self):
|
def test_runs_the_reviewer_as_archived_with_claude_md(self):
|
||||||
self.assertEqual(replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, None), (["--agent", "prose-reviewer", *REFERENCE.flags()], "Review it."))
|
self.assertEqual(replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, None), (["--agent", "prose-reviewer", *REFERENCE.flags()], "Review it."))
|
||||||
|
|
||||||
def test_drops_claude_md_and_hands_the_reviewer_what_the_hook_and_the_header_would(self):
|
def test_drops_claude_md_and_hands_the_reviewer_what_the_hook_and_the_header_would(self):
|
||||||
(self.clone / "AGENTS.md").write_text("")
|
(self.clone / "AGENTS.md").write_text("")
|
||||||
args, prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, changes.OMIT)
|
args, prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, changes.OMIT)
|
||||||
self.assertEqual(args, ["--agent", "prose-reviewer", *REFERENCE.flags(), "--settings", json.dumps({"env": {"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1"}})])
|
self.assertEqual(args, ["--agent", "prose-reviewer", *REFERENCE.flags(), "--settings", json.dumps({"env": {"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1"}})])
|
||||||
self.assertEqual(prompt, f"{reviewer_context(self.home)}\n\nReview it.\nPrinciples: read {self.clone}/AGENTS.md first, for the project principles and the decision titles.")
|
self.assertEqual(prompt, f"{reviewer_context(self.home)}\n\nReview it.\nPrinciples: read {self.clone}/AGENTS.md first, for the project principles and the decision titles.")
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ class Launch(unittest.TestCase):
|
|||||||
self.config.write_text(self.config.read_text().replace('"checkout:AGENTS.md"', '"folder:AGENTS.md"'))
|
self.config.write_text(self.config.read_text().replace('"checkout:AGENTS.md"', '"folder:AGENTS.md"'))
|
||||||
(self.clone / "AGENTS.md").write_text("")
|
(self.clone / "AGENTS.md").write_text("")
|
||||||
(self.config.parent / "AGENTS.md").write_text("")
|
(self.config.parent / "AGENTS.md").write_text("")
|
||||||
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, changes.OMIT)[1]
|
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, changes.OMIT)[1]
|
||||||
self.assertTrue(prompt.endswith(f"Principles: read {self.config.parent}/AGENTS.md first, for the project principles and the decision titles."), prompt)
|
self.assertTrue(prompt.endswith(f"Principles: read {self.config.parent}/AGENTS.md first, for the project principles and the decision titles."), prompt)
|
||||||
|
|
||||||
def test_names_the_decision_log_in_the_clone_or_where_it_stands_outside_the_checkout_without_agents_md(self):
|
def test_names_the_decision_log_in_the_clone_or_where_it_stands_outside_the_checkout_without_agents_md(self):
|
||||||
@@ -151,16 +151,16 @@ class Launch(unittest.TestCase):
|
|||||||
self.config.write_text(self.config.read_text().replace('"checkout:docs/decisions.md"', f'"{setting}"'))
|
self.config.write_text(self.config.read_text().replace('"checkout:docs/decisions.md"', f'"{setting}"'))
|
||||||
decisions.parent.mkdir(exist_ok=True)
|
decisions.parent.mkdir(exist_ok=True)
|
||||||
decisions.write_text("1. A principle.\n\n# Decisions\n")
|
decisions.write_text("1. A principle.\n\n# Decisions\n")
|
||||||
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, changes.OMIT)[1]
|
prompt = replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, changes.OMIT)[1]
|
||||||
self.assertTrue(prompt.endswith(f"Principles: read {decisions} first, up to `# Decisions`, for the project principles and the decision titles."), prompt)
|
self.assertTrue(prompt.endswith(f"Principles: read {decisions} first, up to `# Decisions`, for the project principles and the decision titles."), prompt)
|
||||||
|
|
||||||
def test_fails_without_a_config_for_the_checkout(self):
|
def test_fails_without_a_config_for_the_checkout(self):
|
||||||
self.config.unlink()
|
self.config.unlink()
|
||||||
self.assertIn("no config names the checkout", replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, changes.OMIT).reason)
|
self.assertIn("no config names the checkout", replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, changes.OMIT).reason)
|
||||||
|
|
||||||
def test_fails_without_the_sections_to_hand_over(self):
|
def test_fails_without_the_sections_to_hand_over(self):
|
||||||
(self.home / ".claude" / "CLAUDE.md").write_text("")
|
(self.home / ".claude" / "CLAUDE.md").write_text("")
|
||||||
self.assertIsInstance(replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, changes.OMIT), Failure)
|
self.assertIsInstance(replay.launch("prose-reviewer", REFERENCE, "Review it.", str(self.checkout), replay.Copies(str(self.clone), str(self.reports)), self.home, {}, changes.OMIT), Failure)
|
||||||
|
|
||||||
|
|
||||||
class Match(unittest.TestCase):
|
class Match(unittest.TestCase):
|
||||||
@@ -204,9 +204,10 @@ class Main(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||||
self.archive = self.home / ".claude" / "loop-claude-transcripts"
|
self.archive = self.home / ".local/state/build-release" / "transcripts"
|
||||||
(self.home / ".claude").mkdir()
|
(self.home / ".claude").mkdir()
|
||||||
(self.home / ".claude" / "loop-claude-models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-sonnet-5-5"}))
|
(self.home / ".config/build-release").mkdir(parents=True)
|
||||||
|
(self.home / ".config/build-release" / "models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-sonnet-5-5"}))
|
||||||
origin, self.checkout = self.home / "origin.git", self.home / "code" / "proj"
|
origin, self.checkout = self.home / "origin.git", self.home / "code" / "proj"
|
||||||
run_git(self.home, "init", "-q", "--bare", "-b", "main", str(origin))
|
run_git(self.home, "init", "-q", "--bare", "-b", "main", str(origin))
|
||||||
run_git(self.home, "clone", "-q", str(origin), str(self.checkout))
|
run_git(self.home, "clone", "-q", str(origin), str(self.checkout))
|
||||||
@@ -278,7 +279,7 @@ class Main(unittest.TestCase):
|
|||||||
def test_keeps_each_reviewer_and_match_run_and_the_printed_report_in_one_folder_of_the_archive(self):
|
def test_keeps_each_reviewer_and_match_run_and_the_printed_report_in_one_folder_of_the_archive(self):
|
||||||
code, out, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0, 1]})
|
code, out, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0, 1]})
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
folder = self.home / ".claude" / "loop-claude-transcripts" / "replays" / "review-replay-stability-claude-opus-5-5-20260921T141320Z"
|
folder = self.home / ".local/state/build-release" / "transcripts" / "replays" / "review-replay-stability-claude-opus-5-5-20260921T141320Z"
|
||||||
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
self.assertEqual((folder / "result.md").read_text(encoding="utf-8"), out)
|
||||||
runs = [json.loads(path.read_text(encoding="utf-8").splitlines()[0]) for path in folder.glob("*.jsonl")]
|
runs = [json.loads(path.read_text(encoding="utf-8").splitlines()[0]) for path in folder.glob("*.jsonl")]
|
||||||
# A run that repeats another word for word, as the fakes' do, is kept once.
|
# A run that repeats another word for word, as the fakes' do, is kept once.
|
||||||
@@ -445,7 +446,7 @@ class Main(unittest.TestCase):
|
|||||||
|
|
||||||
def review_folder_with_round_1(self):
|
def review_folder_with_round_1(self):
|
||||||
"""The chunk's review folder. The chunk began at 09:15 and the replayed round 2 at 10:00. It holds round 1's report, written at 09:15:00; round 2's report, written after 10:00; the prose pass's report, written at 10:00:00; and an earlier attempt's report, from before 09:15."""
|
"""The chunk's review folder. The chunk began at 09:15 and the replayed round 2 at 10:00. It holds round 1's report, written at 09:15:00; round 2's report, written after 10:00; the prose pass's report, written at 10:00:00; and an earlier attempt's report, from before 09:15."""
|
||||||
folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x"
|
folder = self.home / ".local" / "state" / "build-release" / "larv-review" / "code" / "proj-x"
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
(folder / "stability-round-1.md").write_text("round 1\n")
|
(folder / "stability-round-1.md").write_text("round 1\n")
|
||||||
began = stamp_seconds("2026-10-14T09:15:00Z")
|
began = stamp_seconds("2026-10-14T09:15:00Z")
|
||||||
@@ -469,7 +470,7 @@ class Main(unittest.TestCase):
|
|||||||
def test_copies_a_compressed_report_from_before_the_round_under_its_plain_name(self):
|
def test_copies_a_compressed_report_from_before_the_round_under_its_plain_name(self):
|
||||||
folder = self.review_folder_with_round_1()
|
folder = self.review_folder_with_round_1()
|
||||||
self.assertIsNone(compress(folder / "stability-round-1.md"))
|
self.assertIsNone(compress(folder / "stability-round-1.md"))
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/larv-review/code/proj-x/stability-round-1.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/build-release/larv-review/code/proj-x/stability-round-1.md.")
|
||||||
seen = []
|
seen = []
|
||||||
|
|
||||||
def review(rung):
|
def review(rung):
|
||||||
@@ -483,7 +484,7 @@ class Main(unittest.TestCase):
|
|||||||
|
|
||||||
def test_points_the_prompts_review_folder_at_a_copy_of_the_reports_from_before_the_round_that_it_removes(self):
|
def test_points_the_prompts_review_folder_at_a_copy_of_the_reports_from_before_the_round_that_it_removes(self):
|
||||||
folder = self.review_folder_with_round_1()
|
folder = self.review_folder_with_round_1()
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/larv-review/code/proj-x/stability-round-1.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/build-release/larv-review/code/proj-x/stability-round-1.md.")
|
||||||
seen = []
|
seen = []
|
||||||
|
|
||||||
def review(rung):
|
def review(rung):
|
||||||
@@ -512,9 +513,19 @@ class Main(unittest.TestCase):
|
|||||||
self.assertNotIn(str(folder), prompt)
|
self.assertNotIn(str(folder), prompt)
|
||||||
self.assertRegex(prompt, rf"report to {folder.parents[1]}/review-replay-\w+/stability-round-2\.md\.$")
|
self.assertRegex(prompt, rf"report to {folder.parents[1]}/review-replay-\w+/stability-round-2\.md\.$")
|
||||||
|
|
||||||
|
def test_points_a_review_folder_named_where_it_was_before_0_18_at_the_copy(self):
|
||||||
|
folder = self.review_folder_with_round_1()
|
||||||
|
for spelling in (f"{self.home}/.local/state/larv-review", "~/.local/state/larv-review"):
|
||||||
|
with self.subTest(spelling=spelling):
|
||||||
|
self.reviews.clear()
|
||||||
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to {spelling}/{folder.relative_to(folder.parents[1])}/stability-round-2.md.")
|
||||||
|
code, _, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0, 1]})
|
||||||
|
self.assertEqual(code, 0, err)
|
||||||
|
self.assertRegex(self.reviews[0][4], rf"report to {folder.parents[1]}/review-replay-\w+/stability-round-2\.md\.$")
|
||||||
|
|
||||||
def test_replays_no_round_whose_prompt_still_names_the_review_folder_after_the_rewrite(self):
|
def test_replays_no_round_whose_prompt_still_names_the_review_folder_after_the_rewrite(self):
|
||||||
self.review_folder_with_round_1()
|
self.review_folder_with_round_1()
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to $HOME/.local/state/larv-review/code/proj-x/stability-round-2.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to $HOME/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md.")
|
||||||
code, out, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
code, out, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertEqual(self.reviews, [])
|
self.assertEqual(self.reviews, [])
|
||||||
@@ -527,7 +538,7 @@ class Main(unittest.TestCase):
|
|||||||
(folder / "branch.diff").write_text("the diff\n")
|
(folder / "branch.diff").write_text("the diff\n")
|
||||||
before = stamp_seconds("2026-10-14T09:50:00Z")
|
before = stamp_seconds("2026-10-14T09:50:00Z")
|
||||||
os.utime(folder / "branch.diff", (before, before))
|
os.utime(folder / "branch.diff", (before, before))
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. The diff is ~/.local/state/larv-review/code/proj-x/branch.diff. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. The diff is ~/.local/state/build-release/larv-review/code/proj-x/branch.diff. Write your report to ~/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md.")
|
||||||
code, _, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0, 1]})
|
code, _, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0, 1]})
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertRegex(self.reviews[0][4], rf"The diff is {folder.parents[1]}/review-replay-\w+/branch\.diff\.")
|
self.assertRegex(self.reviews[0][4], rf"The diff is {folder.parents[1]}/review-replay-\w+/branch\.diff\.")
|
||||||
@@ -535,7 +546,7 @@ class Main(unittest.TestCase):
|
|||||||
def test_replays_no_round_whose_prompt_names_an_input_the_folder_holds_only_as_rewritten_after_the_round_began(self):
|
def test_replays_no_round_whose_prompt_names_an_input_the_folder_holds_only_as_rewritten_after_the_round_began(self):
|
||||||
folder = self.review_folder_with_round_1()
|
folder = self.review_folder_with_round_1()
|
||||||
(folder / "branch.diff").write_text("a later diff\n")
|
(folder / "branch.diff").write_text("a later diff\n")
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. The diff is ~/.local/state/larv-review/code/proj-x/branch.diff. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. The diff is ~/.local/state/build-release/larv-review/code/proj-x/branch.diff. Write your report to ~/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md.")
|
||||||
code, out, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
code, out, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertEqual(self.reviews, [])
|
self.assertEqual(self.reviews, [])
|
||||||
@@ -544,7 +555,7 @@ class Main(unittest.TestCase):
|
|||||||
def test_fails_the_replay_and_leaves_no_folder_behind_when_it_cannot_copy_the_reports(self):
|
def test_fails_the_replay_and_leaves_no_folder_behind_when_it_cannot_copy_the_reports(self):
|
||||||
folder = self.review_folder_with_round_1()
|
folder = self.review_folder_with_round_1()
|
||||||
(folder / "stability-round-1.md").chmod(0)
|
(folder / "stability-round-1.md").chmod(0)
|
||||||
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md.")
|
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/build-release/larv-review/code/proj-x/stability-round-2.md.")
|
||||||
scratch = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
scratch = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||||
self.limits["scratch"] = scratch
|
self.limits["scratch"] = scratch
|
||||||
code, _, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
code, _, err = self.run_main(["stability", "claude-opus-5-5"], unused)
|
||||||
|
|||||||
@@ -1,27 +1,31 @@
|
|||||||
"""The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md → "Reports"."""
|
"""The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md → "Reports"."""
|
||||||
|
from collections.abc import Mapping
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
from review_rules.round_titles import Findings, reported
|
from review_rules.round_titles import Findings, reported
|
||||||
from loop_state.paths import STATE_FOLDER
|
from loop_state.paths import state_folder
|
||||||
|
|
||||||
# Why here: docs/decisions.md → `review: each reviewer under agents/ writes its full report into the chunk's review folder`.
|
# Why here: docs/decisions.md → `review: each reviewer under agents/ writes its full report into the chunk's review folder`.
|
||||||
REPORTS = f"{STATE_FOLDER}/larv-review"
|
def reports_folder(home: pathlib.Path, env: Mapping[str, str]) -> pathlib.Path:
|
||||||
|
"""The folder that holds every chunk's review folder."""
|
||||||
|
return state_folder(env, home) / "larv-review"
|
||||||
|
|
||||||
|
|
||||||
def review_folder(home: str, worktree: str) -> str:
|
def review_folder(home: str, env: Mapping[str, str], worktree: str) -> str:
|
||||||
"""The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under REPORTS."""
|
"""The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under the reports folder."""
|
||||||
inside = worktree.startswith(home.rstrip("/") + "/")
|
inside = worktree.startswith(home.rstrip("/") + "/")
|
||||||
return os.path.join(home, REPORTS, os.path.relpath(worktree, home) if inside else worktree.lstrip("/"))
|
return os.path.join(reports_folder(pathlib.Path(home), env), os.path.relpath(worktree, home) if inside else worktree.lstrip("/"))
|
||||||
|
|
||||||
|
|
||||||
def made_review_folder(worktree: str, home: pathlib.Path) -> pathlib.Path | Failure:
|
def made_review_folder(worktree: str, home: pathlib.Path, env: Mapping[str, str]) -> pathlib.Path | Failure:
|
||||||
"""Makes the review folder of the chunk whose worktree is at worktree, leaving REPORTS readable by the user alone, and returns its path."""
|
"""Makes the review folder of the chunk whose worktree is at worktree, leaving the reports folder readable by the user alone, and returns its path."""
|
||||||
folder = pathlib.Path(review_folder(str(home), worktree))
|
folder = pathlib.Path(review_folder(str(home), env, worktree))
|
||||||
|
reports = reports_folder(home, env)
|
||||||
try:
|
try:
|
||||||
(home / REPORTS).mkdir(parents=True, exist_ok=True)
|
reports.mkdir(parents=True, exist_ok=True)
|
||||||
(home / REPORTS).chmod(0o700)
|
reports.chmod(0o700)
|
||||||
folder.mkdir(parents=True, exist_ok=True)
|
folder.mkdir(parents=True, exist_ok=True)
|
||||||
except OSError as failure:
|
except OSError as failure:
|
||||||
return Failure(f"could not make the review folder {folder}: {failure}")
|
return Failure(f"could not make the review folder {folder}: {failure}")
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ from review_rules.review_folder import findings_in, review_folder, standing_repo
|
|||||||
|
|
||||||
class ReviewFolder(unittest.TestCase):
|
class ReviewFolder(unittest.TestCase):
|
||||||
def test_keys_a_worktree_under_home_by_its_path_relative_to_home(self):
|
def test_keys_a_worktree_under_home_by_its_path_relative_to_home(self):
|
||||||
self.assertEqual(review_folder("/h", "/h/code/proj-item-3"), "/h/.local/state/larv-review/code/proj-item-3")
|
self.assertEqual(review_folder("/h", {}, "/h/code/proj-item-3"), "/h/.local/state/build-release/larv-review/code/proj-item-3")
|
||||||
|
|
||||||
def test_keys_a_worktree_outside_home_by_its_path_relative_to_the_root(self):
|
def test_keys_a_worktree_outside_home_by_its_path_relative_to_the_root(self):
|
||||||
self.assertEqual(review_folder("/h", "/srv/proj-item-3"), "/h/.local/state/larv-review/srv/proj-item-3")
|
self.assertEqual(review_folder("/h", {}, "/srv/proj-item-3"), "/h/.local/state/build-release/larv-review/srv/proj-item-3")
|
||||||
self.assertEqual(review_folder("/h", "/hx/proj"), "/h/.local/state/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it")
|
self.assertEqual(review_folder("/h", {}, "/hx/proj"), "/h/.local/state/build-release/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it")
|
||||||
|
|
||||||
|
|
||||||
class RoundReport(unittest.TestCase):
|
class RoundReport(unittest.TestCase):
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user