record-run-result never stamps attempts.started_at/ended_at — per-iteration durations are unrecoverable #95

Closed
opened 2026-08-26 03:02:27 +00:00 by matou-build-agent · 4 comments

From the 2026-08-25 observability review.

Symptom. attempts has started_at/ended_at columns and swarm-db.py's attempt subcommand accepts --started/--ended, but record-run-result.sh passes neither: started_at stays NULL and ended_at is only set en masse by the run-end finaliser. "How long did issue N iteration K take" cannot be answered from the db — only whole-run duration exists.

Direction. Sandcastle's RunResult iterations carry timing (or it is derivable from the per-iteration session files' first/last message timestamps); thread it through record-run-result.sh into --started/--ended per attempt. Keep invariant 2 (kills-finalise) intact for crashed runs.

Same commit: tests/record-run-result coverage per CLAUDE.md.

From the 2026-08-25 observability review. **Symptom.** `attempts` has `started_at`/`ended_at` columns and `swarm-db.py`'s `attempt` subcommand accepts `--started`/`--ended`, but `record-run-result.sh` passes neither: `started_at` stays NULL and `ended_at` is only set en masse by the run-end finaliser. "How long did issue N iteration K take" cannot be answered from the db — only whole-run duration exists. **Direction.** Sandcastle's RunResult iterations carry timing (or it is derivable from the per-iteration session files' first/last message timestamps); thread it through `record-run-result.sh` into `--started`/`--ended` per attempt. Keep invariant 2 (kills-finalise) intact for crashed runs. Same commit: `tests/record-run-result` coverage per CLAUDE.md.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.
Ruling: ready-for-agent. Two-way door — populates existing, already-migrated columns (attempts.started_at/ended_at) that are currently just left NULL; revertible, provable by tests/record-run-result coverage.

Agent Brief

Category: enhancement
Summary: record-run-result.sh should stamp attempts.started_at/ended_at per iteration.

Current behavior:
attempts already has started_at/ended_at columns and swarm-db.py's attempt subcommand already accepts --started/--ended, but record-run-result.sh passes neither. started_at stays NULL; ended_at is only set en masse by the run-end finaliser. Per-iteration duration cannot be recovered from the db today.

Desired behavior:
Each iteration's real start/end timestamps — from Sandcastle's RunResult iteration timing if available, otherwise derived from the per-iteration session file's first/last message timestamps — are threaded into the swarmdb attempt call's --started/--ended.

Key interfaces:

  • The RunResult iteration usage block already parsed in record-run-result.sh.
  • swarm-db.py's existing attempt subcommand flags (no schema change needed).
  • The kills-finalise invariant: a crashed/killed run's open attempts must still be closed en masse by the existing finaliser — this ticket only adds timestamps when known, it must not weaken that path.

Acceptance criteria:

  • Each recorded attempt has a non-NULL started_at when timing is available
  • ended_at is set from the real iteration end when available, not left to the mass finaliser alone
  • A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged
  • tests/record-run-result coverage updated

Out of scope:

  • Backfilling historical rows
  • Changing kills-finalise semantics itself
> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** Ruling: `ready-for-agent`. Two-way door — populates existing, already-migrated columns (`attempts.started_at`/`ended_at`) that are currently just left NULL; revertible, provable by `tests/record-run-result` coverage. ## Agent Brief **Category:** enhancement **Summary:** `record-run-result.sh` should stamp `attempts.started_at`/`ended_at` per iteration. **Current behavior:** `attempts` already has `started_at`/`ended_at` columns and swarm-db.py's `attempt` subcommand already accepts `--started`/`--ended`, but `record-run-result.sh` passes neither. `started_at` stays NULL; `ended_at` is only set en masse by the run-end finaliser. Per-iteration duration cannot be recovered from the db today. **Desired behavior:** Each iteration's real start/end timestamps — from Sandcastle's RunResult iteration timing if available, otherwise derived from the per-iteration session file's first/last message timestamps — are threaded into the `swarmdb attempt` call's `--started`/`--ended`. **Key interfaces:** - The RunResult iteration usage block already parsed in `record-run-result.sh`. - swarm-db.py's existing `attempt` subcommand flags (no schema change needed). - The kills-finalise invariant: a crashed/killed run's open attempts must still be closed en masse by the existing finaliser — this ticket only adds timestamps when known, it must not weaken that path. **Acceptance criteria:** - [ ] Each recorded attempt has a non-NULL `started_at` when timing is available - [ ] `ended_at` is set from the real iteration end when available, not left to the mass finaliser alone - [ ] A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged - [ ] `tests/record-run-result` coverage updated **Out of scope:** - Backfilling historical rows - Changing kills-finalise semantics itself
Author
Member

swarm-claim host=matou-dev-server-01 run=1160
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=1160 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #95 — status success

⛔ close-report gates REFUSED this close — the following claims did not verify:

  • commit 7c628c8d82 is not reachable from origin/main (not landed)
  • changed_files: 'record-run-result.sh' is not in the diff of the claimed commits
  • changed_files: 'tests/record-run-result-test.sh' is not in the diff of the claimed commits
  • changed_files: 'STATUS.md' is not in the diff of the claimed commits
envelope
{
  "issue": 95,
  "status": "success",
  "commits": [
    "7c628c8d8229ff82fbe9bcbfcac239437c2dbab7"
  ],
  "changed_files": [
    "record-run-result.sh",
    "tests/record-run-result-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/record-run-result-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Each recorded attempt has a non-NULL started_at when timing is available": "record-run-result.sh iter_time_bounds derives the first message timestamp and passes --started; tests/record-run-result-test.sh RUN95 asserts started_at == session first timestamp",
    "ended_at is set from the real iteration end when available, not left to the mass finaliser alone": "attempt writer passes --ended from the last message timestamp; RUN95 asserts ended_at == session last timestamp",
    "A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged": "RUN95B (no readable session file) leaves ended_at NULL, then db run-end closes it to 1790000000 — invariant 2 intact; swarm-db.py cmd_run_end unchanged",
    "tests/record-run-result coverage updated": "two new groups added (11 groups pass); full offline suite green"
  },
  "summary": "record-run-result.sh now stamps per-iteration attempts.started_at/ended_at from the session jsonl's first/last message timestamps, keeping the kills-finalise fallback.",
  "blockers": []
}
**close-report** for #95 — status `success` :no_entry: **close-report gates REFUSED this close** — the following claims did not verify: - commit 7c628c8d8229ff82fbe9bcbfcac239437c2dbab7 is not reachable from origin/main (not landed) - changed_files: 'record-run-result.sh' is not in the diff of the claimed commits - changed_files: 'tests/record-run-result-test.sh' is not in the diff of the claimed commits - changed_files: 'STATUS.md' is not in the diff of the claimed commits <details><summary>envelope</summary> ```json { "issue": 95, "status": "success", "commits": [ "7c628c8d8229ff82fbe9bcbfcac239437c2dbab7" ], "changed_files": [ "record-run-result.sh", "tests/record-run-result-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/record-run-result-test.sh", "exit_code": 0 } ], "criteria": { "Each recorded attempt has a non-NULL started_at when timing is available": "record-run-result.sh iter_time_bounds derives the first message timestamp and passes --started; tests/record-run-result-test.sh RUN95 asserts started_at == session first timestamp", "ended_at is set from the real iteration end when available, not left to the mass finaliser alone": "attempt writer passes --ended from the last message timestamp; RUN95 asserts ended_at == session last timestamp", "A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged": "RUN95B (no readable session file) leaves ended_at NULL, then db run-end closes it to 1790000000 — invariant 2 intact; swarm-db.py cmd_run_end unchanged", "tests/record-run-result coverage updated": "two new groups added (11 groups pass); full offline suite green" }, "summary": "record-run-result.sh now stamps per-iteration attempts.started_at/ended_at from the session jsonl's first/last message timestamps, keeping the kills-finalise fallback.", "blockers": [] } ``` </details>
Author
Member

close-report for #95 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 95,
  "status": "success",
  "commits": [
    "7c628c8d8229ff82fbe9bcbfcac239437c2dbab7"
  ],
  "changed_files": [
    "record-run-result.sh",
    "tests/record-run-result-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/record-run-result-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Each recorded attempt has a non-NULL started_at when timing is available": "record-run-result.sh iter_time_bounds derives the first message timestamp and passes --started; tests/record-run-result-test.sh RUN95 asserts started_at == session first timestamp",
    "ended_at is set from the real iteration end when available, not left to the mass finaliser alone": "attempt writer passes --ended from the last message timestamp; RUN95 asserts ended_at == session last timestamp",
    "A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged": "RUN95B (no readable session file) leaves ended_at NULL, then db run-end closes it to 1790000000 — invariant 2 intact; swarm-db.py cmd_run_end unchanged",
    "tests/record-run-result coverage updated": "two new groups added (11 groups pass); full offline suite green"
  },
  "summary": "record-run-result.sh now stamps per-iteration attempts.started_at/ended_at from the session jsonl's first/last message timestamps, keeping the kills-finalise fallback.",
  "blockers": []
}
**close-report** for #95 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 95, "status": "success", "commits": [ "7c628c8d8229ff82fbe9bcbfcac239437c2dbab7" ], "changed_files": [ "record-run-result.sh", "tests/record-run-result-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/record-run-result-test.sh", "exit_code": 0 } ], "criteria": { "Each recorded attempt has a non-NULL started_at when timing is available": "record-run-result.sh iter_time_bounds derives the first message timestamp and passes --started; tests/record-run-result-test.sh RUN95 asserts started_at == session first timestamp", "ended_at is set from the real iteration end when available, not left to the mass finaliser alone": "attempt writer passes --ended from the last message timestamp; RUN95 asserts ended_at == session last timestamp", "A crashed/killed run's open attempts are still finalised by the existing mass-update path unchanged": "RUN95B (no readable session file) leaves ended_at NULL, then db run-end closes it to 1790000000 — invariant 2 intact; swarm-db.py cmd_run_end unchanged", "tests/record-run-result coverage updated": "two new groups added (11 groups pass); full offline suite green" }, "summary": "record-run-result.sh now stamps per-iteration attempts.started_at/ended_at from the session jsonl's first/last message timestamps, keeping the kills-finalise fallback.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#95
No description provided.