Skip to content

ci: enforce contributor guardrails - #5

Merged
kunchenguid merged 3 commits into
mainfrom
chore/contributing-pr-enforcement
Jun 12, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
chore/contributing-pr-enforcement

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

The captain wants firstmate to have the same contributor guardrails as his other repos (lavish-axi, gh-axi, trial-by-combat, etc.): a CONTRIBUTING.md guide plus GitHub Actions enforcement for PRs. Adapted from the standard set: (1) CONTRIBUTING.md documenting the mandatory git-push-no-mistakes flow and firstmate-specific repo conventions (template repo, AGENTS.md is the contract, CLAUDE.md/.claude/skills symlinks, tracked-vs-local split, bash + shellcheck, one sentence per line in Markdown); (2) no-mistakes-required.yml copied from lavish-axi minus the release-please bot exemption since this repo has no releases; (3) ci.yml that shellchecks bin/*.sh and checks repo invariants (symlinks intact, personal fleet paths like data/ state/ config/ projects/ untracked). guard-generated-files.yml was deliberately NOT ported because firstmate has no release-please or generated files. The SC2016 shellcheck directive added in bin/fm-spawn.sh is deliberate: the single-quoted launch templates defer expansion to the crewmate tmux pane, and the directive makes shellcheck pass clean so CI can enforce it. All CI steps were verified to pass locally before commit.

What Changed

  • Added GitHub Actions checks for shell scripts, repository invariants, and PR bodies signed by the no-mistakes flow.
  • Added a CONTRIBUTING.md guide covering the required no-mistakes workflow and firstmate repository conventions.
  • Updated firstmate docs and spawn script shellcheck annotations so the new CI guardrails match the repo layout and launch-template behavior.

Risk Assessment

⚠️ Medium: The change is small and mostly documentation/CI guardrails, but the central enforcement workflow can be trivially bypassed if treated as a mandatory policy gate.

Testing

Bootstrap was clean; I exercised the PR enforcement script end-to-end for signed and unsigned human PR bodies, exercised the CI repo invariant checks, confirmed the omitted generated-file guard and lack of release-please exemption, and left the worktree clean. I did not run the shellcheck CI step because this testing prompt explicitly forbids linters/static analysis.

Evidence: PR signature enforcement transcript

Scenario: human PR created by no-mistakes with signature Found no-mistakes signature in PR #42 body. Result: accepted Scenario: human PR without no-mistakes signature ::error::This PR was not raised through no-mistakes. Contributions to this repository must be submitted via 'git push no-mistakes'. That pipeline runs the required review/test/lint/CI steps and writes a deterministic '## Pipeline' section into the PR body containing: Updates from git push no-mistakes See CONTRIBUTING.md for setup and the full workflow. PR author: octocat Result: rejected

Scenario: human PR created by no-mistakes with signature
Found no-mistakes signature in PR #42 body.
Result: accepted

Scenario: human PR without no-mistakes signature
::error::This PR was not raised through no-mistakes.

Contributions to this repository must be submitted via 'git push no-mistakes'.
That pipeline runs the required review/test/lint/CI steps and writes a
deterministic '## Pipeline' section into the PR body containing:

    Updates from [git push no-mistakes](https://github.com/kunchenguid/no-mistakes)

See CONTRIBUTING.md for setup and the full workflow.

PR author: octocat
Result: rejected
Evidence: Repo invariant transcript

Scenario: CI symlink invariants CLAUDE.md -> AGENTS.md .claude/skills -> ../.agents/skills Scenario: CI personal fleet path invariant No tracked files under data/, state/, config/, projects/, or .no-mistakes/. Scenario: generated-file guard deliberately absent No .github/workflows/guard-generated-files.yml tracked.

Scenario: CI symlink invariants
CLAUDE.md -> AGENTS.md
.claude/skills -> ../.agents/skills

Scenario: CI personal fleet path invariant
No tracked files under data/, state/, config/, projects/, or .no-mistakes/.

Scenario: generated-file guard deliberately absent
No .github/workflows/guard-generated-files.yml tracked.
- Outcome: ⚠️ 1 warning across 1 run (2m8s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ .github/workflows/no-mistakes-required.yml:31 - The required check accepts any PR body containing this public marker, so a manually opened PR can paste the string and pass without ever going through no-mistakes. If this is meant to enforce the gate rather than serve as an advisory convention, validate a non-forgeable signal from the no-mistakes run or document the limitation explicitly.
⚠️ **Test** - 1 warning
  • ⚠️ .github/workflows/ci.yml:18 - I did not run shellcheck bin/*.sh, so I could not directly demonstrate the new CI lint job passes. This validation prompt explicitly forbids linters/static analysis, and shellcheck is a linter.
  • bin/fm-bootstrap.sh
  • Simulated .github/workflows/no-mistakes-required.yml PR-body check with a no-mistakes-signed human PR body and a manual human PR body, recording /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KTX6NK7HKCCY4H1Y4NF0X775/no-mistakes-required-transcript.txt
  • Executed .github/workflows/ci.yml repo invariant commands for CLAUDE.md, .claude/skills, and personal fleet paths, plus verified guard-generated-files.yml is not tracked, recording /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KTX6NK7HKCCY4H1Y4NF0X775/repo-invariants-transcript.txt
  • Searched workflows for release-please, github-actions[bot], dependabot[bot], and guard-generated-files to confirm only the intended bot exemptions are present and the generated-file guard was not ported
  • Searched bin/*.sh for the deliberate SC2016 directive documenting deferred crewmate-pane expansion
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

CONTRIBUTING.md documents the no-mistakes contribution flow and repo
conventions. CI lints bin/ with shellcheck and checks repo invariants
(symlinks intact, personal fleet paths untracked); a second workflow
requires the no-mistakes signature on PRs targeting main.
@kunchenguid
kunchenguid merged commit 683b8cf into main Jun 12, 2026
3 checks passed
@kunchenguid
kunchenguid deleted the chore/contributing-pr-enforcement branch June 12, 2026 06:30
vipentti pushed a commit to vipentti/firstmate that referenced this pull request Aug 5, 2026
* chore: add CONTRIBUTING guide and PR enforcement CI

CONTRIBUTING.md documents the no-mistakes contribution flow and repo
conventions. CI lints bin/ with shellcheck and checks repo invariants
(symlinks intact, personal fleet paths untracked); a second workflow
requires the no-mistakes signature on PRs targeting main.

* no-mistakes(document): Sync contributor documentation

* no-mistakes: apply CI fixes
Mr-G-9527 pushed a commit to Mr-G-9527/firstmate that referenced this pull request Aug 13, 2026
…nct rc=20 for tool unavailable

Extend bin/fm-decision-hold.sh with the GLM-endorsed pivot from
bin/fm-holds.sh: add a list subcommand that prints the open-decision
inventory with one row per captain-held decision (GLM B1), and refactor
the require_tasks_axi gate to exit with rc=20 TOOL_UNAVAILABLE distinct
from rc=1 decision-unverified so the unresolved-decision completion gate
in bin/fm-teardown.sh:2320 no longer conflates the two failure modes
(GLM B2, also pinned by §1.6 of the self-scaffolding report).

list walks the per-origin state/<id>.meta decision_keys field - the
same path the existing verify subcommand enumerates - so list cannot
disagree with complete --none's attestation about which decisions are
open. Each row carries the full AXI kunchenguid#9 context: id, origin, state
(pending|routed|resolved), age, why-now episode (file:line), dependency
(list of blocked-by tasks with their state, or no-block), what unlocks
(exact command_resolve invocation + downstream tasks), and the hold_reason
summary. --json emits the same keys as a parseable array.

bin/fm-teardown.sh:2320 now distinguishes rc=20 (gate UNKNOWN: tool
unavailable) from rc=1 (gate genuinely failed: decision unverified).
Both still refuse teardown because the gate status is not green; only
the diagnostic differs so the captain can act on the right surface
(reinstall tasks-axi vs. complete the inventory).

Colocated tests at tests/fm-decision-hold-list.test.sh exercise:
- AXI kunchenguid#5 definitive empty state (0 results, [])
- AXI kunchenguid#9 schema coverage for text and JSON output
- state transitions pending -> routed -> resolved via the real resolve path
- filter contract (--by-origin, --by-key; mutually-exclusive = rc=2)
- distinct rc=20 for verify/complete/list with stubbed unavailable tasks-axi
- fm-teardown.sh distinguishes rc=20 from rc=1 in actual teardown runs

shellcheck passes; fm-lint.sh green; existing
tests/fm-decision-hold-lifecycle.test.sh still passes (one pre-existing
secondmate test failure is unrelated to this change). Mode=local-only
per captain's standing instruction.
NewAiCoder referenced this pull request in NewAiCoder/firstmate Sep 26, 2026
* feat(bin): launch crewmates inside a memory-bounded systemd scope on Linux

On Linux hosts with a working systemd --user session, fm-spawn.sh now
launches each crewmate's process tree through `systemd-run --user --scope
--slice=firstmate-agents.slice --unit=fm-<id>-<gen>.scope` wrapping the
existing launch command, so the kernel - not discipline - keeps a runaway
worker's memory away from the host. Every other host keeps the prior
unwrapped launch untouched, byte-identical meta included.

Throttle-then-protect, not a tight cap: MemoryHigh 3G (default) lets the
kernel reclaim aggressively without killing anything; only MemoryMax 6G
(default) past that is fatal. firstmate-agents.slice itself gets
MemoryHigh/MemoryMax at 55%/70% of MemTotal, computed from /proc/meminfo and
applied with `systemctl --user set-property`, so the host always keeps
roughly 30% of RAM for itself regardless of worker count. All five numbers
are overridable via local gitignored config/agent-memory.

- bin/fm-agent-memory-lib.sh: new library - availability detection, argv
  composition, meminfo percentage math, slice configuration, live
  MemoryCurrent/Result reads, and an idempotent OOM status-append.
- bin/fm-spawn.sh: sources the library, wraps the launch when available,
  records memory_scope=/memory_high=/memory_max=/memory_swap_max= in meta.
- bin/fm-crew-state.sh: reports the scope's live MemoryCurrent on every read,
  and names an OOM-kill in the dead-endpoint detail.
- bin/fm-watch.sh: on first sighting of a stale, confirmed-dead endpoint,
  appends `failed: killed by the per-worker memory limit (MemoryMax=...)`
  to the task's own status log so firstmate escalates on the actual cause.
- bin/fm-teardown.sh: cleans up the new state/<id>.oom-reported marker.
- tests/lib.sh: globally exempts the test suite from opportunistically
  activating the real wrapper on a systemd host, so existing spawn fixtures
  that assert on literal launch text stay deterministic; the new
  fm-agent-memory-* tests explicitly clear the exemption to exercise it.
- docs/configuration.md, AGENTS.md: document config/agent-memory and the new
  meta/state fields.

Manually verified on this host (a Fedora host, MemTotal 15758624 kB): slice
configure computed MemoryHigh=8875257036 MemoryMax=11295781683 bytes
(55%/70%); a throwaway `sleep` scope launched through the real wrapper
reported a live MemoryCurrent while running.

Does not change the 6-worker operating cap or touch project clones.

Also fixes tests/fm-backend-herdr-presentation-e2e.test.sh's normalize_meta,
which now normalizes memory_scope= the same way it already normalizes
spawn_gen= (both embed the same non-deterministic spawn incarnation), so the
opted-out-vs-projected metadata byte comparison stays correct.

Full regression sweep (bin/fm-test-run.sh --changed, ~3100 assertions) is
green except 5 pre-existing failures confirmed unrelated to this change by
reproducing identically on a clean pre-change worktree (8c6bbb6) or by
tracing the failing code path (fm-watcher-lock.test.sh HUP timing under
load, fm-backend-herdr-focus-flash-e2e.test.sh's Part C, fm-bootstrap.test.sh
and fm-session-start.test.sh's MISSING-tool diagnostics, plus
fm-pr-check-security.test.sh crashing on this host's missing `shasum`).

* fix(tests): exempt real fm-spawn e2e guards from the memory-scope wrapper

tests/fm-cmux-claude-composer-live-e2e.test.sh and tests/herdr-test-safety.sh
drive the real bin/fm-spawn.sh but don't source tests/lib.sh, so its global
FM_AGENT_MEMORY_DISABLE=1 exemption never reaches them. Without this, a real
spawn on a systemd-capable host activates the systemd-run wrapper, changing
process-tree shape and timing under families whose assertions are already
timing-sensitive - same reasoning as the existing FM_GATE_REFUSE_BYPASS
exemption in tests/lib.sh.

* fix(bin): scrub internal hostname literal from memory-scope comments

bin/fm-agent-memory-lib.sh and bin/fm-spawn.sh named a specific captain-private
host in a code comment explaining why the per-worker memory throttling exists.
firstmate is a shared template repo; comments describe the general condition
(a busy fleet freezing a host) instead of naming which host.

* no-mistakes(document): docs(scripts): list fm-agent-memory-lib.sh in bin/ inventory

---------

Co-authored-by: NewAiCoder <[email protected]>
@kmohta03

Copy link
Copy Markdown

Operator notes (read before deploying)

  • Why the cap is a local file, not the database. The writer role can neither set nor read a cap on labelling requests: the requests table's check constraint allows max_tokens only on reannotate requests, and request_params rejects unknown params keys. So this PR changes no database. A labelling request with no cap of its own runs under the worker's default of 1,000,000 tokens (--default-max-tokens, passed explicitly by ops/ltc-rd/run-worker.sh), counted across everything it pays for (space SOP, camera check, onboarding, labelling, Day-0 refinement). Dashboard-created requests run under that default.
  • Raising one request's cap. On LTC-RD: cycle-autolabel request cap <request id> --max-tokens N. It writes ~/cycle-autolabel-requests/<id>/max_tokens.json (no database call) and can set it higher or lower than the default. A request parked at its cap resumes at its next retry, within an hour; the weekly reset does not lift a cap.
  • Training hand-off is manual for now. Approved autolabel videos must be added to their action type (embedding space) by hand until the database release that adds reviewed videos automatically lands. The digest does not count them: the writer role cannot read space membership (cv.embedding_space_videos), and no grant was widened.

Grijak added a commit to Grijak/firstmate that referenced this pull request Sep 28, 2026
fix(bin): record non-ASCII Lavish board answers intact instead of cutting them off
davestanyer pushed a commit to davestanyer/firstmate that referenced this pull request Oct 8, 2026
…t-windows-abspath

fix(bin): treat a native Windows absolute CLAUDE_CONFIG_DIR as absolute
@lad-spg

lad-spg commented Oct 9, 2026

Copy link
Copy Markdown

Zusammenfassung (Backend-Strang, Runde 1 und 2)

Refactor von services/api ohne Änderung der öffentlichen API- und MCP-Verträge, außer der unten genannten Vertragsänderung. Je Punkt ein Commit; Plan und Grenzen stehen in Docs/Markdown/plan-dg-backend.md. Der Contract-Harness liegt jetzt unter services/api/tests/contract/ (Aufruf in der dortigen README.md).

Vertragsänderung (freigegeben): Eine syntaktisch ungültige ID verhält sich wie eine unbekannte. /api/practices/{id} antwortet mit 404 {"detail": "practice not found"} statt 500 mit SQL-Text; /api/agents/runs/{id}/logs und die MCP-Tools get_practice_signals und get_score_breakdowns liefern {"items": []}; MCP get_practice meldet „Praxis nicht gefunden.“. Im Contract-Diff gegen Base ist das genau detail:not_uuid (500 → 404), dazu erwartungsgemäß mcp_log_ready_lines 6 → 1 (MCP initialisiert die Laufzeit nur noch einmal).

Bewusst nicht übernommen (Prüfbericht Schicht 3):

  • P3-01 (CI überspringt Testmodule ohne Abhängigkeiten): gehört zum Plattform-Strang (.github/**), dort schon umgesetzt.
  • P3-05 (Commit-Text „eine DNS-Auflösung pro Anfrage“): Text und Code stimmen, pro Anfrage (robots.txt und Seite je einmal) wird einmal aufgelöst.
  • P3-06 (scope.practice_id in /api/agents/run wird nicht geprüft): vorbestehend, eine Prüfung wäre neues API-Verhalten; eigenes Ticket.

Von der Pipeline ergänzt: Tests prüfen Parameter statt SQL-Text; docs/agent-flows.md beschreibt den Retry-Backoff jetzt als linear (so verhält sich der Code).

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
* feat: ship the daily intake and to-do page as an opt-in feature

Bring the morning intake gate, the continuous channel intake and the daily
to-do page engine into Starship as one optional system. Nothing reads, arms
or schedules until a home's config/morning-intake or config/channel-intake
turns it on, and each home names its own sources.

The page engine keeps no system-specific code. An add-on extends it through
two new hook points: todo-verbs takes more verbs typed on a row and marks the
row with fm-todo.sh mark, and todo-page adds sections of its own. A home whose
add-on carries same-named tools, hooks or skills keeps running the add-on's.

* no-mistakes(review): Add hand-over, reopen guard and ledger partner-awaiting; behavioural tests

* no-mistakes(review): Let source resolution beat hand-over reopen; harden isolation test

* no-mistakes(review): Reopen only when the source did not change state

* no-mistakes(ci): Fixed "Behavior portable parallel 2": tests/fm-test-run.test.sh "packing exactly at the budget must be accepted" failed (exit 1). Rule broken: the portable serial lane must keep enough spare room that a script weighted exactly at the 1200000 ms budget packs alone, and the shard count must agree everywhere it is set. This PR added four serial test scripts (fm-channel-intake, fm-morning-intake, fm-todo, fm-todo-render) with no measured time, each counted at the 45000 ms default. The largest serial shard rose from 1180219 to 1194905 ms and the boundary fixture overflowed to 1205215 ms; reproduced locally. Fix: (1) added the four scripts' measured duration_ms from this PR's CI run 41103972215 to portable_serial_weight_hints (64209, 18194, 53145, 24241 ms); measured times alone still overflowed by 3404 ms. (2) Following precedent commit 12d6173 (11 to 12 shards for the same failure), went from 12 to 13 serial shards in bin/fm-test-run.sh, .github/workflows/ci.yml, .github/workflows/windows-wsl.yml (lanes of13 plus 13of13), tests/fm-install-herdr.test.sh, CONTRIBUTING.md and docs/fm-test-portable-shards.md, which also records where the new times came from. Verified: --check-coverage passes (serial_shards=13, serial_max_ms=1101850); tests/fm-test-run.test.sh, fm-install-herdr, fm-ci-workflow and fm-linux-setup all exit 0. Follow-up for the owner: add "Behavior portable serial 13" to the required checks in branch settings. Note: a temporary git worktree was briefly created outside this worktree to check the base commit, then removed and pruned right away
ghazni101 pushed a commit to ghazni101/firstmate-dsh that referenced this pull request Nov 18, 2026
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.

4 participants