Skip to content

feat(bin): add runtime incident fast path - #3183

Closed
campos3097 wants to merge 21 commits into
kunchenguid:mainfrom
campos3097:fm/runtime-incident-fast-path-r1
Closed

campos3097 wants to merge 21 commits into
kunchenguid:mainfrom
campos3097:fm/runtime-incident-fast-path-r1

Conversation

@campos3097

@campos3097 campos3097 commented Aug 27, 2026 •

Copy link
Copy Markdown

Intent

Implement a focused runtime incident fast path in FirstMate from the verified current origin/main baseline without modifying TitanOS or any preserved TitanOS worktree. Before creating branches, clones, worktrees, implementation plans, validation, or release work, classify incident requests into application code defect, deployment or routing defect, external dependency quota billing credential or configuration failure, local background-service failure, or unknown. Run bounded read-only triage first: resolve canonical repository and remote; inventory relevant worktrees, clones, branches, registry entries, and workers with exact directory, objective, age, and incident relevance; detect stale registry paths, superseded continuations, detached checkouts, and duplicate repository copies; inspect production identity, logs, health, provider errors, quotas, and managed services when available; and make no code edits during triage. Emit probable root cause and evidence, authoritative repository or worktree, whether code change is required, unrelated or drifted workers, safest next action, and required approval. If no code change is required, create no worktree and run no code tests, CI, PR, or deployment; request only the narrow operational approval, perform the authorized repair, and verify the full runtime path. If code is proven necessary, use one authoritative current-main continuation, preserve unrelated work, keep origin/main policy authoritative, transfer only incident-related changes, and use normal validation and release. Warn on scope drift and never stop, delete, or rewrite another worker or worktree without explicit authorization. Cover stale registry, duplicate clones with one origin, wrong worker worktree, external quota no-code failure, already-deployed hotfix, and proven code-defect escalation. Expose triage to diagnosis to approval to repair to verification in status and demonstrate simulated quota exhaustion. Keep the conductor redesign focused. User authorized all remaining pipeline gates automatically. Preserve all existing pipeline fixes. Resolve the current Greptile P1 by keeping semantic incident judgment agent-owned: scripts may perform deterministic evidence collection and validation but must not override an agents adjudicated classification, code-change decision, approval requirement, or workflow routing with a fixed category map.

What Changed

  • Add a bounded runtime-incident CLI that inventories repository and worker state, validates agent-adjudicated diagnoses, and records approval, repair, and end-to-end verification.
  • Introduce the runtime incident fast-path skill, including no-code operational routing, proven code-defect escalation, scope-drift safeguards, and agent-owned semantic judgment.
  • Project incident lifecycle state through fleet snapshots, fleet views, and Bearings, with coverage for quota exhaustion, stale or duplicate workspaces, deployed hotfixes, and bounded inventory handling.

Risk Assessment

🚨 High: The change can still falsely clear a stale worker checkout and gives agents an impossible lifecycle instruction for the newly supported approval-free path.

Testing

Baseline inspection confirmed target commit 2b8cd4de47035126029ae3e0043e2c3d79ef9073 and a clean worktree; the focused runtime-incident suite passed, and a fresh-checkout quota-exhaustion simulation demonstrated read-only triage with no new worktree, narrow approval, operational repair, complete runtime verification, and matching human/Bearings status. The first transcript attempt had a zsh/Bash harness mismatch before product execution, then succeeded under Bash; its temporary fixture was removed and the CLI transcript was retained as reviewer-visible evidence.

Evidence: Quota-exhaustion end-to-end CLI transcript

Source: Quota-exhaustion end-to-end CLI transcript

Runtime incident quota-exhaustion end-to-end transcript
=======================================================

[1] Bounded read-only triage
{
  "phase": "approval",
  "outcome": "operational_repair",
  "classification": "external dependency, quota, billing, credential, or configuration failure",
  "probable_root_cause": "Upstash command quota exhaustion is rejecting the companion status path.",
  "code_change_required": "no",
  "approval": {
    "kind": "paid_plan_change",
    "request": "Approve the Upstash plan upgrade only.",
    "required": true,
    "status": "pending"
  },
  "guardrails": {
    "code_validation_allowed": false,
    "new_worktree_allowed": false,
    "other_worker_mutation_authorized": false,
    "project_code_edited_during_triage": false
  },
  "worktree_count_before": 1,
  "worktree_count_after": 1
}

[2] Narrow approval
{
  "phase": "repair",
  "approval": {
    "approved_at": "2026-08-26T20:05:00Z",
    "kind": "paid_plan_change",
    "note": "Approved only the Upstash plan change.",
    "request": "Approve the Upstash plan upgrade only.",
    "required": true,
    "status": "approved"
  },
  "flow": [
    {
      "name": "triage",
      "status": "complete"
    },
    {
      "name": "diagnosis",
      "status": "complete"
    },
    {
      "name": "approval",
      "status": "complete"
    },
    {
      "name": "repair",
      "status": "current"
    },
    {
      "name": "verification",
      "status": "pending"
    }
  ]
}

[3] Operational repair
{
  "phase": "verification",
  "repair": {
    "note": "Upstash plan upgraded and companion re-paired.",
    "recorded_at": "2026-08-26T20:06:00Z",
    "status": "complete"
  },
  "flow": [
    {
      "name": "triage",
      "status": "complete"
    },
    {
      "name": "diagnosis",
      "status": "complete"
    },
    {
      "name": "approval",
      "status": "complete"
    },
    {
      "name": "repair",
      "status": "complete"
    },
    {
      "name": "verification",
      "status": "current"
    }
  ]
}

[4] Full runtime-path verification
{
  "phase": "verification",
  "verification": {
    "checks": [
      {
        "evidence": "expected release",
        "name": "production identity",
        "scope": "production_identity",
        "status": "pass"
      },
      {
        "evidence": "commands accepted",
        "name": "upstash quota",
        "scope": "repaired_component_health",
        "status": "healthy"
      },
      {
        "evidence": "paired",
        "name": "companion pairing",
        "scope": "companion_connectivity",
        "status": "pass"
      },
      {
        "evidence": "state visible",
        "name": "user status path",
        "scope": "user_visible_path",
        "status": "pass"
      }
    ],
    "inventory": {
      "checks": {
        "omitted": 0,
        "shown": 4
      }
    },
    "recorded_at": "2026-08-26T20:07:00Z",
    "status": "complete"
  },
  "flow": [
    {
      "name": "triage",
      "status": "complete"
    },
    {
      "name": "diagnosis",
      "status": "complete"
    },
    {
      "name": "approval",
      "status": "complete"
    },
    {
      "name": "repair",
      "status": "complete"
    },
    {
      "name": "verification",
      "status": "complete"
    }
  ]
}

[5] Human status surface
Incident: quota-demo - Titan companion cannot read state
Flow: triage → diagnosis → approval → repair → verification
Current: verification
Classification: external dependency, quota, billing, credential, or configuration failure
Probable root cause: Upstash command quota exhaustion is rejecting the companion status path.
Authoritative repository: /private/var/folders/6z/tffgdwn5753b0dhcv4fwhq6m0000gn/T/runtime-incident-e2e.bN3UTU/home/projects/titan
Authoritative working copy: /private/var/folders/6z/tffgdwn5753b0dhcv4fwhq6m0000gn/T/runtime-incident-e2e.bN3UTU/home/projects/titan
Code change required: no
Unrelated or scope-drifted workers: 0
Workers omitted by bound: 0
Registered worker metadata omitted by repository scan: 0
Candidate worktrees omitted by repository scan: 0
Worktrees omitted by repository scan: 0
Project directories omitted by repository scan: 0
Scanned repositories omitted: at least 0
Scan entries visited: 0
Scan roots truncated by entry bound: 0
Repository candidates omitted by bound: 0
Branches omitted by bound: at least 0
Evidence items omitted by aggregate bounds: 0
Verification checks omitted by aggregate bounds: 0
Safest next action: Incident verification is complete; close the incident without code, release, or unrelated cleanup.
Approval required: paid_plan_change

[6] Bearings projection
{
  "id": "quota-demo",
  "phase": "verification",
  "classification": "external dependency, quota, billing, credential, or configuration failure",
  "code_change_required": "no",
  "approval": "approved",
  "safest_next_action": "Incident verification is complete; close the incident without code, release, or unrelated cleanup.",
  "flow": "triage:complete → diagnosis:complete → approval:complete → repair:complete → verification:complete",
  "verification": "complete"
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 errors
  • 🚨 bin/fm-runtime-incident.py:905 - Intent requires scripts to “not override an agents adjudicated classification, code-change decision, approval requirement, or workflow routing with a fixed category map.” This code derives code_change_required from DIAGNOSIS_CODE_REQUIREMENT and rejects the agent’s supplied decision; it likewise ignores an agent-supplied approval.required:false and silently emits true for every actionable no-code category. Accept independently adjudicated decision/approval fields at this boundary and limit deterministic validation to types, evidence, and authority invariants.
  • 🚨 bin/fm-runtime-incident.py:769 - Candidate capping can silently mark a shown stale worker as correctly placed. With the canonical checkout plus 64 candidate paths, one registered worker path falls outside repo_info.copies; although collect_workers probes that checkout, registered_copy is absent, so stale_path remains false and the row reports repository_match:true and wrong_worktree:false based only on matching origin. Compare cwd_record against the authoritative remote head at this boundary, or report placement as unknown when the candidate was omitted.

🔧 Fix: Honor agent routing and reconcile capped workers
2 errors still open:

  • 🚨 bin/fm-runtime-incident.py:772 - A capped worker checkout is still reported as correctly placed when its origin/main matches authority but its actual checkout is stale. With 64 earlier candidates, a worker clone detached at an old HEAD is absent from repo_info.copies; this branch compares only remote_default_head, leaves the earlier wrong_worktree:false unchanged, and omits the worker from stale/wrong-worktree lists. Reconcile cwd_record.head/detached state here, or report placement as unknown unless it is positively verified.
  • 🚨 .agents/skills/runtime-incident-fast-path/SKILL.md:47 - The accepted approval-free route is contradicted by the runtime skill: triage can now emit approval.required:false and phase repair, while these instructions unconditionally tell the agent to request approval and invoke approve, which necessarily refuses that record. Branch the instructions on approval.required, using approve only when true and proceeding directly to the adjudicated repair when false.
✅ **Test** - passed

✅ No issues found.

  • git status --short && git rev-parse --show-toplevel && git rev-parse HEAD
  • git diff --stat 7ee0c192e9d664b022361bd4609303bebfc7de14..2b8cd4de47035126029ae3e0043e2c3d79ef9073 and changed-file inspection
  • tests/fm-runtime-incident.test.sh
  • Fresh-repository CLI lifecycle: fm-runtime-incident.py triage → approve → repair → verify → human status → fm-bearings-snapshot.sh --json
  • Final git status --short, evidence readability, and temporary-fixture cleanup checks
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Confirm clean lint with pinned toolchain
1 warning still open:

  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (8): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile

Comment thread bin/fm-runtime-incident.py Resolved
Comment thread bin/fm-runtime-incident.py Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Reviewed HEAD 9c14dc1ffee4e9f96674b2b0c0dc65e02b7d2c33 vs main 7ee0c192e9d664b022361bd4609303bebfc7de14. Whole thread read. Full diff reviewed: bin/fm-runtime-incident.py, fleet/bearings snapshot wiring, the new skill, docs, fixture, and tests/fm-runtime-incident.test.sh. No .github/workflows/*. Not disguised security. campos3097 is not blocked.

Class: default-behavior. The new skill auto-loads at the first runtime-incident report (user-invocable: false), and runtime_incidents is projected into fleet snapshots, fleet view, and Bearings with no opt-in. Default-behavior does not auto-merge.

VISION (per rule, inspected evidence):

  • One captain, one interface — mixed. Putting a pending operational approval in Captain's Call can be honest, but a new always-on incident ledger in every snapshot adds machinery the captain did not ask to see.
  • Authority is explicit — does not align. DIAGNOSIS_CODE_REQUIREMENT in bin/fm-runtime-incident.py maps a classification string to code_change_required and then to workflow routing (operational_repair_ready, escalate_to_code_change). Evidence is not authorization; a script must not infer the workflow from a category label.
  • Scripts own the mechanics — does not align. The skill text says the agent adjudicates diagnosis, but the script rejects an agent diagnosis whose code_change_required does not match the category map. That is the script adjudicating meaning. Greptile's remaining objection matches this inspected map.
  • A restart is a non-event — aligns. Ledger is a durable local record.
  • Delegation with a spine — cannot tell / weak. Scout vs ship is not the contract here; the new lifecycle invents a parallel incident workshop.
  • The fleet outlives any vendor — mixed. Provider evidence is generic, but the fixture and skill are Upstash/Titan-shaped.
  • Scope — does not align. This grows the command layer into incident classification, approval, repair, and verification — workshop work, not the layer between intent and agents.

Author's own risk assessment on the PR is High. That matches the inspected map.

Attestation: no-mistakes-pipeline-attestation:v1 head_sha e0866340a294f91e879c6b92f09e669e916c75ca does not match this HEAD (9c14dc1ffee4…, later no-mistakes: apply CI fixes commits).

First-time fork CI: after that full-diff review I approved workflow runs 33102612943 (CI) and 33102612900 (Require no-mistakes) for this HEAD. Subprocess use is git -C plus fm-crew-state.sh (or test-injected FM_CREW_STATE_BIN), bounded by timeout — not a GitHub workflow RCE.

This is waiting on the author, not the captain: keep diagnosis and workflow authority agent-adjudicated (the script may validate schema and record transitions, not map classification → code-change/approval routing); do not ship this as a default Bearings/fleet surface (opt-in if it returns); push an attestation whose head_sha matches HEAD. Merge-eligible: NO.

@campos3097
campos3097 force-pushed the fm/runtime-incident-fast-path-r1 branch from 9c14dc1 to 2b8cd4d Compare August 27, 2026 18:37
Comment on lines +953 to +956
if diagnosis_input is not None and operational_repair_ready:
if type(approval_required_input) is not bool:
raise IncidentError("a no-code diagnosis requires boolean approval.required")
approval_required = approval_required_input

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Approval gate is bypassed

When a no-code diagnosis supplies approval.required: false, triage accepts that value and starts the incident directly in repair, allowing the operational workflow to advance to verification without the captain approval required by the documented no-code path.

Context Used: If there is a VISION.md file at the root of the re... (source)

Comment thread bin/fm-runtime-incident.py Resolved
Comment thread bin/fm-runtime-incident.py Resolved
@campos3097 campos3097 closed this Aug 27, 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.

2 participants