Skip to content

Extract crew contract into globally-loaded fm-crewmate skill - #178

Closed
rob-struction wants to merge 1 commit into
kunchenguid:mainfrom
rob-struction:fm/extract-fm-crewmate-p1
Closed

rob-struction wants to merge 1 commit into
kunchenguid:mainfrom
rob-struction:fm/extract-fm-crewmate-p1

Conversation

@rob-struction

Copy link
Copy Markdown

Phase 1 of the context-slimming plan: extract the crew contract into a reusable, globally-loaded fm-crewmate skill

Follows data/scout-skill-extraction-ba/report.md Part 1, with the captain's decision on skill home (firstmate-owned + global via symlink).

The problem

bin/fm-brief.sh re-emitted the entire crewmate contract into every brief via two large heredocs plus a per-mode case block. The invariant contract (worktree isolation, status protocol, escalation, push/merge rules, per-mode definition of done, project memory, scout rules) was duplicated on every dispatch and re-transmitted to the crewmate in full each time.

The change

1. New skill .agents/skills/fm-crewmate/SKILL.md (firstmate-owned, canonical).
Holds the whole standing contract for all delivery shapes: worktree-isolation assertion, status-reporting protocol, escalation, tools (gh-axi/chrome-devtools-axi), verification/no-hallucination, ship Setup (branch creation + no-mistakes init note), the per-mode Definition of Done (no-mistakes, direct-PR, local-only), the scout-task contract, the project-memory step, and the PR-review variant. Placeholders (<id>, <STATUS_FILE>, <DATA>, <FM_ROOT>) are supplied by the brief. Frontmatter user-invocable: false. Lives in the repo so it travels with firstmate through git + /updatefirstmate (.claude/skills already symlinks to .agents/skills).

2. Global auto-load via bootstrap symlink.
bin/fm-bootstrap.sh gains an idempotent, best-effort ensure_global_crew_skill that symlinks ~/.claude/skills/fm-crewmate -> <FM_ROOT>/.agents/skills/fm-crewmate, so every crew in every repo (not just firstmate) auto-loads it. Creates ~/.claude/skills if missing; never clobbers a real (non-symlink) dir/file there (warns + skips via a new SKILL_LINK: line); a symlink failure never aborts bootstrap. Scoped to claude's global skills dir, with a comment noting other harnesses would need their own link.

3. Slim bin/fm-brief.sh.
Both contract heredocs and the case "$MODE" fragment-assembly block are gone (only mode resolution via fm-project-mode.sh remains). Briefs now emit an identity line + a pointer to the fm-crewmate skill + this run's variables (task, repo, delivery mode, branch fm/$ID, status-file path, report path for scout, FM_ROOT). Reference is unconditional (the skill is globally available). Net: bin/fm-brief.sh loses ~125 lines; each brief transmits ~10 lines of variables instead of ~35-70 lines of contract.

4. AGENTS.md section 11 updated to the new brief shape and notes the skill is firstmate-owned + globally symlinked. (The larger AGENTS.md self-slimming is a later phase, out of scope here.)

Verification (all run, not asserted)

  • bash -n bin/fm-brief.sh and bash -n bin/fm-bootstrap.sh both pass.
  • Ran the scaffolder end-to-end for scout + all three ship modes (no-mistakes, direct-PR, local-only); every generated brief references the fm-crewmate skill and carries all needed variables with the correct resolved mode.
  • Exercised ensure_global_crew_skill in an isolated HOME: fresh create produces the symlink and SKILL.md resolves; re-run is a silent idempotent no-op; a non-symlink at the target is left untouched with a SKILL_LINK: warning.
  • No broken global symlink was left pointing at the disposable worktree; bootstrap creates the real link from the primary FM_ROOT post-merge (guarded by an [ -d "$src" ] check).

Out of scope (later phases)

  • The big AGENTS.md → on-demand-skills extraction.
  • The struction CLAUDE.md/AGENTS.md reconcile + skill-tree symlinks.
  • bin/fm-spawn.sh (has intentional local uncommitted edits in the primary).

The standing crewmate contract (worktree isolation, status protocol,
escalation, tools, per-mode definition of done, project memory, scout
rules, PR-review variant) was re-emitted into every brief by two large
fm-brief.sh heredocs plus a per-mode case block. Move it once into a
firstmate-owned skill at .agents/skills/fm-crewmate/SKILL.md.

- fm-bootstrap.sh idempotently symlinks the skill into ~/.claude/skills
  so every crew in every repo auto-loads it (best-effort, non-fatal;
  never clobbers a real dir/file there).
- fm-brief.sh now emits slim briefs: identity line + pointer to the
  fm-crewmate skill + the run's variables (task, repo, mode, branch,
  status-file path, report path, FM_ROOT). The mode-fragment case block
  is gone; only mode resolution remains.
- AGENTS.md section 11 updated to the new brief shape.

Briefs shrink from ~35-70 lines of contract to ~10 lines of variables;
the contract lives once, versioned, and travels via git + /updatefirstmate.
andrew-kim-techtorch added a commit to andrew-kim-techtorch/firstmate that referenced this pull request Jul 17, 2026
…dc parser without a global install (#14)

* fix(bin): catch reserved-mermaid-keyword node ids and run the real mmdc parser without a global install

Layer 1 now flags a reserved mermaid keyword (graph, end, subgraph, class,
style, click, linkStyle, direction, flowchart, classDef) used as a node id
adjacent to a shape opener or edge, catching the PR kunchenguid#178 class of bug
install-free. Layer 2 now falls back to `npx --yes @mermaid-js/mermaid-cli`
when mmdc is not on PATH, so the authoritative parser actually runs instead
of silently skipping.

* no-mistakes(review): make mermaid keyword linter quote-aware and tests hermetic

* no-mistakes(document): document mermaid reserved-keyword lint and npx real-parser fallback
@bobcave

bobcave commented Sep 2, 2026

Copy link
Copy Markdown

Cierre firmado de la ventana WF-T1 — separación de roles PostgreSQL

GO firmado por el capitán el 2026-09-02 con la privada evidencia-2026-08.

Elemento Valor
SHA256 del sobre cierre.dsse.json 250542eeb0b30550fe13a57ac80abfd9f210d12f5643fed88ba9f85a1247589e
SHA256 del payload 999cfba275e23a886c0d1255f84b454d07e893f80a811bded43b62e5894c7f89
keyid evidencia-2026-08 (mes del depósito, no de la ventana)
Verificación valido:true, código 0
Ventana wf-t1-2026-09-01
Commit operado 615e5d07…d2571
Checkpoint 0013 → 0014

Los nueve gates

G0–G8 todos PASS. Actas: #182 (G0), #183 (G1), #184 (G2), #185 (G3), #186 (G4), #187 (G5),
#188 (G6), #189 (G7).

Resultado operativo

El cutover está en producción: API y worker corren como cmx_runtime, con cero sesiones del
rol histórico
medidas con el pool caliente, readiness 200/200, cero reinicios y la guarda
de identidad C4 sin un solo evento. El login histórico consolidamex permanece LOGIN; su retiro
es un gate posterior y no queda implícito en este GO.

rollback.probado_en_scratch=true por el CI del commit operado, y cambio_env_probado=true por el
ensayo en seco ejecutado dentro del hard stop: variable al histórico con readiness 200, vuelta a
cmx_runtime con readiness 200.

Observación

Un ciclo, 14 h desde el cutover, muy por debajo del techo de 26 h. Una corrida de escaneo
exitoso con errores=0 iniciada después del cutover. Cobertura completa, con ingreso y
salida reales con una cuenta de prueba emitida y dada de baja al cerrar.

Todos los conteos de #189 en cero: permisos denegados, "code":"42501", sql_42501,
worker.error, tipo=identidad, veneno de outbox y sesiones históricas.

Lo que consta en rojo y no se maquilló

observacion.xact_rollback_delta = 3 frente a una base de 0. Se conserva tal cual se midió. El
GO es válido porque el criterio compara tasas normalizadas por duración, no conteos brutos: 3
reversiones en 14 h son 0,214 eventos/hora, por debajo del margen absoluto de 1 evento/hora que
aplica cuando la base es cero.

Ese criterio se corrigió durante esta ventana. La versión inicial comparaba conteos brutos de una
base de 12 minutos contra una observación de 14 horas —el defecto que documenta #245—, y su
primera normalización escribía el margen como 1/3600, 3600 veces más estricto que lo que su
propio comentario declaraba. Ambas cosas están arregladas y fijadas con dos pruebas que vigilan la
unidad por los dos lados. 82 pruebas en verde.

Quiescencia de cierre

Cuatro diferencias frente a Q0, las cuatro atribuidas y ninguna inexplicada: bitácora +6 por los
eslabones del ejercicio de cobertura, vencimientos_escaneos +1 por el escaneo post-cutover que es
el criterio del propio gate, y usuarios_totales 3→4 por la cuenta de prueba declarada por el
capitán. usuarios_vivos sigue en 3: la baja es lógica.

Correcciones abiertas, ninguna bloqueante

#243, #244 y #245 quedaron aplazadas deliberadamente hasta esta firma para no mover main ni
reabrir el hash del runbook. Ya pueden fusionarse.

Lo que este cierre NO autoriza

No autoriza P1–P5: ni el retiro de DATABASE_URL legado, ni la eliminación del fallback de Compose,
ni Retiro-1/2, ni op-llave, ni las rotaciones. Cada uno exige su propia autorización escrita y
fechada.

@bobcave bobcave mentioned this pull request Sep 2, 2026
@karotkriss

Copy link
Copy Markdown
Contributor

Real-browser E2E evidence

Driven in Chrome against a local server: edit a point in /admin/slides, preview, publish, see it on the homepage, then revert.

  1. Draft + live preview - the "Buy from ACH" card's first point is edited; the preview iframe scrolls to the card, rings it, and shows the draft, while "Live now" lists the published points and the publish bar counts 1 section with unpublished changes. The draft survived a full page reload.
  2. Published - after Publish changes, the live homepage shows the edited point.
  3. Reverted - after Reset to default, the homepage is back on the built-in points; the #why section HTML is byte-identical to master.
e1-editor-draft-preview.png e2-home-published-why.png
e1-editor-draft-preview.png e2-home-published-why.png
e3-home-reverted-why.png
e3-home-reverted-why.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants