[fp-cli] fp policies, fp fleet and fp guardrails — the dashboard's enforcement pages from a terminal - #727
Conversation
Brings the dashboard's three cloud-managed-policy pages to the CLI, so a person
or an agent can do from a terminal what previously needed a browser: write a
policy, put it on machines, and see what it blocked.
Three commands because they are three jobs, split the way the dashboard splits
them — `/policies` authors a version, `/enforcement` decides which machines run
it, `/guardrails` reports what happened. Folding them into one would merge
"what we intended" with "what occurred", which is the distinction the pages
exist to keep.
## The dangerous part, and what the CLI does about it
`PUT /enforcement/deployments/{id}` REPLACES a machine's whole policy set. No
merge, no server-side lock. The dashboard has no deploy form precisely because
of this — it edits the machine's own current set, since a form that asks you to
re-tick policies silently drops whatever you forget.
So `fleet deploy` is a read-modify-write: it reads what the machine runs, applies
`--add`/`--remove`, shows the FULL resulting set, and writes that. `--set` is the
only way to drop what you did not name, and is refused alongside `--add`.
Three further guards, each for a way this loses work silently:
* A bare `--add` of a policy the machine already runs keeps its PINNED version
rather than moving to the newest. A pin is deliberate; upgrading a fleet on
a command whose author was reordering is not.
* The diff shows unchanged rows. The write replaces everything, so the set on
screen is the set that will exist — hiding untouched rows hides exactly the
ones a mistake drops.
* The generation read before the write must come back as `base + 1`. Anything
else means somebody deployed in between, and a replace does not merge, so
their change is already gone. The CLI refuses instead of reporting success.
(`lib/enforcementFleet.ts`'s `staleness()` does the same check, after the
fact; doing it before is the difference between a warning and a save.)
## Session-only, deliberately
Every route here is ROOT-ONLY on the server — absent from `/v1` because `/v1` is
internet-facing and these are operator writes. The commands refuse `--api-key`
up front via `deny_in_key_mode` rather than translating a path that would 404,
and `enforcement` is classified in `_V1_NO_EQUIVALENT` so the anti-drift test
that guards that table stays honest.
## Input and output
Policy source arrives as a path, `@path`, a pipe, `-`, or an interactive paste
when stdin is a terminal — five shapes because that is where people keep a file
they are about to publish, and refusing the clipboard means "save it first" for
the most common one-off.
Every command supports `--json`, in the SERVER's shape plus what the CLI
computed (the deploy plan, the drift flag). Model `to_dict()` rather than
`vars()`: the latter leaks Python snake_case into a contract that is camelCase
everywhere else, which a harness discovers at runtime rather than in review.
Tests: 42 covering the planner, the race check and source resolution — the pure
logic, because that is where a wrong answer destroys a fleet's policy set. 836
pass overall.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three findings from driving the commands against a running deployment rather than reading them. **A deploy to an unknown machine silently succeeded.** The server accepts a deploy to ANY id — that is how a machine can be pre-staged before it ever polls — so `fp fleet deploy no-such-box --add x` returned 0 and created `no-such-box`, carrying policies nothing will ever collect. The only trace is an extra row in `fleet list`. The dashboard cannot reach this state because it deploys to a machine picked from a list; a CLI takes free text, so the check belongs here. Unknown ids are now refused with exit 6, and `--create` allows the pre-staging case explicitly. **A bad `--since` exited 1, not 2.** `guardrails` raised a bare `ValueError` where every other bad flag value in the CLI is a usage error. Now `typer.BadParameter`, so it exits 2 like `--since` everywhere else. **Three key-mode refusals read "the versioned API an key authenticates against".** Grammar, but it is the message a CI job gets, so it is the sentence that has to survive being read once at 3am. Also adds the JSON-contract tests that would have caught an earlier slip in this branch: the models emitted `vars()`, which leaked Python snake_case into a contract that is camelCase everywhere else — the kind of difference a harness finds at runtime rather than in review. `to_dict()` now fixes the shape and the test asserts no key contains an underscore. Docs: the README gains a Cloud-managed policies section leading with the full-replace semantics, and the agent skill gains a `policies · fleet · guardrails` reference — the skill matters most here, because an agent reading only `--help` would meet `--set` without meeting what it drops. The enterprise CLI doc lives in FailproofAI/agenteye and is NOT updated here. 838 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both found by looking at real output rather than at the code. The deploy footer said "1 policies after this change". Pluralisation, but this line is the summary of a destructive full-replace, and a line that reads as unfinished is a line an operator skims. The guardrails per-policy table inherited the shared panel's default title, which appends "newest first". That table is ranked by policy, not ordered by time, so the panel was making an ordering claim the data does not support — the same class of wrong-but-plausible text this branch has been finding elsewhere. It now carries its own `by policy · N` title. 838 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks @SiddarthAA for your contribution to Failproof AI! 🙌 We'd love to discuss your PR and welcome you to our community: https://discord.befailproof.ai/ |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Hermes
No summary yet. What this changesNo component map for this revision. RoundsNo review has finished on this pull request yet. FindingsNothing raised yet.
|
Hermes
Changes requested: first deployments can overwrite another operator’s complete policy set while reporting success. The advertised 15-minute guardrail window also requests an hour of data. Containerized tests pass. What this changesflowchart LR
n0PolicyauthoringCLI["+ Policy authoring CLI"]
n1Localpolicyverifier["+ Local policy verifier"]
n2FleetdeploymentCLI["+ Fleet deployment CLI"]
n3GuardrailreportingCLI["+ Guardrail reporting CLI"]
n4EnforcementAPIclient["~ Enforcement API client"]
n5Enforcementdatamodels["~ Enforcement data models"]
n6CLIpresentation["~ CLI presentation"]
n7Operatordocumentation["~ Operator documentation"]
n0PolicyauthoringCLI -- "policy source" --> n1Localpolicyverifier
n0PolicyauthoringCLI -- "policy versions and drafts" --> n4EnforcementAPIclient
n2FleetdeploymentCLI -- "full-set deployments" --> n4EnforcementAPIclient
n3GuardrailreportingCLI -- "report windows" --> n4EnforcementAPIclient
n4EnforcementAPIclient -- "API payloads" --> n5Enforcementdatamodels
n5Enforcementdatamodels -- "rendered state" --> n6CLIpresentation
n2FleetdeploymentCLI -- "replace semantics" --> n7Operatordocumentation
Rounds
FindingsOpen
|
hermes-exosphere
left a comment
There was a problem hiding this comment.
Hermes found blocking issues that should be addressed.
High: First-deployment races are accepted as successes
- Rule:
DATA-001 - Location:
fp-cli/fp_cli/enforcement.py:222 - Evidence:
fleet_deployrecordsbase=Nonewhen a checked-in machine has no deployment, then callscheck_raceafter its full-replacement PUT.check_racereturns immediately for everybase is Noneat fp-cli/fp_cli/enforcement.py:222. Therefore two operators can both read no deployment; after one creates generation 1, the other's stale PUT creates generation 2 and replaces the first policy set, yet the second command reports success. The accompanying test only accepts(None, 1)and does not reject(None, 2). - Required change: Treat a first deployment as clean only when the returned generation is 1, and add a regression test that
check_race(None, 2)raises. To prevent rather than merely detect overwrites, make the API enforce an expected-generation/CAS precondition on the PUT.
| here is how the CLI would become the easiest way to silently overwrite a | ||
| colleague. | ||
| """ | ||
| if base is None: |
There was a problem hiding this comment.
Hermes — High/High (DATA-001): First-deployment races are accepted as successes
fleet_deploy records base=None when a checked-in machine has no deployment, then calls check_race after its full-replacement PUT. check_race returns immediately for every base is None at fp-cli/fp_cli/enforcement.py:222. Therefore two operators can both read no deployment; after one creates generation 1, the other's stale PUT creates generation 2 and replaces the first policy set, yet the second command reports success. The accompanying test only accepts (None, 1) and does not reject (None, 2).
Required change: Treat a first deployment as clean only when the returned generation is 1, and add a regression test that check_race(None, 2) raises. To prevent rather than merely detect overwrites, make the API enforce an expected-generation/CAS precondition on the PUT.
…access
Found by driving the commands as three different users rather than one.
`fleet deploy` short-circuits a no-op before the write — desired-state
semantics, so a retrying harness re-running the same deploy succeeds instead of
erroring. That is deliberate and worth keeping. But it has two consequences that
were nowhere in the docs:
* `applied` in the JSON is the ONLY way to tell "I changed it" from "it
already matched". The exit code is 0 for both, on purpose.
* Because the short-circuit precedes the write, a user with `policies:read`
and no `policies:write` also gets 0. Nothing was written and they gained
nothing, but a harness treating exit 0 as "I have write access" would be
wrong — every deploy that actually changes something correctly exits 5 for
that user.
Verified across three permission levels: admin, `policies:read` only, and a user
with no policies permissions at all. Reads and writes gate exactly as expected
in the other seven cases; this was the one place the exit code alone does not
tell the whole story, so it is now stated in both the code and the agent skill.
838 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…y file as "database error" Two more from driving the commands with hostile input rather than reasonable input. **`fleet show <typo>` exited 0 with an empty set.** Indistinguishable from a real machine that simply has nothing deployed — which is a state that genuinely exists, so the empty result looked like an answer rather than a miss. `history` and `rollback` had the same hole. All three now go through one `_require_machine` check and exit 6, matching `policies show` and the check `deploy` already had. That check also covers an id containing `/`, which is interpolated into a URL path further down and would otherwise address a different route entirely. **A binary file published as "database error".** A NUL byte in policy source reaches Postgres and returns a bare internal failure to somebody who has almost certainly pointed the command at the wrong file. The server ought to refuse it; that repository is out of scope here, so the CLI refuses first with a sentence that names the likely cause. The guard covers all five input shapes — a check on one of five paths is not a check — and ordinary unicode is explicitly not caught by it, since emoji and CJK are legitimate policy content. Both were found in a hostile-input pass alongside path traversal, 1.2 MiB sources, 200-character ids, control characters and empty files; everything else was already refused correctly by the server's own validation. Concurrency held up under real load: six simultaneous deploys to one machine produced exactly one clean write and five detected races, the generation counter advanced by exactly six with no skips, and the final policy set was intact. 841 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three rounds of end-to-end testing — 4 more bugs found and fixedDriven against a live deployment as three different users, plus hostile input and real concurrency. Round 1 — permissions and multi-tenancySigned in as three real users via OTP (read from mailpit), not simulated:
Org scoping is clean: Round 2 — the agent/harness pathAll 9 read commands under Idempotency is exact — the same deploy three times: Round 3 — hostile input and concurrencyPath traversal, ids with slashes, 500-char ids, unicode/emoji, control bytes, 1.2 MiB sources, empty files, negative and huge rollback generations. Everything refused correctly except the two bugs below. Six concurrent deploys to one machine: The 4 bugs this round found
One behaviour documented rather than changedA no-op 841 tests pass (47 unit tests on the pure logic). Still not done
|
hermes-exosphere
left a comment
There was a problem hiding this comment.
Hermes found blocking issues that should be addressed.
High: First-deployment races are accepted as successes
- Rule:
DATA-001 - Location:
fp-cli/fp_cli/enforcement.py:222 - Evidence: When a checked-in machine has no deployment,
fleet_deployrecordsbase=None(fleet_cmds.py:170-176). Two operators can both read that state; the first PUT creates generation 1 and the second stale full-replacement PUT creates generation 2.check_racereturns immediately for everybase is Noneat enforcement.py:222-223, so the second command reports success after overwriting the first set. The tests only accept(None, 1)and do not reject(None, 2). - Required change: Require a first deployment to return generation 1 and add a regression test that
check_race(None, 2)raises. To prevent the overwrite rather than detect it after the fact, add an expected-generation/CAS precondition to the API PUT.
1 advisory finding
- Medium/High
--since 15mqueries a full hour — The command advertises15m, but_hoursmaps it to1at guardrails_cmds.py:31. Summary and timeline then pass that value as the API'shoursparameter (lines 66-68; client.py:1507-1524), so a request for 15 minutes includes up to an hour of coverage and decision data. (fp-cli/fp_cli/commands/guardrails_cmds.py:31)
They are one workflow — write a policy, put it on machines, see what it blocked — and the help split them across two groups, with `guardrails` under OBSERVE and the other two at the bottom of a nine-row MANAGE. Somebody scanning for "how do I control what my agents can do" had to find three entries in two places and infer they were related. Named ENFORCE rather than POLICIES: the existing headings are verbs for what you are doing (OBSERVE, MANAGE), and POLICIES would also collide with the command sitting inside it. Placed before MANAGE so the reading order runs observe → enforce → manage, and ordered within the group the way the work flows rather than alphabetically. Presentation only. No command, flag or output changed. 841 pass, including the guard that every registered command appears in this table exactly once. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…e CLI
They were the only two-step flows in the CLI printing plain text where every
other destructive action uses the shared boxed shape:
disable no-force-push — machines stop enforcing it? [y/N]: y
disabled no-force-push
Both halves now go through the helpers that already existed.
`_write.confirm_destructive` renders the amber ⚠ box with the action, the target
in accent, and the consequence underneath — the same prompt `keys disable` and
`users disable` use — and declining prints the shared `nothing changed` notice
instead of falling through silently. Six new result cards replace the bare
`success()` lines, each naming what the change means rather than restating the
command: a disabled policy says machines stop enforcing it, a rollback says the
restored generation AND the new one it was minted as, a rename says the machine
id is unchanged.
A no-op deploy gets its own calm ACCENT `no change` card rather than the green
tick. Reporting "success" for a write that did not happen is how the exit-code
ambiguity documented last commit turns into a visual one too.
The result text is deliberately terse. The first version repeated the caveat and
the reversal command from the confirm box, which pushed the card onto a second
line at 100 columns — the confirm already carried both, and the result only has
to say what changed. Checked at 80, 100 and 120 columns.
Presentation only; no flag, exit code or `--json` shape changed, and `--json`
still emits pure JSON with an empty stderr on every path including the new
cancelled branches.
841 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hermes-exosphere
left a comment
There was a problem hiding this comment.
Hermes found blocking issues that should be addressed.
High: First-deployment races are reported as successful
- Rule:
DATA-001 - Location:
fp-cli/fp_cli/enforcement.py:222 - Evidence: Two
fleet deployinvocations can both read no deployment, so each plan hasbase=None. The PUT atfleet_cmds.py:216replaces the entire policy set and the second write returns generation 2, butcheck_race()returns immediately for everybase is Noneatenforcement.py:222-223. The second command therefore emitsapplied: trueafter overwriting the first command's policy set. The client PUT atclient.py:1480-1486has no expected-generation precondition. - Required change: Add a server-enforced expected-generation/CAS precondition to deployment writes and have the client send it. Also make the client-side check accept a first deployment only when the returned generation is 1, with a regression test that
check_race(None, 2)raises.
1 advisory finding
- Medium/High
--since 15mretrieves a full hour of guardrail data — The documented15moption maps to1in_hours()atguardrails_cmds.py:31; summary, timeline, and policy commands pass that value as the APIhoursparameter (for exampleguardrails_cmds.py:66-68). Consequently a request for the last 15 minutes includes up to an hour of coverage and decisions. (fp-cli/fp_cli/commands/guardrails_cmds.py:31)
…hard
It printed two unlabelled rows of blocks:
denies ▁▄▁▄▁█▁▁▄▁▁█▄▄▁█▁▁▁▄▄▄▁▁▁
total ▁▆▁▄▄▆▄▆▇▅▃▅▃▂▆▄▁▁▄▁▃█▃▁▁
No axis, no scale, no counts, no times. It showed a shape and nothing anyone
could act on — which is the whole question the command exists for.
Now one row per bucket: the time, a bar scaled to the busiest bucket in the
window, and the total / denied / instructed counts. The blocked share is drawn
in red INSIDE the total bar rather than as a second row, so "busy hour" and
"heavily-blocked hour" are distinguishable without arithmetic. Empty buckets
show an em dash rather than a zero, because "nothing happened" and "zero of
something that happened" read differently in a column of numbers.
The bucket label follows the size the server chose — a clock for hourly buckets,
a date for daily ones. Printing 09:00 against a 24-hour bucket is a chart lying
about its own resolution.
The summary keeps its sparkline: beside a headline number it is a fine accent,
and that is the job it was doing there. It was only ever wrong as the entire
output of a command.
`--json` is unchanged (the server's timeline verbatim) and still emits pure JSON
with empty stderr. An empty window still prints the one-line notice rather than
an empty box.
841 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hermes-exosphere
left a comment
There was a problem hiding this comment.
Hermes found blocking issues that should be addressed.
Review coverage was incomplete, but the concrete blocking findings below are sufficient to request changes.
High: First-deployment races are reported as successful
- Rule:
DATA-001 - Location:
fp-cli/fp_cli/enforcement.py:222 - Evidence:
fleet_deployusesbase=Nonewhen no deployment was read (fleet_cmds.py:170-176), then performs a full-replacement PUT (line 216).check_racereturns immediately for everybase is None(enforcement.py:222-223). Two operators can both read no deployment; the first write creates generation 1 and the second stale write creates generation 2, overwrites the first policy set, and emitsapplied: true. The client PUT sends no expected-generation precondition (client.py:1480-1486). - Required change: Make the API enforce an expected-generation/CAS precondition and send it from the client. Independently, accept a first deployment only when it returns generation 1 and add a regression test that
check_race(None, 2)raises.
1 advisory finding
- Medium/High
--since 15mretrieves a full hour of guardrail data — All three guardrail commands advertise15m, but_hours()maps it to1at guardrails_cmds.py:31. Summary and timeline pass that value as the APIhoursparameter (lines 66-68 and 99), so a requested 15-minute report includes an hour. (fp-cli/fp_cli/commands/guardrails_cmds.py:31)
Round 4 of 5. If the next review still finds something blocking, I will summarize what is left, withdraw this change request, and stop reviewing this pull request until someone asks me to start again.
Still open:
- F1 First-deployment races are reported as successful (
fp-cli/fp_cli/enforcement.py) — open since round 1 - F2
--since 15mretrieves a full hour of guardrail data (fp-cli/fp_cli/commands/guardrails_cmds.py) — noticed at round 2, on code that had not changed since the round before, so it never blocked
If one of these is not worth fixing, @hermes-exosphere dismiss <id> [reason] waives it for the rest of this pull request and gives the review another round.
…m a description
Closes the gap this branch opened: three commands could publish and deploy a
policy, and nothing anywhere checked it was JavaScript. This published, deployed
and reached every machine in the fleet —
echo 'this is not javascript {{{' | fp policies publish broken
— and failed at enforcement time, on the machine, where nobody is watching. The
CLI rejected a NUL byte; the server checks the id charset and a 1 MiB ceiling.
Neither parses.
**`publish` now parse-checks with `node --check` first.** Broken source is
refused with node's own line, caret and SyntaxError — node's internal frames and
version banner are stripped, since those are node talking about itself inside an
error about the user's policy. `--no-verify` skips the check, and a host without
node publishes with a warning rather than a block: node is a real dependency of
the check and deliberately not of the CLI.
**`policies test` runs a policy locally.** It executes the real file — bare
`import { deny } from "failproofai"` and all — against a context you describe,
and prints allow/deny/instruct per registered policy. The shim goes in
`node_modules/failproofai/` rather than beside the file so the bare specifier
resolves by node's ordinary lookup; an import map would have meant testing a
rewritten file and varies by node version anyway.
`--expect` is how CI asserts. A policy that correctly denies is a PASSING test,
so the decision never sets the exit code on its own — otherwise the command
would fail precisely when the policy worked.
**`policies compose` drafts one from plain English.** It prints the source and
stops: a generated policy that deploys itself is a generated policy nobody read.
`--out` saves it, `--publish` ships it, still syntax-checked first.
Two things found only by running it against the live assistant. The endpoint
takes `intent`, not `prompt` — it 400s before the model is called. And it
answers `text/event-stream`, not JSON: `delta` frames then one `done` carrying
the source, so reading it as JSON fails on the first frame. It now consumes the
stream through the client's existing SSE helper.
The composer also aborts itself at 30s (`agent/src/server.ts`), server-side, so
a long intent simply does not finish and raising `--timeout` cannot help. The
error says that rather than "the assistant closed the stream", because the
obvious remedy is the wrong one.
20 new tests, each skipping without node rather than failing: every broken-source
shape, ESM imports and top-level await accepted, the caret preserved and node's
stack dropped, a missing node reported as UNCHECKED rather than passing, the
strictest-decision rule, a policy that throws reported per-policy, and an
infinite loop timing out instead of hanging the command.
861 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
I have spent 5 rounds of review on this pull request and I am still finding things to block on. At that point I am no longer the useful reviewer here, so I am standing down and leaving the decision to a person. I have withdrawn my change request, so I am no longer blocking this pull request. I have also stopped reviewing new commits on it. What I last reviewed: Still open:
None of this is a judgement that the findings above are wrong. It is a judgement that another round of me is not what will settle them. |
Hermes spent 5 rounds on this pull request without converging and has stood down. This change request is stale and should not block the merge.
…what disable does Two findings from exercising all 18 subcommands against a live server. **A disabled policy drew a full deploy plan, asked for confirmation, and then failed.** The server refuses it — correctly — but only after the CLI had shown the operator a change and a prompt implying it could happen. Every other precondition the plan depends on is checked before it is built (the machine exists, the policy exists, the ref parses); this was the one gap. `--add` and `--set` now refuse up front, naming `policies enable <id>` as the fix. **`policies disable` does considerably more than stop enforcement.** It REMOVES the policy from every deployment carrying it, reissuing each affected machine at a new generation. Verified against the live server: generation 16 held the policy, disabling minted 17 without it, and `fleet history` shows the reissue as an ordinary entry. And `enable` does NOT put it back — the machines that lost it need `fleet deploy --add` again. The help, the confirm prompt and the result card all said "machines stop enforcing it", which is true and badly incomplete: an operator disabling a policy to pause it would find their deployments rewritten and, on re-enabling, a fleet still missing it. All three now say what actually happens. That also corrects two tests. One claimed disable-then-remove was "the ordinary way to retire something" — it is not, because the removal has already happened; it is now documented as defensive cover for a state the server normally prevents. The other was renamed to describe what it actually pins: that only the refs you name are re-resolved. Round 1 ran every subcommand and every option: 35 checks, and the three that failed were all correct server behaviour caught by bad ordering in the script rather than bugs in the CLI. 867 pass (6 new). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every pre-existing command in this CLI states three things in its help: the
permission it needs, the `--json` shape it returns, and an example. Nine of the
eighteen new subcommands stated only the first — `policies enable/disable/delete`,
`fleet show/diff/history/rename/rollback` and `guardrails policies`.
That gap lands hardest on the reader this feature was built for. An agent
driving the CLI reads `--help`, not the source; without the shape it either
guesses the keys or calls the command once to find out.
Then I checked the shapes I had just written against real responses, and two
were wrong:
* the lifecycle commands return `machinesUpdated` as well, which is the count
of deployments the server rewrote — the number that makes `policies disable`
removing a policy from every machine visible instead of surprising, and the
one to check if you expected a no-op;
* `fleet rename` returns `labelOverride`, not `label`. The server keeps the
operator's label beside the machine's self-asserted one rather than
replacing it, and the field name is the only place that shows.
Round 2 also confirmed the new commands match the CLI's existing conventions
rather than inventing their own: 0/18 leak non-JSON or stderr under `--json`,
every destructive subcommand carries `--yes` like `keys disable` and `query
delete` do, and exit codes line up exactly with the pre-existing commands —
6 not-found, 2 usage, 2 key-mode, 3 unreachable.
867 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ed the opposite
The previous commit stated, in four places, that `policies enable` puts a policy
back but does not redeploy it, and that machines which lost it need
`fleet deploy --add` again. That is wrong. Disable and enable are exactly
symmetric:
deploy -> gen 21 [en-test, no-secret-echo, prod-deploy-guard]
disable -> gen 22 [no-secret-echo, prod-deploy-guard] machinesUpdated=1
enable -> gen 23 [en-test, no-secret-echo, prod-deploy-guard] machinesUpdated=1
The server puts the policy back into every deployment it removed it from,
advancing each machine's generation again, and reports the same count in both
directions. `machinesUpdated` for an enable is 1, not the 0 I wrote.
The wrong version was the more damaging way round: an operator following it
would re-run `fleet deploy --add` on every affected machine after a re-enable,
minting a redundant generation per machine and re-pulling a fleet for nothing.
Caught by a lifecycle test that asserts the machine's state after every step
rather than trusting the command's own report — the docstring, the confirm text,
the result card and the skill all agreed with each other and all disagreed with
the server.
Round 3 otherwise found no regressions: all 22 pre-existing commands still
return valid JSON and exit 0, every global option (`--quiet`, `--no-color`,
`--timeout`, `--org`, `--base-url`, `--insecure`, `--token`) works on the new
commands, and `--help` renders for all 18 subcommands.
867 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… like every other group `guardrails policies` returned nothing `summary` did not already give you. Validated rather than assumed: its `--json` payload is byte-identical to `summary.summary.policies`, and its human render is the summary view minus one sparkline line. A third subcommand for a strict subset is a third thing to learn, document and keep in step. Bare `fp guardrails` also ran the summary from a callback, which made it the only group in the CLI that DID something instead of printing its help — `keys`, `query`, `users`, `settings`, `alerts`, `audits`, `issues`, `orgs`, `policies` and `fleet` all print usage and exit 2. It now does the same, so all twelve groups behave identically. That removes the group-level `--since`/`--machine` with it. They existed only to feed the callback, and having them in two places taught a shape the rest of the CLI does not have; they stay on `summary` and `timeline`, where the work is. The split that remains is the one worth keeping: `summary` answers "how are we doing" (headline stats, a deny sparkline, the per-policy table) and `timeline` answers "when did it bite" (per-bucket rows with counts). Neither is a subset of the other. Also fixes a stale hint the audit turned up: the help table still advertised `policies` as "list show publish enable disable delete", missing `test` and `compose` from two commits ago. Every group's hint is now checked against the real command tree — the only two that disagree are `audits` and `issues`, both deliberately abbreviated with a comment saying why. 867 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… lines
**`fleet rename` reported success and `fleet list` kept showing `-`.** The
server keeps two names for a machine: `label`, which the machine asserts about
itself, and `labelOverride`, which an operator sets — separate columns, and
`rename` writes the second. The model read only the first, which is null on
every machine that never reported one, so the rename was invisible everywhere
except its own success message. Precedence is now `labelOverride || label`,
mirroring `machinePicker.ts` in the dashboard, and both fields survive into
`--json` so a harness can tell which it is looking at.
**`fleet history` and `fleet diff` printed one raw line per row** while every
other list in this CLI is a panel. Both are now panels, and both gained the
column that makes them worth reading:
* history shows a `change` column — what moved between each generation and
the one below it. A reissue (the server rewriting a deployment because a
policy was disabled or re-enabled) then reads as an ordinary +/- rather than
an unexplained new row, which is exactly the thing you open history to see.
* diff leads with `N of M behind` and colours only the drifted rows, because
those are the only reason to run it.
History also uses the CLI's shared time column rather than a date. Generations
land seconds apart — twenty-one rows of `08-19` distinguished nothing, and the
shared helper already folds the date back in when rows span more than a day.
867 pass, plus 4 covering the label precedence.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ployment
It printed the id, the generation and the policy list — about a third of what
the two endpoints return, and quietly implied the machine was running them.
It is not. `laptop-sidd` is told to run `prod-deploy-guard` at generation 21 and
has never collected it: `appliedDeployment` is null. That field is the answer to
the only question this view is opened for, and it was the one thing left out —
so the card was confidently wrong rather than merely sparse.
It now reads the machine record as well as the deployment, and reports:
╭─ laptop-sidd ────────────────────────────────╮
│ chutney │
│ deployment #21 · not yet collected │
│ deployed by admin@local.host · 43 min ago │
│ last seen 5 hr ago · 197 events │
│ policy ver effect │
│ prod-deploy-guard v1 enforce │
╰──────────────────────────────────────────────╯
Three states rather than a boolean: `not yet collected`, `machine is on #N`
(behind but alive), and `collected`. The operator label appears here too — the
machine is called `chutney`, which `show` previously never mentioned.
A machine with no deployment now gets the same card instead of a one-line
notice. "Checked in and given nothing" is a real state and usually the one being
looked for; the old line could not distinguish it from a dead host, where the
card shows 7 days ago and 23,314 events.
Times are relative in the card and raw in `--json`, which now returns
`{machine, deployment}` rather than the deployment alone — so a harness gets
`drifted`, `appliedDeployment`, `lastSeen` and both label fields without a
second call. Reused `_relative_age` rather than adding a second humaniser; the
machine side speaks epoch-ms, so `_epoch_age` converts and delegates.
Costs one extra request. `show` already called `/deployments`; drift is only
knowable from `/machines`, and there is no single-machine GET — that route is
DELETE-only.
871 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…iscards
Two things, found by asking what the endpoint returns versus what the table drew.
**It displayed 6 of the machine record's 11 fields**, and the most useful
omission was `lastSeen`. A host that last reported seven days ago rendered
identically to one that reported a minute ago — on a fleet view, "is this thing
alive" is usually the first question, and it is a DIFFERENT question from drift:
a machine can be perfectly in sync and dead. `eventCount` came with it as the
cheap corroborating signal.
machine label pol intended applied seen events state
5ca5d9e5… - 0 — — 7d 23,314 —
build-box-03 - 2 #28 — 5h 205 drifted
laptop-sidd chutney 1 #21 — 5h 197 drifted
Ages are compact here rather than the card's "7 days ago": a table cell is not a
sentence, and this column sits beside seven others. `lastCheckIn`, `appliedAt`
and `firstSeen` are still left out — `--json` carries them, and a ten-column
table buries the three people actually scan for.
**The human path fetched the deployments and threw them away.** `render_fleet`
took them as an argument and never read one; every value comes from the machine
record. That was my own leftover from rebuilding the renderer around the
corrected model. `--json` genuinely emits them, so the call now happens only
there — verified by instrumenting the client: a human `fleet list` makes exactly
one enforcement request where it used to make two.
Also fixes truncation I introduced: `last_col="ellipsis"` was clipping `state`,
the SHORTEST column, because the long one here is the machine id. Rich sizes
that fine unaided.
`--json` is unchanged: `{machines, deployments}`, raw timestamps, computed
`drifted`. 871 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…hardcoded argument
`render_policy_published` took a `deployed_to` count and the caller always
passed `1`, so every publish printed "vN is not deployed anywhere yet" whether
or not earlier versions were running across the fleet. For `demo-a` v3 the truth
was that `ci-runner-01` was carrying v1 the whole time.
It was also unreadable, which is the reported symptom: the card showed an id, a
version and a sha256 — three restatements of the command — and one sentence that
was wrong. Nothing said what had been published.
It now shows the description and the size, and computes the deployment state
instead of asserting it, from the deployments the CLI can already see:
published, not deployed — no machine runs this policy yet
fp fleet deploy <machine> --add demo-fresh
1 machine still runs an older version: ci-runner-01
fp fleet deploy <machine> --add demo-a@3
every machine carrying it is already on v3
`policies show` uses the same card, so it gained the same answer.
`--json` gains `carriers`: machine id -> the version of this policy it runs, so
a harness can tell what a publish left behind without a second call.
Costs one extra request on publish. Publishing is the moment an author decides
whether to roll a version out, and the card was previously guessing at the only
input to that decision.
871 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…back A review pass over the enforcement commands. Nothing here was a crash the tests would have caught — with one exception every finding is a command that did something defensible and then reported it wrongly, which is the failure mode this surface keeps producing. * `fleet diff <typo>` exited 0 and printed "no machines have checked in yet" over a healthy four-machine fleet. Every other machine-scoped command refuses an unknown id; this one filtered to nothing and called it a result. The machine list is already in hand, so the check costs no extra request. `guardrails --machine` had the same hole and now answers the same way. * `policies publish x logo.png` printed a Python traceback. `read_source` caught OSError, but decoding happens inside read() and raises UnicodeDecodeError — a ValueError — so it escaped through Click with internal paths in it. The NUL-byte guard written for exactly this mistake could never fire: it inspects text, and a file that fails to decode never becomes text. Covers path, @path and pipe. * `fleet history` called an enforce → observe flip "no change". The row identity was `id@version`, so a generation that changed only the effect diffed to nothing — and a version bump split into `+x` and `-x`, reading as removed-and-re-added rather than moved. Now keyed by id, comparing (version, effect), using the deploy plan's own `~` for changed. * `policies list` said "policies · 4" for three policies. The endpoint returns one row per immutable version and the docstring claimed "newest version of each". The dashboard's library counts distinct policies and captions the version total; this now matches it, sorts newest-first per policy, and says so. `policies show` picks the newest version explicitly rather than inheriting the server's ordering. * `fleet rename m ""` reported `labelled m as ` — a sentence with a hole in it. The server clears the override; the card now says that. * `policies compose --out` wrote the file after the publish that can fail, so a refused publish threw away the draft the user had just paid an assistant to write. Saved first, and the write is guarded. Exit codes: a malformed ref, `--set` with `--add`, a missing or non-text source file, and a bare `deploy` were exit 1 ("the server returned an error") for mistakes the server never saw. They are exit 2 now, which is what the documented table promises and what `--since` and `--expect` in these same commands already did. A ref that parses but names something absent stays exit 1, and an unknown machine stays 6 — a script has to be able to tell a typo from a rejected write. RefUsageError subclasses RefError so every existing call site and test keeps working. `--expect` is validated before the syntax check, so a bad flag value reports itself instead of being masked by whatever node says about the file. 12 regression tests, one per finding. 883 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The section already says "before you script it" and then documents only the pinning rule and the race check. The third thing a script needs is which failures are its own: exit 2 for a malformed ref or a flag combination that cannot be acted on, 1 for a ref that parses but names nothing, 6 for an unknown machine. Also notes that `fleet diff` refuses an unknown machine rather than drawing an empty fleet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fp policies·fp fleet·fp guardrailsBrings the dashboard's three enforcement pages —
/policies,/enforcement,/guardrails— to the CLI, so anything an operator can do by clicking, anoperator (or an agent) can do from a terminal or a CI job.
19 commits · 14 files · +3,530 · 883 tests pass.
What's here
17 subcommands under three groups, listed in
fp helpunder a new ENFORCEheading between OBSERVE and MANAGE.
fp policieslistshowpublishtestcomposeenabledisabledeletefp fleetlistshowdeploydiffhistoryrollbackrenamefp guardrailssummarytimelineEvery command takes the global
--json, and every source input accepts a path,@path, a pipe,-, or an interactive paste.The three jobs, kept separate
Publishing a policy, deploying it, and seeing what it did are three jobs done by
different people at different times — which is why the dashboard splits them
across three pages and why this is three groups rather than one.
policiesmints immutable versions. Publishing deploys nothing, andevery success path says so, because that is the single most surprising thing
in the model.
fleetputs a version on a machine.guardrailssays what actuallyhappened once it got there — coverage comes from Postgres, decision counts
from ClickHouse, and a machine can be deployed-to and silent, or reporting and
undeployed.
Two places this can destroy work, so both are pure and tested hard
PUT /enforcement/deployments/{id}is a full replace with no server-sidelock. Send
{"policies": [a]}to a machine running[a, b, c]and it nowruns
[a]— permanently, with a 200 and no warning. The dashboard never exposesthat as a form for exactly this reason.
--add/--removeread-modify-write. The CLI reads the current set,applies the delta, shows the full resulting set, and writes that. Nothing
you did not mention is disturbed.
--setis the escape hatch for thedeclarative case and the only way to drop what you do not name.
generation it read and refuses if the write does not land at exactly one
higher — mirroring
staleness()inlib/enforcementFleet.ts. It refuses andre-reads rather than reporting a success that erased somebody.
enforcement.pyholds both with no HTTP in it, so they are testable without aserver.
Policies get checked before they reach a fleet
Nothing between an author and a machine validated policy source. This publishes,
deploys, and reaches every machine:
It then fails at enforcement time, on the machine, where nobody is watching.
policies publishparse-checks withnode --checkfirst.--no-verifyskips it; a host without node publishes with a stated reason rather than a
silent skip.
policies testexecutes the real file — bareimport { deny } from "failproofai"and all — against a context you describe, and printsallow/deny/instruct per registered policy. Nothing is published, nothing
installed.
--expectturns it into a CI assertion; a correctdenyis apassing test, so the decision alone never sets the exit code.
policies composedrafts from a description via the Cloud assistant. Bydefault it prints and stops — a generated policy that deploys itself is a
generated policy nobody read.
Review round
A full pass over the surface: every command with no-args,
--help, each option,option combinations, invalid inputs, both auth modes, and state assertions after
each mutation against a live stack.
Ten findings. One was a crash; the other nine were commands stating something
false while every test passed — which is the failure mode this surface keeps
producing, and the reason the review asserted real state after each step rather
than trusting internal consistency.
fleet diff <typo>guardrails --machine <typo>@pathand stdin, in bothpublishandtest.read_sourcecaughtOSError, but decoding happens insideread()and raisesUnicodeDecodeError. The NUL-byte guard written for this exact mistake could never fire — it inspects text, and a file that fails to decode never becomes text → clean exit 2, namedfleet historyid@version, so effect-only diffs vanished and version bumps split into+xand-x→ keyed by id, compares(version, effect), uses the deploy plan's own~policies listpolicies · 3 · 4 versions, newest-first per policy, matching the dashboard's own librarypolicies showmax(version)fleet rename m ""✓ labelled m as— a sentence with a hole in it, for what is actually a clear → "cleared the label on m"policies compose --out--setwith--add, a missing file and a baredeploywere exit 1 ("the server returned an error") for mistakes the server never saw → 2, matching the documented table and what--since/--expectin these same commands already did--expect bogusRefUsageErrorsubclassesRefError, so every existing call site and all 15pytest.raises(RefError)assertions keep working. A ref that parses but namesnothing stays exit 1; an unknown machine stays 6 — a script has to be able to
tell a typo from a rejected write.
Flagged, deliberately not changed
policies test --eventignores the policy's ownmatch.events. APreToolUse-only policy still returns DENY under--event PostToolUse, wherethe daemon would never invoke it. Caveated in the docstring, and "run every
registered policy" may be intended.
--since 15mis one hour. The server takes whole hours. The render ishonest — it prints
guardrails · 1h— but the flag advertises a window itcannot deliver.
fleet listneeds ~118 columns. At 80 it degrades tolab… inte… ap….This is the shared house renderer, not new code, but a 36-char UUID currently
wins over
state.Testing
refuse API-key mode with exit 2 (these endpoints are deliberately absent
from
/v1), andpolicies testcorrectly still works there, being local-only.--add Athen--add B≡--add Bthen--add A; aplan naming one bad policy leaves no partial write; declining on a real
pty writes nothing; a repeated identical deploy is a no-op that exits 0
without writing, so a retrying harness succeeds rather than errors.
fp-cli/README.mdandfp-cli/skill/references/commands.md.Note on CI
ci.ymltriggers onpull_request: branches: [main], which filters on thebase branch. This PR targets
feat/fp-cli, so itsfp-clijob — pytest onPython 3.10 and 3.13 with
FP_CLI_REQUIRE_CONTRACT=1, a wheel build, a wheelpayload assertion and a console-script smoke test — has never fired here. It
runs the moment these commits land on
feat/fp-cli, because that re-triggers CIon #702, which does target
main. Nothing reachesmainungated; the gate justsits one level up the stack.
Not done here
The 18 customer-visible commands are still undocumented in
enterprise-docs/cli.mdand the public
docs/agenteye/cli.mdx, both of which live in the agenteyerepo. That is a separate change in a separate repo, awaiting sign-off.