Skip to content

Commit 549ac23

Browse files
authored
Merge pull request #649 from escoffier-labs/feat/595-runs-audit
feat(runs): offline coordinator decision audit (#595)
2 parents 0c781e1 + d7c2613 commit 549ac23

5 files changed

Lines changed: 1606 additions & 1 deletion

File tree

docs/command-inventory.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enabled: run `brigade extras on` once, or set `BRIGADE_EXTRAS=1`.
5656
- `brigade route`: 1 command path(s)
5757
- `brigade run`: 1 command path(s)
5858
- `brigade runbook` (extras): 5 command path(s)
59-
- `brigade runs`: 10 command path(s)
59+
- `brigade runs`: 11 command path(s)
6060
- `brigade scrub`: 1 command path(s)
6161
- `brigade search`: 6 command path(s)
6262
- `brigade security`: 15 command path(s)
@@ -439,6 +439,7 @@ enabled: run `brigade extras on` once, or set `BRIGADE_EXTRAS=1`.
439439
- `brigade runbook plan` (extras)
440440
- `brigade runbook resume` (extras)
441441
- `brigade runbook run` (extras)
442+
- `brigade runs audit`
442443
- `brigade runs events`
443444
- `brigade runs interrupt`
444445
- `brigade runs latest`

src/brigade/cli/runs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,28 @@ def register(sub: argparse._SubParsersAction) -> None:
199199
"resume", help="Re-attach interrupted app-server workers from a run and re-synthesize."
200200
)
201201
p_runs_resume.add_argument("run_dir", type=Path, help="Path to a Brigade run artifact directory.")
202+
p_runs_audit = runs_sub.add_parser(
203+
"audit",
204+
help=(
205+
"Offline coordinator decision audit from recorded lifecycle evidence. "
206+
"Exit 0 on match, 1 on divergence or corrupt journal evidence, "
207+
"2 when the run is not auditable or the run id cannot be resolved."
208+
),
209+
)
210+
p_runs_audit.add_argument("run", help="Run directory path, run id under --runs-dir, or 'latest'.")
211+
p_runs_audit.add_argument(
212+
"--cwd",
213+
type=Path,
214+
default=Path("."),
215+
help="Workspace whose default .brigade/runs directory should be used for run ids.",
216+
)
217+
p_runs_audit.add_argument(
218+
"--runs-dir",
219+
type=Path,
220+
default=None,
221+
help="Explicit runs directory for run ids. Defaults to .brigade/runs under --cwd.",
222+
)
223+
p_runs_audit.add_argument("--json", action="store_true", help="Emit the audit receipt as JSON.")
202224
p_runs.set_defaults(func=dispatch)
203225

204226

@@ -262,6 +284,13 @@ def dispatch(args) -> int:
262284
)
263285
if args.runs_command == "resume":
264286
return runs_cmd.resume(args.run_dir)
287+
if args.runs_command == "audit":
288+
return runs_cmd.audit(
289+
args.run,
290+
cwd=args.cwd,
291+
runs_dir=args.runs_dir,
292+
json_output=args.json,
293+
)
265294
args._brigade_parser.error(f"unknown runs command: {args.runs_command}")
266295
return 2
267296

0 commit comments

Comments
 (0)