Repository navigation
feat(skills): add pal-council, a multi-vendor council of expert voices moderated by firstmate - #38
Merged
Merged
Conversation
added 3 commits
September 25, 2026 15:44
…derated by firstmate Add the captain-invocable pal-council skill and bin/fm-pal-council.sh (implemented in bin/fm_pal_council.py, standard library only). A council seats 1-5 voices from different model providers as read-only scout workers, runs a blind first round and then delta-packet rounds, and ends in a synthesis firstmate writes once as the neutral moderator. - Tiers resolve seats from each harness's own model catalog through configured patterns; no model id is hard-coded. quota-axi exhaustion excludes a seat; a single-provider council needs the captain's word. - A euro estimate from configured list prices gates launch against the budget, and the spend recomputed at every round closes an overrun. - Everything bound for a voice outside Anthropic or the researcher is pseudonymised (Haiku lists the forms, a deterministic literal recheck refuses any survivor); secrets are refused for every worker. - Voices report through ordinary status lines, so the normal watcher wakes firstmate; cleanup waits for the captain-hold completion gate. - Knowledge payloads (synthesis and record, internal admin,dev roles, pal-council tags) are written for firstmate to ingest; sensitive councils purge their placeholder table and originals after 12 hours through a process-event watch whose action only prints status. Tests: tests/fm-pal-council.test.sh (fakes for every called script and the pseudonymiser) and the opt-in live guard tests/fm-pal-council-catalog-live-e2e.test.sh for the vendor catalogs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Implement Jira IN-18: the firstmate skill
pal-council, a multi-vendor council of expert voices run as fleet workers, moderated and synthesised by firstmate. IN-18 (built from 19 captain decisions, Q1-Q19, plus a captain comment confirming internal RAG visibility admin,dev, never goplanner:public) is the spec; the brief's shape guidance yields to it on conflict. The change is firstmate shared tracked material, so firstmate-coding-guidelines apply (one-owner rule, inline-stub pattern, AGENTS.md size discipline, one sentence per line, plain dash, shellcheck-clean bin scripts, colocated tests run with bin/fm-test-run.sh, no agent co-author in commits).Required behaviour (from the spec and the task brief):
.agents/skills/pal-council/SKILL.mdis the procedure firstmate follows as neutral moderator (steps with "done when" gates), with references/ for the voice persona template, the neutral researcher persona, the per-turn output contract (CONTINUE/DONE plus findings, blockers, questions, research requests), and the voice/researcher brief templates. /pal-council is captain-invocable and also triggered by a chat request.bin/fm-pal-council.sh(plus helpers) owns the mechanics: create data/pal-/ and consiglio.json; resolve the tier (fast: 3 voices low effort; best, default: 3 voices high effort; pro: 4-5 voices max allowed effort plus an economy voice; one seat per provider - Anthropic via claude, OpenAI via codex, Google via agy, optionally grok/cursor) from each harness's own model catalog, never hard-coding model ids; or an explicit list of 1-5 participants {harness, model, persona, instructions}; voices must come from different providers; a separate neutral researcher on agy with no vote answers the voices' research requests with a sourced dossier (URL, date consulted, unverified facts marked) that every voice reads next round; euro estimate from list prices in config documented in docs/configuration.md (default budget 4 EUR per Opus-class voice, 2 EUR for others, plus 0.5 EUR moderator, limits 0.1-50 EUR), shown before start, refusing when it exceeds the budget, consumption updated every round and the council closed when exceeded; quota-axi check at start excludes a voice without quota and asks the captain if only one provider would remain; spawn voices and researcher through bin/fm-spawn.sh --scout with explicit harness/model/effort; brief.md at most 10,000 characters, larger material as attachments; round 1 blind, later rounds in parallel closing when all answered or on timeout, a failed or late voice recorded as such; each turn is turni/-.md; verbale.md append-only with the moderator summary per round; from round 2 each voice gets via fm-send only the others' new turns, the moderator summary and the dossier (delta packets); closing on all DONE, a round with nothing new, the round limit (default 6, max 20), budget exhausted, or the captain; captain interventions through firstmate (message all/one, close, cancel, resume a finished council with a new direction, change topic); synthesis written once by firstmate (recommendation, agreements, remaining disagreements with who holds what, questions for the captain); cleanup of the council's workers only after their turns are in the verbale and the captain-hold-lifecycle completion gate passes; pseudonymisation gate (Haiku finds names, addresses, codes, contacts; the script replaces them with placeholders; a deterministic literal recheck blocks the send if any clear datum remains) before any send to non-Anthropic voices or the researcher, including research queries; never send secrets or credentials to any voice; sensitive councils delete the placeholder table and original attachments after 12h or on request, leaving only the pseudonymised version; RAG ingest of the synthesis and pseudonymised verbale with tags (pal-council, topic, date, participants and models, tier, sensitivity, outcome) and internal roles admin,dev; RAG lookup of prior councils at start with their syntheses passed in the initial brief. Supervision stays firstmate's: voices report through normal status lines and the watcher wakes firstmate; no new daemon or database.Deliberate decisions made while implementing (not mistakes):
launchrefuses until the prior-council search is recorded.whenwatch whose action only prints status; firstmate runspurgeon the wake, because process-event-sources forbids binding an irreversible action to a watch.nextrefuses once spent exceeds the budget). The researcher is budgeted like a non-Opus voice (2 EUR). Estimates model interactive agents with cached repeated context.fm-brief.sh --scoutscaffold (keeping its isolation and status contracts) with targeted anchored edits for the council turn protocol; the edits fail loudly if the scaffold changes. Voices end each turn withdone: turn <N> <CONTINUE|DONE>, and an AGENTS.md section 8 stub says a council worker's wake belongs to the pal-council loop so it is never mistaken for a finished scout.What Changed
pal-councilskill (.agents/skills/pal-council/SKILL.mdplusreferences/for the voice and researcher personas, the per-turn CONTINUE/DONE contract, the brief templates, and the synthesis template). firstmate acts as a neutral moderator and follows its gated steps, which cover tier or explicit-participant composition, a blind first round, delta-packet rounds, research requests to a neutral agy researcher, captain interventions, synthesis, RAG ingest/lookup of prior councils, and cleanup.AGENTS.mdgains a pointer and a section 8 stub, so a council worker's wake belongs to the council loop.bin/fm-pal-council.shas the entry point and command reference, with the mechanics inbin/fm_pal_council.py(stdlib-only Python). It createsdata/pal-<id>/andconsiglio.json. It resolves fast/best/pro tiers from each harness's own model catalog, with one seat per provider. It checks quota before launch. It shows a euro estimate against the budget and refuses if the estimate is over, then tracks spend each round and closes the council once spend exceeds the budget. It spawns voices and the researcher throughfm-spawn.sh --scout. It keeps the round barrier, the per-voice delta packets, the append-onlyverbale.md, and the closing rules. It runs a pseudonymisation gate (Haiku entity detection, placeholder substitution, and a deterministic literal recheck that blocks the send) before anything goes to a non-Anthropic voice or the researcher. Sensitive councils are purged 12h after close. The script also writes RAG payloads tagged with internal rolesadmin,dev.docs/configuration.mdand adds an example council config (docs/examples/pal-council.json),docs/scripts.mdentries, a verification record, and audience metadata. Adds the colocated testtests/fm-pal-council.test.sh, which covers tier resolution with a stubbed catalog, estimate and budget refusal, the pseudonymisation gate refusing a clear name, round barrier and delta packets, and the sensitive purge. Also adds an opt-in live catalog guard,tests/fm-pal-council-catalog-live-e2e.test.sh, registered inbin/fm-test-run.sh.Risk Assessment
✅ Low: The fix round is well bounded and covers the approved findings correctly: the quota-narrowed single-provider stop, cancel closing the open round, topic pseudonymisation with a gated psevdo/verbale.md, full-string purge mapping and the mapped RAG outcome, all with behavioural tests. The one gap left is narrow: a new name that appears only in a close or cancel reason is never pseudonymised.
Testing
The colocated test file tests/fm-pal-council.test.sh passes all 18 of its tests, including those covering the round-1 review fixes: the topic is pseudonymised in psevdo/verbale.md, purge maps every string in consiglio.json, the RAG outcome is pseudonymised, quota exclusion down to one provider stops for the captain, and cancel closes an open round. The coverage guard passes under
LC_ALL=C. Under en_US.UTF-8 it fails on acommsort-order error that the base commit also shows. A manual CLI transcript using stubbed harnesses shows the tier seats, the exit-5 captain stop, the estimate table and budget refusal, the Italian placeholders ([ENTE_1] [PERSONA_1]) and gate refusal, the barrier recording a late voice, a delta packet to the OpenAI voice with no clear name, a verbatim verbale with missing turns recorded, and cleanup refused until the completion gate passes. No live council was run: quota, cost and the live harnesses were not used; this was a CLI-only check with no UI surface.Evidence: pal-council CLI transcript (stubbed harnesses)
Source: pal-council CLI transcript (stubbed harnesses)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm_pal_council.py:1220- The council topic never goes through the pseudonymiser.outgoing_sourcescovers only brief.md, allegati/, precedenti/ and persone/, andmerge_entitiesdrops any form that is not in those texts. Butverbale_headerwritescouncil['topic']in clear, andpsevdo/verbale.mdis onlyapply_map'd (lines 1220 and 1503), never gated. Voices outside Anthropic are pointed at that file as their full record (voice-brief rule 3). Concrete case:new "Contratto con Mario Rossi"with a brief that says only 'il cliente'. Haiku never sees 'Mario Rossi', so psevdo/verbale.md hands the clear name to the codex and agy voices.build_ragthen puts the same unmapped topic into a sensitive council's payload tags. Fix: add the topic (and free-text reasons such as drop and close reasons) to the textspseudoandnextpseudonymise. Also rungate(..., trusted=False)on psevdo/verbale.md before writing it, so a structural hit such as an e-mail is refused rather than left readable.bin/fm_pal_council.py:1827-purgeapplies the map only totopicinside consiglio.json. The leftover check at line 1835 then scans the whole raw file withleak_hits. Any mapped form inclosed_reason, a seatnote(adrop --reasonor a send-failure detail) or another string field makes purge stop with 'clear data survived ... the map was kept'. Every retry fails the same way, so a sensitive council cannot be purged without hand-editing, and the 12h purge requirement fails. Fix: apply the map to every string value in consiglio.json (or to its whole text, as the other .json files get), not just the topic.bin/fm_pal_council.py:527- The intent requires that the quota check 'excludes a voice without quota and asks the captain if only one provider would remain'.check_diversitystops only whenlen(active) >= 2. Concrete case: a best-tier council where quota-axi reports codex and agy at 0%. Two seats are excluded, one claude voice remains, andnewsucceeds with exit 0 and no captain question. A one-voice, one-provider council starts silently. The SKILL documents the narrower rule ('two or more voices'), so this looks deliberate but narrows the spec. It should apply at least whenever quota exclusion brought the council down to one provider.bin/fm_pal_council.py:524- The intent says 'voices must come from different providers' and 'one seat per provider'.check_diversityrefuses only when every voice shares one provider. An explicit--participantslist such as claude/opus + claude/sonnet + codex is accepted with two Anthropic seats. The pro tier in docs/examples/pal-council.json also seats two OpenAI voices (codex top plus codex-eco). The economy seat may be the intended exception, but duplicate providers in an explicit list contradict the stated criterion. Confirm whether duplicate providers should be refused (or need the captain's word) whenever the council has more than one provider.bin/fm_pal_council.py:1598- The intent requires 'cleanup of the council's workers only after their turns are in the verbale'.canceldoes not close an open round, andcleanuponly checks turns listed inrnd['results'], whichclose-roundfills. Concrete case: round 2 is open, two voices have written turni/2-*.md with their [STATUS] line, and the captain cancels.cancelthencleanuptear the workers down, and those delivered turns never reach verbale.md. The non-delivering voices are not recorded as missing either. Fix: havecancelclose the open round (append delivered turns and record missing ones), or havecleanuprefuse when delivered turn files are absent from the record.bin/fm_pal_council.py:1685- For a sensitive council,build_ragmaps the topic and the body text, but writescouncil['closed_reason']raw into the chunk header ('Outcome: ...') and into the metadataoutcome. Theleak_hitscheck covers only the mapped body. A close reason that names a person reaches the RAG in clear. Applyapply_maptoclosed_reasonas well.🔧 Fix: Pseudonymise council topic, fix purge, cancel, and quota stops
1 info still open:
bin/fm_pal_council.py:1693-build_ragnow mapsclosed_reason, and purge maps every string in consiglio.json. Both only replace forms already in the entity map, andclose --reasonandcancel --reasontext never goes through the pseudonymiser. The lastpseudonymise_pass(innext) runs before the close, so itsfree_textsnever sees a close reason. Concrete case: a sensitive council whose brief names 'Mario Rossi' is closed withclose --reason "deciso con Giulia Bianchi". 'Giulia Bianchi' is not in the map, so it reaches the RAG payload'sOutcome:header andpal_council.outcomein clear. It also survivespurgein consiglio.json and in verbale.md.leak_hitschecks only known forms, so purge reports success. Fix: for a sensitive council, runpseudonymise_passover the reason incloseandcancel(or once infinalizeandpurge) before it is recorded or mapped.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-pal-council.test.sh: all 18 tests passed. They cover tier resolution from a stubbed catalog, quota exclusion and the single-provider stop, the budget and the estimate refusal, the send gate, the barrier and delta packets, budget closure, the synthesis and RAG payloads with a pseudonymised outcome, the cleanup gate, the sensitive purge, lost voices, and cancel closing an open round.bin/fm-test-run.sh --check-coverage: under en_US.UTF-8 it exits 1 withcomm: not in sorted order. UnderLC_ALL=Cit reportsFM_TEST_COVERAGE okand includes both new pal-council test files. The base commit's runner shows the samecommerror under en_US.UTF-8, so this was already there before the change.Manual CLI walkthrough ofbin/fm-pal-council.shin a throwaway FM_HOME, using the test's stub catalogs, quota files, fake Haiku and fake spawn/send/teardown/hold/when. It ran new (best tier), new with a quota exclusion that leaves only one provider (exit 5), estimate (within budget, then refused with exit 3), pseudo, check (refused with exit 3), launch, barrier, close-round after the deadline, next (delta packet), cancel with an open round, and cleanup before and after complete.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.