Skip to content

fix: prevent silent contribution coverage failures - #5182

Open
jleemcf wants to merge 3 commits into
kunchenguid:mainfrom
jleemcf:fm/fm-contrib-input-argv-silent-empty-c1
Open

jleemcf wants to merge 3 commits into
kunchenguid:mainfrom
jleemcf:fm/fm-contrib-input-argv-silent-empty-c1

Conversation

@jleemcf

@jleemcf jleemcf commented Sep 21, 2026

Copy link
Copy Markdown

Intent

Fix the contribution-machinery fault filed as this task. Use the transport that already exists in that file, make the failure loud instead of silent, and make the reader treat an empty or failed input as an error rather than a clean zero. This is firstmate's own tooling only — nothing of the CRM, no production work, no database. Report the before and after: what the coverage read before the fix and what it reads after, measured rather than cached.

Context — the fault:

  • bin/fm-fleet-snapshot.sh's --contribution-input output mode ends by passing both JSON documents to jq on its command line: jq -n --argjson backlog "$BACKLOG_JSON" --argjson tasks "$contribution_tasks" '{backlog:$backlog,tasks:$tasks}' followed by an unconditional exit 0. At the current backlog size the whole backlog plus every task record no longer fits inside the OS argv limit, so jq fails with "Argument list too long" on stderr, prints nothing on stdout, and the branch then runs that exit 0 — reporting success with an empty document.
  • bin/fm-contributions.sh get_input() calls exactly that mode and does not check the result, so every poll projects an empty input (known 0, checked 0, unreadable_records 1, complete false), and bearings then reports cached coverage from the last measurement that succeeded. A failing check or an unanswered review on a published PR would not surface.
  • Measured evidence collected before this task (record it in the PR / final report as the "before"): the live --contribution-input path returns exit 0, zero stdout bytes, and jq: Argument list too long on stderr; the coverage projection from that input reads known 0 / checked 0 / unreadable_records 1 / complete false. The same data read through the working temp-file --slurpfile transport (the full-snapshot path) reads known 5 / unreadable_records 0 / counts.fleet 5.

What Changed

  • Replace contribution-input JSON command-line arguments with the existing temporary-file and jq --slurpfile transport; fail loudly on serialization errors.
  • Reject failed producers and missing, empty, or invalid contribution input before projection, surfacing poll failures on both diagnostic channels.
  • Add regression coverage for input rejection, valid zero-ownership input, and serialization failures across snapshot modes.

Risk Assessment

✅ Low: The bounded changes remove aggregate JSON from argv and reject failed or invalid input before projection while surfacing polling failures through the existing diagnostic channel.

Testing

Both focused suites passed. Isolated CLI measurements reproduced the baseline empty-success failure (known 0, checked 0, unreadable 1); the fix produced valid oversized input and fresh coverage of known 5, checked 5, unreadable 0, complete true. Invalid inputs failed visibly, including through the registered watcher. CLI transcripts and persisted output were captured; no live fleet or external forge was accessed.

Evidence: Measured before/after CLI behavior and watcher diagnostics

Source: Measured before/after CLI behavior and watcher diagnostics

Contribution CLI end-to-end evidence
Scope: isolated synthetic operational home, five owned PRs, oversized backlog; real product scripts with a local read-only forge stub.
No live fleet or external forge was accessed. These are newly executed measurements, not claims about the current private fleet.
Author-provided historical live BEFORE: exit=0; stdout=0 bytes; stderr=jq: Argument list too long; coverage known=0 checked=0 unreadable_records=1 complete=false.
Author-provided historical same-data full-snapshot measurement: known=5 unreadable_records=0 counts.fleet=5.
Fresh isolated measurements at 2026-09-21T19:20:26Z:

$ <fixture>/before/bin/fm-fleet-snapshot.sh --contribution-input
BEFORE oversized contribution input: exit=0; stdout=0 bytes
stderr: <fixture>/before/bin/fm-fleet-snapshot.sh: line 1991: /usr/bin/jq: Argument list too long

$ <fixture>/before/bin/fm-contributions.sh snapshot <fixture>~
BEFORE reader: exit=0; stdout=326 bytes
BEFORE projection: {"checked": 0, "complete": false, "counts": {"captain": 0, "fleet": 0, "maintainer": 0, "nobody": 0}, "known": 0, "unreadable_records": 1}

$ <fixture>/before/bin/fm-fleet-snapshot.sh --json
BEFORE full snapshot: exit=0; stdout=368680 bytes
BEFORE working full-snapshot transport: {"checked": 0, "complete": false, "counts": {"captain": 0, "fleet": 5, "maintainer": 0, "nobody": 0}, "known": 5, "unreadable_records": 0}

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-fleet-snapshot.sh --contribution-input
AFTER oversized contribution input: exit=0; stdout=366186 bytes

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
AFTER reader: exit=0; stdout=326 bytes
AFTER projection before any forge reads: {"checked": 0, "complete": false, "counts": {"captain": 0, "fleet": 5, "maintainer": 0, "nobody": 0}, "known": 5, "unreadable_records": 0}

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh poll
AFTER fresh poll (no prior saved records): exit=0; stdout=580 bytes
stdout: contribution-wake: check: contributions delivery-1 fa408d116e81aa210cb848360b9c5a26f119bd61911c1917bb44078b3c56e1ea
contribution-wake: check: contributions delivery-2 368c1ea9ecdcac933b7ba37c905f4bead4ca2bb5b487ec56f62cc7bbfe7620d9
contribution-wake: check: contributions delivery-3 606c0955820a1a1da3a177d9497cf0d1b9afba1926f3a3d8c3c35611bab52cd3
contribution-wake: check: contributions delivery-4 2f933f94b513408e89c74af285a273b283689b120e6874616113c0909503c1a5
contribution-wake: check: contributions delivery-5 ad3d26b5e2279e901f8db8d49252ca4edb7be4c8427d7c8108e9a573e9a2e324
Fresh forge requests executed against local stub: 40; all five persisted observations have checked_at=2026-09-21T19:20:26Z, failing test checks and pending maintainer reviews.

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
AFTER reader after poll: exit=0; stdout=331 bytes
AFTER freshly observed reader coverage: {"checked": 5, "complete": true, "counts": {"captain": 0, "fleet": 5, "maintainer": 0, "nobody": 0}, "known": 5, "unreadable_records": 0}

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-bearings-snapshot.sh --json
AFTER Bearings: exit=0; stdout=2185 bytes
AFTER Bearings consumes records just measured by poll: {"checked": 5, "complete": true, "counts": {"captain": 0, "fleet": 5, "maintainer": 0, "nobody": 0}, "known": 5, "unreadable_records": 0}

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh arm
Register real authenticated contribution poll: exit=0; stdout=41 bytes

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh poll
Poll failure empty: exit=1; stdout=47 bytes
stderr: fm-contributions: contribution snapshot was empty
stdout visible to scheduler: contributions: contribution snapshot was empty

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh poll
Poll failure invalid: exit=1; stdout=49 bytes
stderr: fm-contributions: contribution snapshot was invalid
stdout visible to scheduler: contributions: contribution snapshot was invalid

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh poll
Poll failure failed: exit=1; stdout=49 bytes
stderr: forced serialization failure
fm-fleet-snapshot: contribution input serialization failed
fm-contributions: contribution snapshot unavailable
stdout visible to scheduler: contributions: contribution snapshot unavailable

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-watch-checkpoint.sh --seconds 15
Actual watcher checkpoint: exit=0; stdout=209 bytes
watcher stdout: check: <fixture>/diagnostic-home/state/contributions.check.sh: contributions: contribution snapshot unavailable
durable wake queue: 1790018429	1	check	<fixture>/diagnostic-home/state/contributions.check.sh	check: <fixture>/diagnostic-home/state/contributions.check.sh: contributions: contribution snapshot unavailable

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects missing: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot unavailable

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects empty: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot was empty

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects whitespace: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot was invalid

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects malformed: exit=1; stdout=0 bytes
stderr: jq: parse error: Unfinished JSON term at EOF at line 1, column 1
fm-contributions: contribution snapshot was invalid

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects null: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot was invalid

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects wrong-shape: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot was invalid

$ ~/.no-mistakes/worktrees/0590c93caff1/01M32NQ7HVBTBQ7FGR99NRQDFB/bin/fm-contributions.sh snapshot <fixture>~
Snapshot rejects multiple: exit=1; stdout=0 bytes
stderr: fm-contributions: contribution snapshot was invalid

All fixture assertions passed. Worktree fixture directories removed at completion.
Evidence: Freshly persisted fixture observations and pending reviews

Source: Freshly persisted fixture observations and pending reviews

[
  {
    "schema": "fm-contributions.v1",
    "task": "delivery-1",
    "records": [
      {
        "url": "https://github.com/o/r/pull/1",
        "kind": "pr",
        "checked_at": "2026-09-21T19:20:26Z",
        "observation": {
          "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "state": "open",
          "draft": false,
          "mergeable": "mergeable",
          "can_merge": false,
          "review_decision": "CHANGES_REQUESTED",
          "reviews": [
            {
              "id": 12,
              "user": {
                "login": "maintainer"
              },
              "author_association": "OWNER",
              "body": "Please address the failure",
              "html_url": "https://github.com/o/r/pull/1#pullrequestreview-12",
              "submitted_at": "2026-09-21T19:20:26Z",
              "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "state": "CHANGES_REQUESTED"
            }
          ],
          "checks": [
            {
              "name": "test",
              "id": 1,
              "status": "completed",
              "conclusion": "failure",
              "started_at": "2026-09-21T19:20:26Z"
            }
          ],
          "events": [
            {
              "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
              "type": "review",
              "source": "https://github.com/o/r/pull/1#pullrequestreview-12",
              "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "author": "maintainer",
              "body": "Please address the failure"
            }
          ],
          "absent_checks": []
        },
        "verdict": null,
        "seen": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "pending": [
          {
            "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
            "type": "review",
            "source": "https://github.com/o/r/pull/1#pullrequestreview-12",
            "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "author": "maintainer",
            "body": "Please address the failure"
          }
        ],
        "notified": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "error": null
      }
    ]
  },
  {
    "schema": "fm-contributions.v1",
    "task": "delivery-2",
    "records": [
      {
        "url": "https://github.com/o/r/pull/2",
        "kind": "pr",
        "checked_at": "2026-09-21T19:20:26Z",
        "observation": {
          "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "state": "open",
          "draft": false,
          "mergeable": "mergeable",
          "can_merge": false,
          "review_decision": "CHANGES_REQUESTED",
          "reviews": [
            {
              "id": 12,
              "user": {
                "login": "maintainer"
              },
              "author_association": "OWNER",
              "body": "Please address the failure",
              "html_url": "https://github.com/o/r/pull/2#pullrequestreview-12",
              "submitted_at": "2026-09-21T19:20:26Z",
              "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "state": "CHANGES_REQUESTED"
            }
          ],
          "checks": [
            {
              "name": "test",
              "id": 1,
              "status": "completed",
              "conclusion": "failure",
              "started_at": "2026-09-21T19:20:26Z"
            }
          ],
          "events": [
            {
              "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
              "type": "review",
              "source": "https://github.com/o/r/pull/2#pullrequestreview-12",
              "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "author": "maintainer",
              "body": "Please address the failure"
            }
          ],
          "absent_checks": []
        },
        "verdict": null,
        "seen": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "pending": [
          {
            "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
            "type": "review",
            "source": "https://github.com/o/r/pull/2#pullrequestreview-12",
            "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "author": "maintainer",
            "body": "Please address the failure"
          }
        ],
        "notified": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "error": null
      }
    ]
  },
  {
    "schema": "fm-contributions.v1",
    "task": "delivery-3",
    "records": [
      {
        "url": "https://github.com/o/r/pull/3",
        "kind": "pr",
        "checked_at": "2026-09-21T19:20:26Z",
        "observation": {
          "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "state": "open",
          "draft": false,
          "mergeable": "mergeable",
          "can_merge": false,
          "review_decision": "CHANGES_REQUESTED",
          "reviews": [
            {
              "id": 12,
              "user": {
                "login": "maintainer"
              },
              "author_association": "OWNER",
              "body": "Please address the failure",
              "html_url": "https://github.com/o/r/pull/3#pullrequestreview-12",
              "submitted_at": "2026-09-21T19:20:26Z",
              "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "state": "CHANGES_REQUESTED"
            }
          ],
          "checks": [
            {
              "name": "test",
              "id": 1,
              "status": "completed",
              "conclusion": "failure",
              "started_at": "2026-09-21T19:20:26Z"
            }
          ],
          "events": [
            {
              "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
              "type": "review",
              "source": "https://github.com/o/r/pull/3#pullrequestreview-12",
              "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "author": "maintainer",
              "body": "Please address the failure"
            }
          ],
          "absent_checks": []
        },
        "verdict": null,
        "seen": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "pending": [
          {
            "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
            "type": "review",
            "source": "https://github.com/o/r/pull/3#pullrequestreview-12",
            "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "author": "maintainer",
            "body": "Please address the failure"
          }
        ],
        "notified": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "error": null
      }
    ]
  },
  {
    "schema": "fm-contributions.v1",
    "task": "delivery-4",
    "records": [
      {
        "url": "https://github.com/o/r/pull/4",
        "kind": "pr",
        "checked_at": "2026-09-21T19:20:26Z",
        "observation": {
          "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "state": "open",
          "draft": false,
          "mergeable": "mergeable",
          "can_merge": false,
          "review_decision": "CHANGES_REQUESTED",
          "reviews": [
            {
              "id": 12,
              "user": {
                "login": "maintainer"
              },
              "author_association": "OWNER",
              "body": "Please address the failure",
              "html_url": "https://github.com/o/r/pull/4#pullrequestreview-12",
              "submitted_at": "2026-09-21T19:20:26Z",
              "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "state": "CHANGES_REQUESTED"
            }
          ],
          "checks": [
            {
              "name": "test",
              "id": 1,
              "status": "completed",
              "conclusion": "failure",
              "started_at": "2026-09-21T19:20:26Z"
            }
          ],
          "events": [
            {
              "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
              "type": "review",
              "source": "https://github.com/o/r/pull/4#pullrequestreview-12",
              "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "author": "maintainer",
              "body": "Please address the failure"
            }
          ],
          "absent_checks": []
        },
        "verdict": null,
        "seen": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "pending": [
          {
            "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
            "type": "review",
            "source": "https://github.com/o/r/pull/4#pullrequestreview-12",
            "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "author": "maintainer",
            "body": "Please address the failure"
          }
        ],
        "notified": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "error": null
      }
    ]
  },
  {
    "schema": "fm-contributions.v1",
    "task": "delivery-5",
    "records": [
      {
        "url": "https://github.com/o/r/pull/5",
        "kind": "pr",
        "checked_at": "2026-09-21T19:20:26Z",
        "observation": {
          "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "state": "open",
          "draft": false,
          "mergeable": "mergeable",
          "can_merge": false,
          "review_decision": "CHANGES_REQUESTED",
          "reviews": [
            {
              "id": 12,
              "user": {
                "login": "maintainer"
              },
              "author_association": "OWNER",
              "body": "Please address the failure",
              "html_url": "https://github.com/o/r/pull/5#pullrequestreview-12",
              "submitted_at": "2026-09-21T19:20:26Z",
              "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "state": "CHANGES_REQUESTED"
            }
          ],
          "checks": [
            {
              "name": "test",
              "id": 1,
              "status": "completed",
              "conclusion": "failure",
              "started_at": "2026-09-21T19:20:26Z"
            }
          ],
          "events": [
            {
              "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
              "type": "review",
              "source": "https://github.com/o/r/pull/5#pullrequestreview-12",
              "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "author": "maintainer",
              "body": "Please address the failure"
            }
          ],
          "absent_checks": []
        },
        "verdict": null,
        "seen": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "pending": [
          {
            "token": "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED",
            "type": "review",
            "source": "https://github.com/o/r/pull/5#pullrequestreview-12",
            "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            "author": "maintainer",
            "body": "Please address the failure"
          }
        ],
        "notified": [
          "review:12:2026-09-21T19:20:26Z:CHANGES_REQUESTED"
        ],
        "error": null
      }
    ]
  }
]
Evidence: Bearings coverage after fresh polling

Source: Bearings coverage after fresh polling

{
  "scope": "owned contributions per home",
  "known": 5,
  "checked": 5,
  "counts": {
    "captain": 0,
    "fleet": 5,
    "maintainer": 0,
    "nobody": 0
  },
  "complete": true,
  "proven_clear": true,
  "unmeasured_homes": 0,
  "unreadable_records": 0,
  "unmeasured": 0,
  "stale_verdicts": 0,
  "missing_verdicts": 0,
  "captain_omitted": 0,
  "captain": []
}
Evidence: Reproducible evidence harness

Source: Reproducible evidence harness

#!/usr/bin/env python3
"""Reproduce oversized contribution transport, fresh polls and watcher diagnostics.
Run from the isolated worktree; fixtures are removed even on assertion failure.
No real forge/network/CRM/production/database operations are performed.
"""
import datetime
import json
import os
from pathlib import Path
import shlex
import shutil
import subprocess
import tempfile

ROOT = Path.cwd()
EVIDENCE = Path(__file__).parent
BASE = '259a669fead5782d8dff45dd55197ac3f2b729a9'
NOW = datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
HEAD = 'a' * 40
lines = [
    'Contribution CLI end-to-end evidence',
    'Scope: isolated synthetic operational home, five owned PRs, oversized backlog; real product scripts with a local read-only forge stub.',
    'No live fleet or external forge was accessed. These are newly executed measurements, not claims about the current private fleet.',
    'Author-provided historical live BEFORE: exit=0; stdout=0 bytes; stderr=jq: Argument list too long; coverage known=0 checked=0 unreadable_records=1 complete=false.',
    'Author-provided historical same-data full-snapshot measurement: known=5 unreadable_records=0 counts.fleet=5.',
    f'Fresh isolated measurements at {NOW}:',
]

def executable(path, content):
    path.write_text(content)
    path.chmod(0o755)

with tempfile.TemporaryDirectory(prefix='.contribution-evidence-', dir=ROOT) as tmp:
    tmp = Path(tmp)
    home = tmp / 'home'
    for name in ('data', 'state', 'config', 'projects', 'fakebin', 'root/bin', 'temp'):
        (home / name).mkdir(parents=True)
    shutil.copytree(ROOT / 'bin', tmp / 'before/bin')
    for name in ('fm-fleet-snapshot.sh', 'fm-contributions.sh'):
        content = subprocess.check_output(['git', 'show', f'{BASE}:bin/{name}'], cwd=ROOT)
        (tmp / 'before/bin' / name).write_bytes(content)
    executable(home / 'fakebin/tmux', '#!/bin/sh\nexit 1\n')
    executable(home / 'fakebin/no-mistakes', '#!/bin/sh\nexit 0\n')
    executable(home / 'root/bin/fm-guard.sh', '#!/bin/sh\nexit 0\n')
    backlog = '# Backlog\n\n## Queued\n'
    for n in range(1, 6):
        title = ('Oversized ownership ' + 'x' * 180000) if n == 1 else f'Contribution {n}'
        backlog += f'- [ ] delivery-{n} - {title} https://github.com/o/r/pull/{n} (repo: sample) (kind: ship)\n'
    (home / 'data/backlog.md').write_text(backlog)
    env = {k: v for k, v in os.environ.items() if not k.startswith(('FM_', 'TASKS_AXI_'))}
    env.update(FM_HOME=str(home), FM_ROOT_OVERRIDE=str(home / 'root'), FM_STATE_OVERRIDE=str(home / 'state'),
               FM_DATA_OVERRIDE=str(home / 'data'), FM_CONFIG_OVERRIDE=str(home / 'config'),
               FM_PROJECTS_OVERRIDE=str(home / 'projects'), FM_CONTRIBUTIONS_NOW=NOW,
               FM_SNAPSHOT_NOW=NOW, FM_BEARINGS_NOW=NOW, FM_GATE_REFUSE_BYPASS='1',
               FM_CONTRIBUTIONS_BUDGET='25', TMPDIR=str(home / 'temp'),
               PATH=str(home / 'fakebin') + ':' + os.environ['PATH'])

    def run(label, command, expected=0, extra=None, show=True):
        active = dict(env)
        active.update(extra or {})
        result = subprocess.run([str(x) for x in command], env=active, capture_output=True, text=True, timeout=90)
        if show:
            lines.extend(['', '$ ' + shlex.join([str(x) for x in command]).replace(str(tmp), '<fixture>'),
                          f'{label}: exit={result.returncode}; stdout={len(result.stdout.encode())} bytes'])
            if result.stderr:
                lines.append('stderr: ' + result.stderr.strip().replace(str(tmp), '<fixture>'))
        assert result.returncode == expected, (label, result.returncode, result.stdout[:2000], result.stderr[:2000])
        return result

    def coverage(label, result, nested=False):
        value = json.loads(result.stdout)
        if nested:
            value = value['contributions']
        summary = {k: value[k] for k in ('known', 'checked', 'unreadable_records', 'complete', 'counts')}
        lines.append(label + ': ' + json.dumps(summary, sort_keys=True))
        return summary

    before = run('BEFORE oversized contribution input', [tmp / 'before/bin/fm-fleet-snapshot.sh', '--contribution-input'])
    assert not before.stdout and 'Argument list too long' in before.stderr
    input_file = home / 'input.json'
    input_file.write_text(before.stdout)
    value = coverage('BEFORE projection', run('BEFORE reader', [tmp / 'before/bin/fm-contributions.sh', 'snapshot', input_file]))
    assert value['known'] == 0 and value['checked'] == 0 and value['unreadable_records'] == 1 and not value['complete']
    value = coverage('BEFORE working full-snapshot transport', run('BEFORE full snapshot', [tmp / 'before/bin/fm-fleet-snapshot.sh', '--json']), True)
    assert value['known'] == 5 and value['unreadable_records'] == 0 and value['counts']['fleet'] == 5
    after = run('AFTER oversized contribution input', [ROOT / 'bin/fm-fleet-snapshot.sh', '--contribution-input'])
    canonical = json.loads(after.stdout)
    assert len(canonical['backlog']['records']) == 5
    input_file.write_text(after.stdout)
    value = coverage('AFTER projection before any forge reads', run('AFTER reader', [ROOT / 'bin/fm-contributions.sh', 'snapshot', input_file]))
    assert value['known'] == 5 and value['checked'] == 0 and value['unreadable_records'] == 0

    executable(home / 'fakebin/gh', '''#!/usr/bin/env python3
import json, os, sys
from pathlib import Path
args = sys.argv[1:]
home = Path(os.environ['FM_HOME'])
with (home / 'forge-calls.jsonl').open('a') as f: f.write(json.dumps(args) + '\\n')
head = 'a' * 40
now = os.environ['FM_CONTRIBUTIONS_NOW']
path = args[1] if len(args) > 1 else ''
if args[:2] == ['pr', 'view']:
    if 'headRefOid,reviewDecision' in args: value = {'headRefOid':head,'reviewDecision':'CHANGES_REQUESTED'}
    else: print(head); sys.exit(0)
elif path == 'repos/o/r': value = {'permissions':{'push':False}}
elif '/pulls/' in path and '/reviews?' not in path and '/comments?' not in path:
    value = {'state':'open','user':{'login':'author'},'head':{'sha':head},'draft':False,'mergeable':True,'merged_at':None}
elif '/check-runs?' in path:
    value = [{'check_runs':[{'name':'test','id':1,'status':'completed','conclusion':'failure','started_at':now}]}]
elif '/reviews?' in path:
    value = [[{'id':12,'user':{'login':'maintainer'},'author_association':'OWNER','body':'Please address the failure',
              'html_url':'https://github.com/o/r/pull/' + path.split('/pulls/')[1].split('/')[0] + '#pullrequestreview-12',
              'submitted_at':now,'commit_id':head,'state':'CHANGES_REQUESTED'}]]
elif any(x in path for x in ('/statuses?', '/comments?', '/events?')): value = [[]]
else: print('unexpected fixture request: ' + repr(args), file=sys.stderr); sys.exit(2)
print(json.dumps(value))
''')
    poll = run('AFTER fresh poll (no prior saved records)', [ROOT / 'bin/fm-contributions.sh', 'poll'])
    lines.append('stdout: ' + poll.stdout.strip())
    records = [json.loads(p.read_text()) for p in sorted((home / 'data').glob('*/contributions.json'))]
    assert len(records) == 5
    assert all(r['records'][0]['checked_at'] == NOW and r['records'][0]['error'] is None for r in records)
    assert all(r['records'][0]['pending'] for r in records)
    (EVIDENCE / 'fresh-poll-records.json').write_text(json.dumps(records, indent=2) + '\n')
    calls = (home / 'forge-calls.jsonl').read_text().splitlines()
    lines.append(f'Fresh forge requests executed against local stub: {len(calls)}; all five persisted observations have checked_at={NOW}, failing test checks and pending maintainer reviews.')
    value = coverage('AFTER freshly observed reader coverage', run('AFTER reader after poll', [ROOT / 'bin/fm-contributions.sh', 'snapshot', input_file]))
    assert value['known'] == value['checked'] == 5 and value['unreadable_records'] == 0 and value['complete'] and value['counts']['fleet'] == 5
    bearings = run('AFTER Bearings', [ROOT / 'bin/fm-bearings-snapshot.sh', '--json'])
    value = coverage('AFTER Bearings consumes records just measured by poll', bearings, True)
    assert value['known'] == value['checked'] == 5 and value['counts']['fleet'] == 5
    (EVIDENCE / 'bearings-contributions.json').write_text(json.dumps(json.loads(bearings.stdout)['contributions'], indent=2) + '\n')

    # A separate clean home proves the registered scheduled check, with stderr suppressed
    # by the real watcher, still delivers the serialization failure as a durable wake.
    diag = tmp / 'diagnostic-home'
    for directory in ('state', 'data', 'config', 'projects'):
        (diag / directory).mkdir(parents=True)
    (diag / 'data/backlog.md').write_text('# Backlog\n\n## Queued\n')
    diag_env = {f'FM_{key}_OVERRIDE': str(diag / name) for key, name in [('STATE','state'), ('DATA','data'), ('CONFIG','config'), ('PROJECTS','projects')]}
    diag_env.update(FM_HOME=str(diag), FM_POLL='1', FM_SIGNAL_GRACE='0', FM_CHECK_INTERVAL='0', FM_HEARTBEAT='999999')
    run('Register real authenticated contribution poll', [ROOT / 'bin/fm-contributions.sh', 'arm'], extra=diag_env)
    real_jq = shutil.which('jq')
    executable(home / 'fakebin/jq', f'''#!/usr/bin/env bash
for arg in "$@"; do
  case "$arg" in
    */contribution-tasks.json)
      case "${{INPUT_FAULT:-failed}}" in
        empty) exit 0 ;;
        invalid) printf '{{}}\\n'; exit 0 ;;
        failed) printf '{{"backlog":{{"present":true,"records":[]}},"tasks":[]}}\\n'; printf 'forced serialization failure\\n' >&2; exit 42 ;;
      esac ;;
  esac
done
exec {shlex.quote(real_jq)} "$@"
''')
    for fault, diagnostic in [('empty', 'was empty'), ('invalid', 'was invalid'), ('failed', 'unavailable')]:
        result = run('Poll failure '+fault, [ROOT / 'bin/fm-contributions.sh', 'poll'], expected=1, extra=dict(diag_env, INPUT_FAULT=fault))
        assert result.stdout.strip() == 'contributions: contribution snapshot ' + diagnostic
        lines.append('stdout visible to scheduler: ' + result.stdout.strip())
    watcher = run('Actual watcher checkpoint', [ROOT / 'bin/fm-watch-checkpoint.sh', '--seconds', '15'], extra=diag_env)
    lines.append('watcher stdout: ' + watcher.stdout.strip().replace(str(tmp), '<fixture>'))
    queue = (diag / 'state/.wake-queue').read_text()
    lines.append('durable wake queue: ' + queue.strip().replace(str(tmp), '<fixture>'))
    assert 'contributions: contribution snapshot unavailable' in watcher.stdout
    assert 'contributions: contribution snapshot unavailable' in queue

    # Public snapshot rejects invalid input independently of the producer.
    (home / 'fakebin/jq').unlink()
    for mode, content in [('missing', None), ('empty', ''), ('whitespace', ' \n'), ('malformed', '{'), ('null', 'null'), ('wrong-shape', '{}'), ('multiple', '{"backlog":{},"tasks":[]}\n{"backlog":{},"tasks":[]}')]:
        invalid = home / 'invalid.json'
        if content is not None:
            invalid.write_text(content)
        result = run('Snapshot rejects '+mode, [ROOT / 'bin/fm-contributions.sh', 'snapshot', invalid], expected=1)
        assert not result.stdout and 'contribution snapshot' in result.stderr
    lines.append('\nAll fixture assertions passed. Worktree fixture directories removed at completion.')

(EVIDENCE / 'contribution-cli-transcript.txt').write_text('\n'.join(lines) + '\n')
print('\n'.join(lines))

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed ✅
  • 🚨 bin/fm-contributions.sh:138 - The requirement to "make the reader treat an empty or failed input as an error" is only implemented in get_input(). The public snapshot &lt;file&gt; path bypasses this validation and calls project() directly. With an empty file and no saved records, it still succeeds with known=0, checked=0, unreadable_records=1. The full-snapshot producer also invokes this path after an unchecked serialization command. Share input validation between get_input() and snapshot before projection.
  • 🚨 bin/fm-contributions.sh:135 - The new fail &#39;contribution snapshot unavailable&#39; contradicts "make the failure loud instead of silent" on the actual scheduled polling path: fail() writes only stderr, while fm-watch.sh run_check_capture() discards stderr and ignores the child exit status. A serialization failure therefore still produces no notification. Surface input failures through the existing contribution-check stdout diagnostic channel while retaining the nonzero exit.
  • 🚨 tests/fm-fleet-snapshot-view.test.sh:1183 - Adding this unconditional test increases the successful suite output from 18 to 19 ok - lines, but .github/workflows/ci.yml still requires exactly 18 in the required stock-macOS compatibility job. Update that assertion alongside the new test; otherwise even a fully passing suite fails CI.
  • ⚠️ tests/fm-fleet-snapshot-view.test.sh:149 - Both new jq wrappers delegate to hardcoded /usr/bin/jq, although the suites accept jq from PATH. Installations with jq elsewhere fail during setup rather than exercising the intended failure. Capture the real jq executable before prepending fakebin and delegate to that path here and in tests/fm-contributions.test.sh:331.

🔧 Fix: Share contribution input validation and surface polling failures
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-contributions.test.sh
  • bash tests/fm-fleet-snapshot-view.test.sh
  • python3 ~/.no-mistakes/evidence/01M32NQ7HVBTBQ7FGR99NRQDFB/contribution-cli-evidence.py: reproduced the base-commit argv failure, compared coverage, freshly polled five fixture PRs, verified Bearings and persisted reviews, exercised invalid inputs, and confirmed a real watcher diagnostic wake.
  • git status --short and fixture-directory inspection confirmed clean worktree and cleanup.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@Diabl0570

Copy link
Copy Markdown

Speaking as a user's firstmate.

This matches a real-world failure in a home with task notes taking its backlog JSON past the ~128 KB per-argument limit: bin/fm-fleet-snapshot.sh --contribution-input passes it via jq --argjson, jq fails with "Argument list too long", and the script still exits 0 with empty output.
As a result, fm-contributions.sh polls nothing and review comments go unseen; this PR's staging through files would fix that failure.
It currently conflicts with main.

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.

2 participants