Skip to content

feat(bin): add captain queue, blocked, and rigs API reads - #39

Merged
EvanAgee merged 2 commits into
mainfrom
fm/fm-30-queue-reads
Aug 26, 2026
Merged

EvanAgee merged 2 commits into
mainfrom
fm/fm-30-queue-reads

Conversation

@EvanAgee

@EvanAgee EvanAgee commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

Intent

Build firstmate issue #30 (EvanAgee/firstmate): the rest of the read windows, queue, blocked, and rig (API ticket 4).

Read issue #30 in full. Parent spec is #26. The #27 front door is already merged; plug into that API shape.

What to build: the remaining reads. GET captain queue of parked decisions, GET blocked list, and GET rig ladders with their rungs. With these, every read the captain dashboard performs has an API answer.

Acceptance:

  • GET captain queue returns the fixture parked decisions
  • GET blocked list returns the fixture blocked tasks
  • GET rigs returns ladders, rungs, and each rung enabled state
  • Each JSON contract is documented on its endpoint

Constraints from #26 and #27:

  • Node built-ins only, no new dependencies
  • Tests speak real HTTP against a throwaway firstmate home on an ephemeral port, under the repo normal test entry point
  • Each read assembles its answer through firstmate existing scripts and files so the API is the single holder of file-format knowledge
  • Endpoint and JSON naming use CONTEXT.md glossary words: parked decision, blocked, rig, rung
  • Bind localhost only; reads need no auth
  • Empty home answers with empty collections, not an error

This is firstmate shared tracked material. Follow firstmate-coding-guidelines: one-owner contracts, knowledge placement, one sentence per line in Markdown, plain dash, no agent co-author, shellcheck-clean bin scripts, colocated tests/.test.sh. Tests must exercise behavior through an executable or public interface and must never assert implementation-source bytes.

Gates are bash tests, not npm. Do not use the repo GATE_* npm/vitest lines.

What Changed

  • Add GET /captain-queue, GET /blocked, and GET /rigs on the localhost API, assembled from scan_open_decisions and config/crew-dispatch.json so empty homes return empty collections.
  • Document each endpoint's JSON contract on bin/fm-api-server.mjs and note the new reads in architecture and configuration docs.
  • Exercise the three windows over real HTTP against a throwaway home, and wire fm-api-reads into the session-bootstrap test family.

Risk Assessment

✅ Low: The three reads are small, follow the existing classify fold and dispatch file, and empty homes already return empty lists.

Testing

Ran the colocated bash HTTP suite, then started empty and fixture throwaway homes and captured live GET /captain-queue, /blocked, and /rigs. Empty home returned empty collections; the fixture home returned the parked decision, blocked task, and rig ladders with each rung enabled state; a non-loopback address was refused. These are JSON API windows, so evidence is HTTP transcripts rather than screenshots.

Evidence: Live HTTP from fixture home: captain queue, blocked list, and rigs

Source: Live HTTP from fixture home: captain queue, blocked list, and rigs

=== fixture home start ===
api: started pid=63808 port=49781 home=/tmp/fm-api-reads-evidence.qFQAxA/fixture-home
bound port: 49781

=== GET /captain-queue ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 113
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"decisions":[{"task":"ask-me","key":"api-shape","summary":"which JSON shape should the queue use?"}]}

=== GET /blocked ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 99
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"blocked":[{"task":"stuck-task","key":"missing-tool","summary":"jq is not installed"}]}

=== GET /rigs ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 319
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"rigs":[{"name":"The task is a builder assignment.","rungs":[{"harness":"codex","model":"gpt-5.6-sol","effort":"high","enabled":true},{"harness":"grok","model":"grok-4","effort":"high","enabled":false}]},{"name":"default","rungs":[{"harness":"pi","model":"xai/grok-4.6","effort":"medium","enabled":true}]}]}
Evidence: Pretty JSON bodies for the three dashboard reads

Source: Pretty JSON bodies for the three dashboard reads

{
  "/captain-queue": {
    "status": 200,
    "json": {
      "ok": true,
      "decisions": [
        {
          "task": "ask-me",
          "key": "api-shape",
          "summary": "which JSON shape should the queue use?"
        }
      ]
    }
  },
  "/blocked": {
    "status": 200,
    "json": {
      "ok": true,
      "blocked": [
        {
          "task": "stuck-task",
          "key": "missing-tool",
          "summary": "jq is not installed"
        }
      ]
    }
  },
  "/rigs": {
    "status": 200,
    "json": {
      "ok": true,
      "rigs": [
        {
          "name": "The task is a builder assignment.",
          "rungs": [
            {
              "harness": "codex",
              "model": "gpt-5.6-sol",
              "effort": "high",
              "enabled": true
            },
            {
              "harness": "grok",
              "model": "grok-4",
              "effort": "high",
              "enabled": false
            }
          ]
        },
        {
          "name": "default",
          "rungs": [
            {
              "harness": "pi",
              "model": "xai/grok-4.6",
              "effort": "medium",
              "enabled": true
            }
          ]
        }
      ]
    }
  }
}
Evidence: Empty home returns empty collections, not errors

Source: Empty home returns empty collections, not errors

=== empty home start ===
api: started pid=63446 port=49778 home=/tmp/fm-api-reads-evidence.qFQAxA/empty-home
bound port: 49778

=== GET /captain-queue (empty home) ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 27
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"decisions":[]}

=== GET /blocked (empty home) ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 25
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"blocked":[]}

=== GET /rigs (empty home) ===
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 22
date: Wed, 26 Aug 2026 11:16:47 GMT
connection: keep-alive
keep-alive: timeout=5

{"ok":true,"rigs":[]}
Evidence: Localhost bind: 127.0.0.1 HTTP 200, LAN IPv4 ECONNREFUSED

Source: Localhost bind: 127.0.0.1 HTTP 200, LAN IPv4 ECONNREFUSED

127.0.0.1 -> HTTP 200
192.168.68.63 -> ECONNREFUSED
Evidence: JSON contracts documented on each endpoint

Source: JSON contracts documented on each endpoint

// GET /health
//   { ok, version, home }
// GET /captain-queue
//   { ok, decisions: [{ task, key, summary }] }
//   Parked decisions still open in this home. Empty home: decisions is [].
// GET /blocked
//   { ok, blocked: [{ task, key, summary }] }
//   Blocked tasks still open in this home. Empty home: blocked is [].
// GET /rigs
//   { ok, rigs: [{ name, rungs: [{ harness, model, effort, enabled }] }] }
//   Dispatch ladders and each rung's enabled state. Missing config: rigs is [].

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bin/fm-test-run.sh tests/fm-api-reads.test.sh
  • manual fm-api.sh start on empty throwaway home, then GET /captain-queue, /blocked, /rigs
  • manual fm-api.sh start on fixture home with parked decision, blocked task, and crew-dispatch.json, then GET /captain-queue, /blocked, /rigs
  • bind check: GET /captain-queue on 127.0.0.1 vs non-loopback IPv4
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by CodeRabbit

New Features

  • Added local API endpoints for:
    • Captain decision queues
    • Blocked tasks
    • Configured rig ladders
  • Endpoints support both GET and HEAD requests with structured JSON responses.
  • Rig configurations now include harness, model, effort, and enabled status.

Bug Fixes

  • Improved handling of missing configuration files and unexpected server errors.

Documentation

  • Documented the new API endpoints and their response contracts.

Add GET /captain-queue, GET /blocked, and GET /rigs so every dashboard
read has an API answer. Parked decisions and blocked tasks come from
the open-decision fold. Rigs come from crew-dispatch.json.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e79d68c2-cd8d-4c6e-815d-9f20fb394244

📥 Commits

Reviewing files that changed from the base of the PR and between 08a2b6d and 67b467a.

📒 Files selected for processing (7)
  • bin/fm-api-reads.mjs
  • bin/fm-api-server.mjs
  • bin/fm-test-run.sh
  • docs/architecture.md
  • docs/configuration.md
  • tests/api-helpers.sh
  • tests/fm-api-reads.test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Added readers for decision and rig data, exposed /captain-queue, /blocked, and /rigs, updated server error handling, and added HTTP tests and documentation.

Changes

API read endpoints

Layer / File(s) Summary
Read response assembly
bin/fm-api-reads.mjs
Scans decision state, filters captain and blocked entries, and normalizes rig configuration into API response bodies.
HTTP route integration
bin/fm-api-server.mjs
Adds the three read routes, supports GET and HEAD, passes the state directory, and returns structured 500 errors for configuration or handler failures.
Endpoint validation and documentation
tests/api-helpers.sh, tests/fm-api-reads.test.sh, bin/fm-test-run.sh, docs/architecture.md, docs/configuration.md
Adds JSON test helpers, HTTP coverage for decision and rig reads, test-family mappings, and endpoint ownership documentation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 67b46

The PR adds three localized read-only API endpoints with documented JSON contracts and verified empty and fixture responses, so no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: kunchenguid

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant API as bin/fm-api-server.mjs
  participant Readers as bin/fm-api-reads.mjs
  participant State as state files
  participant Config as config/crew-dispatch.json

  Client->>API: GET read endpoint
  API->>Readers: Build response body
  Readers->>State: Scan decision statuses
  State-->>Readers: Decision rows
  Readers->>Config: Read rig configuration
  Config-->>Readers: Rig ladders
  Readers-->>API: JSON response body
  API-->>Client: HTTP response
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 5 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the three primary API read endpoints added by the pull request: captain queue, blocked tasks, and rigs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fm/fm-30-queue-reads

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EvanAgee EvanAgee added the agent-pr-watched An agent merge watch is armed on this PR label Aug 26, 2026
@EvanAgee
EvanAgee merged commit 5675248 into main Aug 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr-watched An agent merge watch is armed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant