conduct
conduct
¶
Conducting commands for Marianne CLI (GH #547): wait, next, verdict.
A conductor today polls mzt status hundreds of times and parses rich
tables. These three commands answer the three questions a conductor asks
with a closed enum and one small JSON object each, so a small model can
hold the loop:
mzt wait JOBblocks until the job needs a decision or is finished.mzt nextsays which job needs attention and what to do about it (--tasks DIRalso lists TASK files nobody has started).mzt verdict JOBreads the review sheet's VERDICT line as PASS/REWORK/BLOCKED and adds the findings, the validation counts, the report path and the round (GH #554).
All conductor access goes through :func:_route, so tests replace one
function and never touch a real conductor.
Classes¶
ConductorUnreachable
¶
JobNotFound
¶
Bases: Exception
The conductor answered and does not know the job.
Functions:¶
classify_job
¶
Map a job.status payload to (state, outcome, reason).
Returns None while the job is still moving and nobody has to decide.
Source code in src/marianne/cli/commands/conduct.py
wait_for_job
async
¶
Poll fetch with backoff until the job needs a decision or ends.
The conductor IPC has no per-job subscription, so the polling lives here
(not in the caller). clock and sleep are injectable so tests never
sleep. JobNotFound from fetch propagates.
Source code in src/marianne/cli/commands/conduct.py
wait
¶
wait(job_id=Argument(..., help="The score's run id (job id) to wait for"), max_seconds=Option(_WAIT_DEFAULT_MAX, '--max', '-m', min=0, help='Give up after this many seconds and report wait_expired (default 1800)'), json_output=Option(False, '--json', '-j', help='Output one JSON object (no ANSI)'))
Block until a score is finished or needs a human decision.
Returns one of four states: done, needs_you, conductor_down, wait_expired. Exit codes: 0 done, 2 needs_you, 3 conductor_down, 4 wait_expired (1 is an error such as an unknown score). Rate limits, retries and fallbacks happen inside the conductor and do not end the wait.
Examples:
mzt wait my-job --json mzt wait my-job --max 600 --json
Source code in src/marianne/cli/commands/conduct.py
find_verdict
¶
Newest artifact in workspace carrying a mappable VERDICT line.
Within that file the last such line wins. No prose interpretation beyond
the word mapping; round is None here (mzt verdict fills it from
the task file, see :func:task_round).
Source code in src/marianne/cli/commands/conduct.py
extract_findings
¶
The reviewer's findings, verbatim, from the report that carries the verdict.
Rule, first match wins:
- a section headed
FINDINGS(FINDINGS:or## Findings): its bullets; - else the sheets' own review labels
REQUIRED FIXESthenFAILURES; - else, when the verdict is not PASS, the bullet lines after the VERDICT line up to the next heading or label (non-blank lines when it has no bullets).
Bullet markers are stripped, the text is not edited. At most 20 items of 500 characters. A PASS with no FINDINGS section has none.
Source code in src/marianne/cli/commands/conduct.py
accept_counts
¶
{ran, passed} over the validations the job's sheets recorded.
Reads the checkpoint (job.status): each sheet's validation_details
(latest attempt), or its passed_validations/failed_validations name
lists when the details were not kept. {0, 0} means no validation result
is available, not that all passed.
Source code in src/marianne/cli/commands/conduct.py
parse_task_fields
¶
Field name -> value of the conducting card's TASK.md (first occurrence wins).
Same grammar as mzt agents run: a field is NAME: value (list, quote
and heading marks tolerated); following lines up to the next field line
continue the value.
Source code in src/marianne/cli/commands/conduct.py
find_task_file
¶
The task file mzt agents run copied for this job, or None.
agents run binds the engagement in a run dir (the bound score and the
read-only copy task-<source name>) and, by default, uses that same
directory as the workspace. Looked for beside the bound score first
(config_path; its marianne_agent.task.copy names the copy), then in
the workspace as task-* carrying the card's REPORT field.
Source code in src/marianne/cli/commands/conduct.py
task_extras
¶
(round, result_path) from the task file; (None, None) without one.
round is 2 when the task carries a FINDINGS: line (the rework
task), else 1. result_path is the REPORT field's file name resolved in
the workspace, the path mzt agents run printed.
Source code in src/marianne/cli/commands/conduct.py
build_verdict
¶
The full mzt verdict object: the four #547 keys plus the #554 extras.
Source code in src/marianne/cli/commands/conduct.py
is_judged
¶
Whether mzt verdict --accept was recorded for this run of the job.
Keyed on submitted_at so a fresh run under a reused job id is not
mistaken for the run that was judged.
Source code in src/marianne/cli/commands/conduct.py
verdict
¶
verdict(job_id=Argument(..., help="The score's run id (job id) to read the verdict of"), pattern=Option(DEFAULT_VERDICT_PATTERN, '--pattern', help="Regex for a verdict line; group 'word' (or group 1) is the verdict word. Default matches 'VERDICT: <word>' lines."), workspace=Option(None, '--workspace', '-w', help='Read this workspace directly instead of asking the conductor for it'), accept=Option(False, '--accept', '--judged', help='Record this job as judged so `mzt next` stops saying JUDGE (accepted, or sent back for rework). Written to .mzt-judged.json in the workspace.'), json_output=Option(False, '--json', '-j', help='Output one JSON object (no ANSI)'))
Read a score's review verdict as PASS, REWORK, BLOCKED or unknown.
Finds the newest review/inspect artifact in the score's workspace that has
a 'VERDICT:' line and maps its word: PASS/APPROVE/ACCEPT -> PASS,
REWORK/REJECT -> REWORK, HOLD/BLOCK -> BLOCKED. Anything else, or no
such line, is unknown. The JSON also carries findings (the report's
FINDINGS bullets, else REQUIRED FIXES/FAILURES, else the bullets after a
non-PASS VERDICT line), accept ({ran, passed} over the sheets'
validation results), result_path (the task's REPORT file in the
workspace) and round (2 when the task file has a FINDINGS: line, else
1; null when the job has no mzt agents run task file).
Examples:
mzt verdict my-job --json mzt verdict my-job --accept --json
Source code in src/marianne/cli/commands/conduct.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
task_hash8
¶
The 8 hex digits mzt agents run puts in the job id for this task file.
unbound_tasks
¶
CAST entries for TASK*.md files in tasks_dir that no job is bound to.
Bound means some job id (any age, any status) contains -task-<hex8>- with
the file's hash, so editing a task (a rework adds FINDINGS:) makes it new
again. Only the hash is compared, not the agent name or the date. Unreadable
files are skipped. Sorted by file name.
Source code in src/marianne/cli/commands/conduct.py
compute_next
async
¶
The ordered attention queue: [{job_id, action, why}].
With tasks_dir, unbound TASK*.md files there add CAST rows that
also carry task (the file's absolute path).
Source code in src/marianne/cli/commands/conduct.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | |
next_actions
¶
next_actions(mine=Option(None, '--mine', help='Only jobs whose id starts with this prefix'), since=Option(_DEFAULT_SINCE_HOURS, '--since', min=0, help='Ignore finished jobs that ended more than this many hours ago (default 24; 0 = no limit)'), idle_after=Option(None, '--idle-after', min=1, help="Seconds without activity before a running job is UNSTICK (default: the score's stale_detection timeout, else its sheet timeout)"), tasks=Option(None, '--tasks', help='Also list TASK*.md files in this directory that no job is bound to (by the task hash in the job id `mzt agents run` makes) as CAST rows'), json_output=Option(False, '--json', '-j', help='Output a JSON array (no ANSI)'))
List what needs attention across jobs: one action per job, most urgent first.
Actions: ESCALATE (a human must decide: failed, cancelled, paused at a
fermata), UNSTICK (a running sheet has gone quiet), JUDGE (completed, not
yet judged), CAST (with --tasks: a TASK*.md file has no job yet; the row
carries task), WAIT (still running), DONE (completed and judged). An
empty queue is one DONE row with a null job_id. Judged state is the marker
that mzt verdict --accept writes in the job's workspace.
Examples:
mzt next --json mzt next --mine legion- --json mzt next --tasks . --json