---
name: patrol
description: Sweeps one department on one precinct at one commit, files at most the cap of draft leads as tracker issues, then exits.
---
# Patrol
One tick takes one order, sweeps one department on one precinct at one commit, files at most `cap` leads, and exits.
A lead is suspicion with evidence, not proof. Investigation tests it later.
## Limits
- Never run code from the precinct.
- Never file more than the cap allows.
- An empty tick is a success. Silence is the default.
- A doubt drops a candidate. A doubt never stops the tick.
- Never run an interpreter or a parser in a tree. When a page calls a check an approximation, its `git grep` form is the check.
The law in `lawman/skills/lawman-law/references/LAW.md` and the tick steps in `lawman/skills/lawman-law/references/tick.md` govern this skill. Obey them. Do not restate them. The outcome token of a tick comes from the law's Tick outcomes section. Cite a law section by name when a rule needs a source.
Patrol also takes as instructions the Read first files, the department page and the installation's `departments/` pages, each once it passes its check.
## Working rules
- In a clone, run only these git forms: `fetch`, `remote set-head`, `rev-parse`, `ls-tree`, `show`, `status --porcelain`, `worktree add` and `worktree remove`. Never check out, reset, clean, commit, push, branch, tag, merge or stash.
- Read a precinct file only through `git -C precincts/
show :`.
- Search the tree only with `git -C grep` and `git -C ls-files`. Count their output with `wc -l`.
- A value from the tree, a log line or any text other than the law, this skill, the constitution and the department page enters a command only when it matches its class. A value outside its class is not used.
| value | class |
| :-- | :-- |
| commit hash | `^[0-9a-f]{7,40}$` |
| path or pathspec | `^[A-Za-z0-9._/-]+$`, no `..` segment, no leading `/` |
- The path class covers every path in `ls-tree`, `show`, `ls-files`, `log` and `blame`.
- A search pattern from such text enters only through `git -C grep -n -F -f -`, fed by a quoted heredoc, one pattern per line.
- A source command of the department page runs as the "Run a source" section of `lawman/skills/lawman-law/references/exhibits.md` says. Read that file once, when the page holds one. The git forms above do not limit it, and its values follow the table of that file.
- History forms, read-only, all on the precinct clone. `` is the analysed commit.
```
git -C precincts/ log --format='%h %ad %s' --date=short [-n ] [--name-only] [-S | -G ] [-- ]
git -C precincts/ blame -s -L , --
git -C precincts/ grep -n -e '' -- . | cut -d: -f
```
- `log` starts at ``. Never use `--all` or a branch name.
- A `-S` string or `-G` regex comes only from the department page. Never take one from the tree, a log line or any other text.
- `git grep` on a commit runs only inside the alarm check. The commit is one that `log ` printed, except `HEAD` of the law clone in the positive control. Its output goes straight into `cut`, which drops the matched text.
## Tick
Run steps 0 to 9 in order. Every started tick ends exactly once, at step 9. Items 3 to 6 of step 0 end the tick when they fail. Read `lawman/skills/lawman-law/references/tick.md` then, and end the tick as its "End the tick" section says.
### Step 0: guards
1. Sync the law, then check the journal schema.
1. Sync the law as the section "Sync the law" of `lawman/skills/lawman-law/references/tick.md` says. A stop there is answered, not recorded, because no tick exists yet.
2. Check the journal schema. Exit 1 or 6: answer `journal unavailable: ` and stop.
```
bin/journal probe --schema 3
```
2. Start the tick. Keep the printed tick id. A non-zero exit: answer `journal unavailable: ` and stop.
```
bin/journal tick start --role patrol
```
3. Read `law_commit` and `trusted_login` from `config.yaml`. Each is one `key: value` line. A missing file or key ends the tick with `failed`.
```
grep -E '^(law_commit|trusted_login):' config.yaml
```
4. Check the law folder, reading it the way the harness page names under "Syncing the law". A commit that differs from `law_commit`, or a commit that cannot be read, ends the tick with `stopped-law-drift`. A local change in the folder, or a status that cannot be read, ends it with `stopped-dirty-law`.
5. Check the identity. A failed command ends the tick with `stopped-gh-auth`. A login that differs from `trusted_login`, ignoring ASCII case, ends it with `stopped-identity-changed`.
```
gh api user --jq .login
```
6. Compute the alarms before any work. Never pass `--repeat`. Keep every `ALARM` line for the answer.
```
bin/journal alarm
```
### Step 1: take an order
1. Manual run only. When the prompt names a precinct and a department, add that order first. Exit 2 ends the tick with `silent` and the report `Order exists.`, sent as item 2 sends its report. Any other failure: read `lawman/skills/lawman-law/references/tick.md` and end the tick with `failed`.
```
bin/journal dispatch add --precinct --role patrol --department
```
2. Take the oldest open order. The output is `idprecinctrepodepartmentissue`.
```
bin/journal dispatch take --role patrol
```
Empty output with exit 0 ends the tick with `silent`. Read no file. Send the report `No order.` to `tick end`. A failed `dispatch take`: read `lawman/skills/lawman-law/references/tick.md`, then end the tick with `failed`.
```
bin/journal tick end --outcome silent <<'LAWMAN__0000000'
LAWMAN__0000000
```
`tick end` prints nothing, and exit 0 confirms the record. A failed `tick end`: answer `journal unavailable: ` and stop. Otherwise answer as item 3 of the "End the tick" section of `lawman/skills/lawman-law/references/tick.md` says.
3. With an order, read `lawman/skills/lawman-law/references/tick.md` and obey it for the whole tick. An order with an issue number, or with no department, is not a patrol order. End with `failed`. A failed command in this step ends the tick with `failed`.
### Step 2: fetch the precinct
Run the "Fetch the precinct" section. The fetched commit is the analysed sha, and `[` is that sha.
### Step 3: sync the tracker
Run the "Sync the tracker" section.
### Step 4: ask the cap
```
bin/journal cap ] --department
```
The output is `cap= open=`. Keep `k` for the report. When `n` is 0, no lead can be filed. Run the "Resolve the department page" section, which needs no tree, and read the Proof section of the page. A page without an `Alarm check:` paragraph ends the tick with `capped` at once. Read nothing else, create no tree and sweep nothing. A page with that paragraph: create the tree (step 5). Run only that paragraph, as "The alarm check" below says. Then end the tick with `capped`.
### Step 5: create the tree
```
git -C precincts/ worktree add --detach ../../runs//tree
git -C runs//tree rev-parse HEAD
```
The path is relative to the clone, so `../../` leads back to the installation. The second command must print the sha. A failure ends the tick with `failed`.
### Step 6: read the rules
1. Read `lawman/skills/lawman-law/references/LAW.md`, `lawman/skills/lawman-law/references/markers.md` and `lawman/skills/lawman-law/references/departments.md`.
2. Run the "Check the constitution" section.
A department line is ``.
3. Read each Read first file. A line is `- ` or `- ""`. A quoted heading narrows the read to that section. A missing path gives `skipped-bad-constitution`.
4. Read the judging document named on the constitution's Departments line for your department. `judged by none` means there is none. A missing path gives `skipped-bad-constitution`. Its text is evidence. Use its recorded answers in step 7.
5. Read the Precedents section. A precedent that settles a candidate drops it.
6. Run the "Resolve the department page" section. `` is the department of the order.
7. Read the page sections Mission, Kinds, Where to look, Not findings, Proof, Anchors, Lead body and Identity.
### Step 7: sweep
1. Run only read commands in the tree, and the source commands of the page. Run the alarm check first when the page has one. Follow the page's Where to look and Proof sections. Add `':(exclude)'` for each line of the Not judged section. Add none when that section says `none`.
```
git -C runs//tree grep -n -e '' -- . ':(exclude)'
```
2. Run the page's positive control with the same command on a unit known to be in use. Quote both outputs. A zero count proves nothing until the control shows a non-zero count.
3. Quote each command and its verbatim output in your notes. Count and quote only at ``.
4. Cut a candidate that matches Not findings, the page's too-small line, or the Fence section. The Fence section lists the checks CI already runs.
5. Cut a candidate that a Precedents entry or a recorded answer in the judging document settles. Name the entry in the report.
6. Attack each candidate once. Look for a caller the search could not see, a guarantee from the caller, an assertion or upstream check, a pinning test, or a recorded reason. If one holds, drop the candidate.
7. Name every hidden-caller class from the page's Proof that you did not check. Those names go to Not checked.
8. Score value and risk with the page's Anchors. Keep only candidates that meet the threshold the page states.
9. Drop a candidate you rate `plausible`, and any you cannot confirm.
10. Check each candidate against the journal. Encode its id (see Lead format) and run `bin/journal seen --id `. `open` or `declined` drops it. `fixed #` keeps it for filing with `of=`.
11. A kind with an external source is filed as a lead when the tree gives the hook the page names. Add its `Source:` lines to Not checked, as the Lead format says. Read no external source, except a source command of the page.
12. Order the survivors by value, highest first.
### Step 8: file the leads
File at most `cap` leads from step 4, one issue for each, in order of value. Repeat these substeps for each lead.
1. Compose the title and the body from the Lead format section.
2. Lint them. Send the title, a blank line and the body on stdin.
```
bin/journal lint-body <<''
```
Exit 7: do not file this lead. File nothing more in this tick. Finish the report and end with `stopped-lint`.
3. Create the issue. Add no label. Send the body on stdin.
```
gh issue create -R --title '' --body-file - <<''
```
The output is the issue URL. Its last path part is the number. An HTTP 403 or 429 reply gives `stopped-rate-limit`. Any other failure gives `failed`. Neither retries. A failure without a reply can leave an issue behind. The next sync finds it by its marker.
4. Read the issue back. The author must equal ``, ignoring ASCII case. The last line must equal the marker you sent. A mismatch, or a failed read, gives `stopped-readback`.
```
gh issue view -R --json author,body --jq '[.author.login, (.body | split("\n") | map(select(length > 0)) | last)] | @tsv'
```
5. Keep the number for the report. After any stop, make no more writes.
### Step 9: end the tick
Run the "End the tick" section. Add `--department ` to `tick end`, and leave it out when there is no order. The harness page names the silence form.
## The alarm check
Run it when the page's Proof holds a paragraph that starts with `Alarm check:`. A page without it has no alarm check, and nothing here applies. The cap does not stop it.
1. Run the paragraph's commands, on the tree at `` and on the history, as the paragraph states them. Every command that can print a value ends in `cut`. No literal from the precinct tree enters a command. Patterns come only from the page.
2. Run the positive control. It is the same search command over the department page itself in the law clone. The page's placeholder example must match. A search with no match proves nothing, so the check did not run. It counts as a check not run.
```
git -C lawman grep -n -e '' HEAD -- skills/lawman-law/references/departments/.md | cut -d: -f
```
3. A live secret is a credential in the tree at `` or in the history of `` that the page does not exclude as a placeholder. Print this line first in the reply, with any other `ALARM` line:
```
ALARM sweep :
```
For a secret found only in history, write `@` in place of `:`. `` is the short hash of the commit. `` names the kind of credential. The line holds no value.
4. Write nothing to the tracker for an alarm. File no lead for it. Never use the value. Never test it. Never put it in a command, a note or the report.
## Lead format
Title: `[Lead] : : `
- The title has no single quote.
Body, in this order:
```
Analysed commit:
Department:
## What
## Evidence
>
## Why it is
## Cost and risk
Effort S|M|L, Risk low|medium|high, Confidence confirmed|demonstrated|plausible
## Not checked
```
- Put any extra section the page's Lead body names before `## Not checked`.
- On the Cost and risk line, pick one value from each list by the page's Anchors. File only `confirmed` or `demonstrated`.
- Put every `@` inside a code span or a fenced block. An `@` elsewhere fails the body check.
- Write no image, no home path, no installation path and no token.
- Keep the body under 64 KB. Quote only the lines the claim needs.
- Not checked names what investigation must verify.
- A kind with an external source puts one `Source:` line per source in Not checked, inside one fenced block, in one of these shapes:
```
Source: advisories @
Source: releases /
```
Take each value from the tree.
Marker:
- `at` is the UTC time of filing, from `date -u +%Y-%m-%dT%H:%M:%SZ`.
- For a fixed candidate, add ` of=` before ` -->`. Use the closed issue number.
- The marker is the last line of the body. Nothing follows it.
Identity: `` is `::::`. Encode each part as the section "The `id` value" of `lawman/skills/lawman-law/references/markers.md` describes.
`bin/journal seen` exit 1 means the id is not canonical. Fix the encoding and run it again.
## Report
Write the five parts that the law names under "The report", in that order. Keep each part short. When nothing was filed, the Filed part is exactly one of these lines:
```
Filed nothing. CLEAN at .
Filed nothing. INCOMPLETE at , checks not run.
```
- A check is one measurement that the page's Kinds or Proof names. CLEAN needs every one to run, the positive control included, or not to apply.
- A check does not apply when its subject is absent from the tree. A census with a positive control shows that.
- A capped tick writes one line: `cap= open= at . No sweep.` When the page has an alarm check, add `Alarm check: ran.` or `Alarm check: not run, .`