Skip to content

fix(quota-plane): reconcile.py fee_period vocabulary mismatch reports permanent drift #13375

Open

Description

@dezren39

Problem

pm-stack/provider-usage/reconcile.py (#1270's reconciliation diff) compares the fee_period field across legs as a raw string, but the legs use different vocabularies for the same fact:

  • Tracker leg (fenced plan-facts block, schema approved 2026-11-16): month / year.
  • Plan-store leg: the store's Effect schema (packages/core/src/model-plan.ts in the opencode fork, Period) only admits monthly / yearly / once, and ModelPlan.writeStore validates against it — a store row written through the sanctioned edit path can never carry month / year.

Result: since #1270 slice 2 seeded the store (2026-11-23), every daily diff reports 9 fee_period findings (winner: plan-store) that are pure vocabulary noise, burying any real drift. The fixture in test_reconcile.py masks this because its hand-written store fixture uses month — a value the real store schema rejects.

Fix shape

Normalise the period vocabulary on one side of the comparison in reconcile.py (e.g. map the store leg's monthly→month, yearly→year in load_store, or canonicalise both legs in diff), and extend the fixture tests: a store fixture carrying monthly against a tracker row carrying month must produce no fee_period finding, while a genuine period mismatch (monthly vs year) must still be caught with the winner named.

Evidence: the 2026-11-23 post-seed run recorded on #1270 (legs plan-store 9 / tracker 9 / measured 0; the only findings were the 9 fee_period vocabulary rows) and in the registry's RECONCILIATION FINDINGS — 2026-11-23 (post-seed run) section.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T14:27:29Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane ZS claiming #13375 (reconcile.py fee_period vocabulary mismatch), dispatched by the coordinator 2026-11-23 ~09:15 CST.

    Plan: re-verify the mismatch first-hand in the current code path, decide the normalisation direction from the consumers of both vocabularies (store schema monthly/yearly/once vs tracker month/year), implement in reconcile.py + fixture tests, verify the post-seed reconciliation reports no fee_period drift, land via PR. #1270 stays open regardless — no closing keywords for it anywhere.

  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane ZS — premise verified first-hand, normalisation direction decided.

    Premise: TRUE. Reproduced the exact reported state with current main's reconcile.py (0d29cda) against the live inputs (laptop ~/.local/share/opencode/plans.json, the registry's plan-facts block, the current snapshot): legs plan-store 9 / tracker 9 / measured 0, and exactly 9 findings, all fee_period — every one a pure vocabulary pair (monthly vs month, yearly vs year), winner plan-store. No other field drifts.

    Root cause confirmed in code:

    • reconcile.py diff() compares fee_period as a raw string; neither leg is normalised.
    • Store leg can only ever carry monthly/yearly/once — the opencode fork's packages/core/src/model-plan.ts Period schema (Schema.Literals(["monthly", "yearly", "once"])), enforced by ModelPlan.writeStore.
    • Tracker leg carries month/year per the plan-facts schema approved 2026-11-16.
    • The fixture masks it: test_reconcile.py's hand-written store fixture uses "period": "month", a value the real store schema rejects.

    Direction: canonicalise inside reconcile.py at comparison time — neither source's vocabulary changes.

    • Consumers: within this repo, fee_period is consumed only by reconcile.py itself. The tracker vocabulary belongs to an approved schema (2026-11-16) maintained by the registry keeper; the store vocabulary is schema-enforced in another repo. The comparison is the only place the two vocabularies meet, so it is the only place that can reconcile them.
    • Canonical form: the tracker vocabulary (month/year), mapping the store leg's monthly→month, yearly→year for the comparison only. once has no tracker equivalent and passes through unchanged, so a store once against any tracker period still reports as a genuine mismatch.
    • Canonicalising in diff rather than load_store: findings keep each leg's raw values, so a real period finding still shows what each source actually says and names the winner truthfully — normalising at load would rewrite the reported plan-store value to a string the store never carried.

    Fixture tests will be extended per the issue: the base store fixture switches to the schema-valid monthly (tracker month → no finding), and a planted genuine period mismatch (store monthly vs tracker year) must still be caught with the winner named.

  4. added a commit that references this issue on Nov 23, 2026
  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane ZS — done. Closing #13375 as completed.

    Landed: PR #13395, merged — merge commit 22ec90b9c29db984a11e5a78abfe52a42b7323b6 (head SHA-guarded at 0784f1806254). Verified present on main by read-back (PERIOD_ALIASES / _canon in pm-stack/provider-usage/reconcile.py).

    Fix: diff() canonicalises fee_period to the tracker vocabulary for comparison only (monthly→month, yearly→year); findings keep each leg's raw values and the winner. once passes through, so a one-off fee still mismatches any recurring tracker period. Neither source's vocabulary changed.

    Verification:

    • Remote dispatch: fleet queue session fp_cd30072ca532094c8a3f60d74e59b6b7 (run 45203801763, conclusion success) ran python3 pm-stack/provider-usage/test_reconcile.py at ref lane-zs-13375.
    • Laptop run of the same fixture suite in the worktree: all tests pass — base case now exercises the vocabulary pair (store monthly vs tracker month), the planted genuine mismatch (store monthly vs tracker year) is caught with winner plan-store and raw values reported, and store yearly vs tracker year agrees.
    • Live-input reconciliation with the fixed tool (laptop plan store, registry plan-facts block, current snapshot): no-drift — legs plan-store 9 / tracker 9 / measured 0, zero findings. The 9 fee_period vocabulary findings are gone, and no other store↔tracker drift remains. (Measured leg empty: the snapshot freshness gap already recorded on feat(quota-plane): plan-store / tracker / measured reconciliation diff (daily) #1270; it carries no values to disagree with.)

    Criteria in the issue are fully met: normalisation on the comparison side, fixture extended both ways (vocabulary agreement produces no finding; genuine mismatch still caught with the winner named).

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from xaltha: PR #13397 is open — the store leg is normalised to the tracker vocabulary in load_store (monthly→month, yearly→year), so the 9 daily fee_period noise findings stop; values outside the map (e.g. once) still pass through, so genuine drift still reports. The fixture now carries the real store value monthly (the old month masked the bug) and a new case proves a genuine mismatch (monthly vs year) is still caught with the plan-store named winner. Verified remotely via the fleet-command workflow (run 45203450530, success): all reconcile fixture tests pass. The PR says Closes #13375.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions