Skip to content

ci: partition archived run records by UTC day #4130

Closed

Description

@schlessera

Part of #2948.

Context

The archive currently stores YYYY-MM/<record-kind>.json on refs/heads/brain-ci-metrics. The issue's 2026-11-16 volume observation projects approximately 66 MB of run data per month. The delivered writer refuses publication if an output file exceeds 95 MiB. On inspected main 49b6e7c48ca9f7f6c4bfff90790c28a536ba66e0, the guard is MAX_FILE_BYTES (scripts/ci-archive.ts:26) and the serialization check is if (Buffer.byteLength(text) > MAX_FILE_BYTES) (scripts/ci-archive.ts:246). The current reader, parseMonthFile (scripts/ci-archive.ts:148-158), recognizes only monthly files. #2955's writer is delivered through merged #4133; the implementation prerequisite is satisfied.

Decision

Maintainer, 2026-11-17: option B, recorded ruling. New run writes use YYYY-MM/run/DD.json, based on the run's existing UTC partition timestamp (run: { at:, scripts/ci-archive.ts:52). Other kinds retain YYYY-MM/<kind>.json. The rule is fixed by kind; no runtime partition-selection interview is needed.

Daily placement keeps late-arriving records on a stable natural key and retains readable text history. Numbered size-based parts can reshuffle on late arrivals; compression hides text diffs and only postpones the same ceiling. Each daily output still has the existing 95 MiB guard; exceeding it refuses publication rather than inventing another partition scheme.

Out of scope

Baseline acquisition (#4129), directory-report tie handling (#4131), new telemetry, report delivery, changing retention or record payload meanings, compression, numbered parts, and raising the size cap. No live archive dispatch or data-ref rewrite is part of this decision-processing pass.

Scope

Append the selected layout amendment to docs/decisions/ci-evidence.md, update the existing writer and all archive readers, and update the archive/inventory documentation. Preserve immutable historical records, deterministic identity/merge semantics, the leakage screen, unknown-version refusal and exact-lease publication. Keep legacy monthly run files readable throughout the transition; new writes use daily run partitions without destructively rewriting historical blobs.

Acceptance criteria

  • A dated amendment in docs/decisions/ci-evidence.md records this ruling, alternatives, the timestamp rule and compatibility with legacy monthly files. The archive guide and inventory describe the same rule.
  • The writer puts each new run/attempt in the ruled UTC-day file, including late arrivals and month/day boundaries; other kinds stay monthly.
  • Every archive-reading/report path accepts legacy monthly runs and daily runs. If both layouts carry a run/attempt, reporting counts it once using the existing deterministic merge/conflict rules; no historical record is lost or silently changed.
  • Every output file retains the existing size boundary: at the cap is allowed, above it refuses the complete publication before any push. Daily overflow does not silently fall back to compression or numbered parts.
  • Replay, repeated compaction and reader/report ordering are deterministic. Existing schema versions, privacy checks, record conflicts and exact-lease concurrency protections remain covered.

Verification

Use focused offline tests in tests/ci-archive.test.ts for daily placement, UTC boundaries, late arrivals, the size boundary and mixed-layout transition. Assert equivalent report contents without missing or double-counted runs. Remove the partition/boundary behavior in a mutation, observe the named assertion fail, restore it and run bun run test tests/ci-archive.test.ts tests/ci-timings.test.ts, plus any affected evidence-report tests. Synthetic data is sufficient; no live near-limit archive is required.

Contract impact

No CLI/MCP or consumer payload change is selected. This changes the internal archive layout bound by docs/decisions/ci-evidence.md, whose dated amendment is required in this delivery.

2026-11-17 decision processing: selected B, replaced the open partition question with its implementation brief, and retained unscheduled priority p2. Earlier triage's writer prerequisite is satisfied by #4133.

Activity

  1. added
    type: choreTooling, CI, release plumbing, dependencies.
    area: ciCI workflows, the gates they run, release scripts, packaging.
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    on Nov 17, 2026
  2. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Decision needed (triage, 2026-11-17). How is a record kind partitioned once one UTC month no longer fits in a single blob? The archive decision binds YYYY-MM/<record-kind>.json, so every option amends that record, and #2956/#2957 read whatever it says.

    • A. Size-split parts: YYYY-MM/<kind>-<n>.json. Keeps the month as the unit. Cost: unless records are ordered by a stable key, a re-compaction that adds records shifts records between parts, so archive history diffs badly. Readers must list parts.
    • B. Day partitions for the oversized kind: YYYY-MM/<kind>/DD.json, at first only run. A record's place is set by its own UTC date, so re-compaction is stable and append-only history stays readable. At the projected ~66 MB/month that is about 2–3 MB a day, a large margin. Cost: the layout differs by kind, so readers need a rule or a manifest to know which kinds are split by day.
    • C. Compress each monthly file (for example gzip). Smallest change for readers. Cost: it only postpones the limit, loses the text-diff history of the ref, and makes the leakage screen read decompressed content.

    Recommendation (not approval): B. It bounds file size by a natural key, keeps compaction deterministic and append-only, and the switch can be recorded per kind in a dated amendment of the decision record.

    Completion evidence: a **Decision (maintainer, <date>):** comment choosing A, B or C (or another layout). It is recorded in docs/decisions/ci-evidence.md under the issue's first criterion. Implementation then follows once #2955's writer is on main.

  3. added
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    and removed
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    on Nov 17, 2026
  4. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-17): Option B: partition new archived run records by UTC day at YYYY-MM/run/DD.json. Other record kinds retain YYYY-MM/<kind>.json. A run's day follows its existing partition timestamp (run.createdAt), rather than collection or compaction time.

    Keep legacy monthly run files readable during transition, preserve historical records and deterministic identity/merge semantics, and count a run/attempt once when layouts coexist. Keep the 95 MiB size guard on each output file, the leakage screen, unknown-version refusal and exact-lease publication. An oversized daily file still refuses publication; this ruling does not add a second automatic partition scheme.

    Record the dated layout amendment in docs/decisions/ci-evidence.md as part of this issue's delivery, update the writer and every archive reader, and prove the boundary and transition offline. Numbered monthly parts were rejected because late records can reshuffle them; compression was rejected because it hides text diffs and only postpones the size limit.

    Remove needs: decision and add agent-ready. The issue remains unscheduled. This decision does not dispatch archive jobs or rewrite the live data ref.

  5. changed the title [-]ci: decide how the evidence archive partitions a kind that outgrows one monthly blob[/-] [+]ci: partition archived run records by UTC day[/+] on Nov 17, 2026
  6. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    and removed
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    on Nov 17, 2026
  7. added this to the 0.45.0 milestone on Nov 17, 2026
  8. self-assigned this
    on Nov 17, 2026
  9. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-2c4dfdb0. Branch: chore/4130-daily-run-archive.

  10. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Merged in #4166 as 94f55806c through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ciCI workflows, the gates they run, release scripts, packaging.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: choreTooling, CI, release plumbing, dependencies.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions