provisioning: record a deploy time so the activity feed can place deploy/health rows in the window #840

Closed
opened 2026-08-25 16:18:38 +00:00 by matou-build-agent · 3 comments

Symptom

The activity feed's devices face (#826) can only place provisioning's deploy/health events in time if provisioning records when a deploy ran. Today provision.Orchestrator keeps a latest-wins active map[DeviceID]*Outcome with no timestamp and no history, and fleetstate.Reader exposes no device activation time. So provision.RecentEvents(window) (shipped in #826) can only emit its standing per-service health-check failures with the honest-zero At (ADR 0100 — no fabricated time), which a bounded window excludes.

Proposed fix

Give provisioning a genuinely-recorded deploy time — e.g. stamp each Outcome with the deploy-completion time (provision already holds an injectable clock func() time.Time), or record deploy started/completed/failed transitions. Then provision.RecentEvents places its rows in the fleet chronology and a bounded 7-day/30-day window includes them, closing acceptance clause 2 of #796 story 56 fully.

Found while

Implementing #826 observability:fleet-recent-events. Recording a deploy time is a write-path change, which #826 lists in out_of_scope ("no new table, file, stream or collector"; "the only write-path touch in the whole feature" is the founding stamp). Ruled under ADR 0174 on #826 and filed here for a scoped write-path slice.

## Symptom The activity feed's devices face (#826) can only place provisioning's deploy/health events in time if provisioning records *when* a deploy ran. Today `provision.Orchestrator` keeps a latest-wins `active map[DeviceID]*Outcome` with **no timestamp and no history**, and `fleetstate.Reader` exposes no device activation time. So `provision.RecentEvents(window)` (shipped in #826) can only emit its standing per-service health-check failures with the honest-zero `At` (ADR 0100 — no fabricated time), which a bounded window excludes. ## Proposed fix Give provisioning a genuinely-recorded deploy time — e.g. stamp each `Outcome` with the deploy-completion time (provision already holds an injectable `clock func() time.Time`), or record deploy started/completed/failed transitions. Then `provision.RecentEvents` places its rows in the fleet chronology and a bounded 7-day/30-day window includes them, closing acceptance clause 2 of #796 story 56 fully. ## Found while Implementing #826 `observability:fleet-recent-events`. Recording a deploy time is a **write-path** change, which #826 lists in `out_of_scope` ("no new table, file, stream or collector"; "the only write-path touch in the whole feature" is the founding stamp). Ruled under ADR 0174 on #826 and filed here for a scoped write-path slice.
Author
Member

This was generated by AI during triage.

Verified against the current code: provision.Outcome carries no timestamp field, and the active map is latest-wins with no history — the activity-feed gap is real. Two-way door — an additive write-path change to an existing injectable clock, revertible by commit, provable by the existing RecentEvents/seam test suite — proceeding to ready-for-agent.

Agent Brief

Category: enhancement
Summary: Provisioning should record a genuine deploy timestamp so the fleet activity feed can place deploy/health events within a bounded time window instead of only emitting the honest-zero fallback.

Current behavior:
Provisioning keeps a latest-wins outcome per device with no timestamp and no history of when a deploy completed. RecentEvents(window) therefore cannot place deploy/health rows in a bounded window and falls back to the honest-zero At value (per ADR 0100's no-fabricated-time rule), which any bounded window excludes.

Desired behavior:
Each recorded deploy outcome carries a real, deploy-completion timestamp (using the orchestrator's existing injectable clock, not wall-clock time directly, so it stays test-controllable). RecentEvents uses this timestamp to place deploy/health rows correctly within a requested window (e.g. 7-day / 30-day).

Key interfaces:

  • The orchestrator's outcome record needs a timestamp field capturing when the deploy completed (or, alternatively, recorded started/completed/failed transitions — either satisfies the acceptance criteria below).
  • The orchestrator's existing injectable clock func() time.Time should be the time source — no new time dependency.
  • RecentEvents(window) should read this timestamp instead of falling back to the honest-zero value for deploy/health rows that have a real completion time.

Acceptance criteria:

  • A deploy outcome recorded via the orchestrator carries a timestamp reflecting when it completed, sourced from the injectable clock.
  • RecentEvents(window) places a recently-completed deploy's row within a window that covers its completion time, and excludes it once the window has passed.
  • Outcomes with no real completion time (if any remain reachable) still use the honest-zero At rather than a fabricated time — ADR 0100 is not violated.
  • Existing RecentEvents and orchestrator seam tests continue to pass; a new test covers a deploy landing inside vs. outside the window.

Out of scope:

  • Any new storage table, file, or stream — this is the same write-path #826 scoped out, now scoped in here as its own ticket per that ruling.
  • Changing RecentEvents's existing standing-health-check-failure behavior.
  • Backfilling timestamps for outcomes recorded before this change ships.
> *This was generated by AI during triage.* Verified against the current code: `provision.Outcome` carries no timestamp field, and the `active` map is latest-wins with no history — the activity-feed gap is real. Two-way door — an additive write-path change to an existing injectable clock, revertible by commit, provable by the existing `RecentEvents`/seam test suite — proceeding to `ready-for-agent`. ## Agent Brief **Category:** enhancement **Summary:** Provisioning should record a genuine deploy timestamp so the fleet activity feed can place deploy/health events within a bounded time window instead of only emitting the honest-zero fallback. **Current behavior:** Provisioning keeps a latest-wins outcome per device with no timestamp and no history of when a deploy completed. `RecentEvents(window)` therefore cannot place deploy/health rows in a bounded window and falls back to the honest-zero `At` value (per ADR 0100's no-fabricated-time rule), which any bounded window excludes. **Desired behavior:** Each recorded deploy outcome carries a real, deploy-completion timestamp (using the orchestrator's existing injectable clock, not wall-clock time directly, so it stays test-controllable). `RecentEvents` uses this timestamp to place deploy/health rows correctly within a requested window (e.g. 7-day / 30-day). **Key interfaces:** - The orchestrator's outcome record needs a timestamp field capturing when the deploy completed (or, alternatively, recorded started/completed/failed transitions — either satisfies the acceptance criteria below). - The orchestrator's existing injectable `clock func() time.Time` should be the time source — no new time dependency. - `RecentEvents(window)` should read this timestamp instead of falling back to the honest-zero value for deploy/health rows that have a real completion time. **Acceptance criteria:** - [ ] A deploy outcome recorded via the orchestrator carries a timestamp reflecting when it completed, sourced from the injectable clock. - [ ] `RecentEvents(window)` places a recently-completed deploy's row within a window that covers its completion time, and excludes it once the window has passed. - [ ] Outcomes with no real completion time (if any remain reachable) still use the honest-zero `At` rather than a fabricated time — ADR 0100 is not violated. - [ ] Existing `RecentEvents` and orchestrator seam tests continue to pass; a new test covers a deploy landing inside vs. outside the window. **Out of scope:** - Any new storage table, file, or stream — this is the same write-path #826 scoped out, now scoped in here as its own ticket per that ruling. - Changing `RecentEvents`'s existing standing-health-check-failure behavior. - Backfilling timestamps for outcomes recorded before this change ships.
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=10101
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=10101 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #840 — status success

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

envelope
{
  "issue": 840,
  "status": "success",
  "commits": [
    "e8cce02"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/provision/health.go",
    "internal/provision/recentevents.go",
    "internal/provision/recentevents_test.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/provision/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/provision ./internal/controlapi ./internal/monitor",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A deploy outcome recorded via the orchestrator carries a timestamp reflecting when it completed, sourced from the injectable clock": "internal/provision/health.go — Outcome.CompletedAt stamped `o.now()` in healthGate as the standing record lands; o.now() is the existing injectable clock (deploycalibration.go). Pinned by TestRecentEvents_DeployTimePlacesRowInWindow (withClock injected).",
    "RecentEvents(window) places a recently-completed deploy's row within a window that covers its completion time, and excludes it once the window has passed": "internal/provision/recentevents.go — healthFailureEvents sets OpsEvent.At = rec.CompletedAt and gates on win.Contains(at). TestRecentEvents_DeployTimePlacesRowInWindow: row present with At==t0 inside a covering window, absent for windows before and after.",
    "Outcomes with no real completion time still use the honest-zero At rather than a fabricated time — ADR 0100 is not violated": "TestRecentEvents_NoCompletionTimeKeepsHonestZero — a zero-CompletedAt Outcome yields a zero At on an all-time read and is excluded by a bounded window (never mis-placed at the epoch).",
    "Existing RecentEvents and orchestrator seam tests continue to pass; a new test covers a deploy landing inside vs. outside the window": "go test ./internal/provision green (existing TestRecentEvents_StandingHealthCheckFailureProjects / _HealthyDeployEmitsNoRow pass); new TestRecentEvents_DeployTimePlacesRowInWindow covers inside vs. before/after the window."
  },
  "summary": "Provisioning stamps each finished deploy's Outcome with an injectable-clock CompletedAt and RecentEvents places its health-check-failure rows at that time so a bounded window includes them.",
  "blockers": []
}
**close-report** for #840 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 840, "status": "success", "commits": [ "e8cce02" ], "changed_files": [ "STATUS.md", "internal/provision/health.go", "internal/provision/recentevents.go", "internal/provision/recentevents_test.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/provision/", "exit_code": 0 }, { "command": "go test ./internal/provision ./internal/controlapi ./internal/monitor", "exit_code": 0 } ], "criteria": { "A deploy outcome recorded via the orchestrator carries a timestamp reflecting when it completed, sourced from the injectable clock": "internal/provision/health.go — Outcome.CompletedAt stamped `o.now()` in healthGate as the standing record lands; o.now() is the existing injectable clock (deploycalibration.go). Pinned by TestRecentEvents_DeployTimePlacesRowInWindow (withClock injected).", "RecentEvents(window) places a recently-completed deploy's row within a window that covers its completion time, and excludes it once the window has passed": "internal/provision/recentevents.go — healthFailureEvents sets OpsEvent.At = rec.CompletedAt and gates on win.Contains(at). TestRecentEvents_DeployTimePlacesRowInWindow: row present with At==t0 inside a covering window, absent for windows before and after.", "Outcomes with no real completion time still use the honest-zero At rather than a fabricated time — ADR 0100 is not violated": "TestRecentEvents_NoCompletionTimeKeepsHonestZero — a zero-CompletedAt Outcome yields a zero At on an all-time read and is excluded by a bounded window (never mis-placed at the epoch).", "Existing RecentEvents and orchestrator seam tests continue to pass; a new test covers a deploy landing inside vs. outside the window": "go test ./internal/provision green (existing TestRecentEvents_StandingHealthCheckFailureProjects / _HealthyDeployEmitsNoRow pass); new TestRecentEvents_DeployTimePlacesRowInWindow covers inside vs. before/after the window." }, "summary": "Provisioning stamps each finished deploy's Outcome with an injectable-clock CompletedAt and RecentEvents places its health-check-failure rows at that time so a bounded window includes them.", "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/idss#840
No description provided.