Skip to content

impl(quota-plane): stage-3 S6 — re-weighting proposal generator: route-config PRs with forecast evidence #12700

Closed

Description

@dezren39

Stage-3 epic #12694, slice S6. Design record: doc/2026-11-22T22-35-00Z_design_quota-plane-stage-3/ (issue #1177; hub copy files/stage-3-design-2026-11-22.md in the usage-billing-hub goal files).

Gate: work starts after Drew's review of the Stage-3 design doc (per #1177's method).

Scope: A weekly job that drafts pool re-weighting proposals as repo PRs against the route config — never silent config edits (#1177 hard rule). Each proposal PR carries: the forecast evidence (S1), the accuracy record behind it (S2), the shadow diff summary when the change was shadow-tested (S3), and the expected effect. Merge authority is unchanged (Felix/Drew); the controlled A/B gate #1342 applies before any proposal class becomes routine.

Acceptance criteria

  • The first proposal PR is generated by the job (not hand-written) with the full evidence pack attached, and is linked from this issue.
  • The generator provably cannot merge or push to main directly (PR-only path, shown in its config/permissions).

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 22, 2026
  2. developing-today commented on Nov 22, 2026

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

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: progress
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    S6 underway. Design read (D5), evidence base located: the generator consumes S2's accuracy ledger (backtest output today — ~/workspace/issue-12696/accuracy-ledger.json is the demonstration input; the same ledger shape is what live scoring will produce, so the input contract doesn't change when live rows flow), S1's forecast file and S3's shadow record as optional evidence-pack inputs. Proposal targets identified in the route config (.opencode/opencode.jsonc weighted provider routes) plus the caution margin (NEAR_PCT, derive.ts — the margin class D4 reserves to this mechanism).

    Building: pure generator module + PR-only runner (allowlisted gh/git choke point — no merge path exists in code) + strict-argv CLI, in the aggregator's idiom. The first generated proposal PR follows once the generator runs on the real ledger.

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: implementation landed + first generated proposal opened
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    S6 is implemented. Implementation PR (unmerged, Felix reviews): #12762

    First generated proposal PR — acceptance criterion 1: #12761 — opened BY the generator (not hand-written) against the S2 backtest ledger: widen the caution margin NEAR_PCT 85 → 90, +1/−1, with the full evidence pack as its body (S2 accuracy rows verbatim; S1/S3 sections name their absence — no live forecast/shadow products exist in the sandbox yet, and the pack says so rather than papering over it). Unmerged; the #1342 A/B gate applies before the margin class becomes routine.

    Generator shape. Inputs: S2's accuracy ledger (required — backtest output today; the same shape scored from live rows later, so the contract doesn't change when live ticks flow), the route config (.opencode/opencode.jsonc), optional S1 forecast + S3 shadow products for the pack. Outputs: proposals (exact find/replace edit + evidence pack + a measurable expected-effect prediction S7 can score) and named evidence gaps. Two v1 classes: pool-weight shifts inside weighted routes, and the caution-margin step. The demonstration run grounded exactly one proposal and reported 13 gaps — the four Go workspaces' binding windows are too thin today (8/7/44/36 scored forecasts vs the 100 gate), zen-plans members match no forecast pool exactly, and the bare opencode-go weekly row (+1,903 min over 711 scored) was reported but excluded as S2's mixing artifact.

    PR-only path — acceptance criterion 2. Every subprocess the generator runs passes one allowlist choke point (src/quota-reweight-pr.ts): gh surface is exactly pr create + pr list; git pushes validate to quota-proposal/… branches only. A merge is not a forbidden call in the generator — it is an unrepresentable one. Pinned by tests: the allowlist refuses pr merge / push-to-main before anything executes, and a fake-runner drive performs exactly branch+edit+push+create. Stated plainly: the generator runs under the owner's ordinary gh identity; the enforcement is this code path, not GitHub permissions.

    Evidence (sandbox venue). Fail-before: new suites on pristine main fail (module absent). Pass-after: 19/19 new tests incl. the refusal paths (unscoreable carrying S2's reason verbatim, insufficient volume, undefined metrics, aggregate exclusion, counter-evidence); neighbours 60/60; tsc clean. No new dependencies. No schedule created — the weekly cadence is S7's (#12701), which calls this generator; the registry entry lands with it.

    #12700 stays open for Felix's review of PR #12762 and the disposition of the generated proposal PR #12761.

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: done). S6 implemented: generator + PR-only runner + CLI in PR #12762 (unmerged, Felix reviews); generator opened its first proposal PR #12761 (NEAR_PCT 85->90, evidence pack attached, unmerged). Records: #12700 comment 7089288499, epic pointer #12694 comment 7089289077.

  7. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: direction defect fixed; corrected proposal filed
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    The caution-margin direction defect (found at review of the closed proposal PR #12761) is fixed on PR #12762's branch (fix commit 652af2f, with origin/main merged in; head 0c65353).

    What was wrong: the generator stepped NEAR_PCT 85 → 90 on evidence that weekly walls arrive systematically EARLY (positive median signed wall error). A pool reads "near" at windowPercent >= NEAR_PCT (derive.ts poolState), so raising the threshold enters caution LATER and narrows the band — the opposite of the rationale. The class conflated "widen the margin of safety" with "raise the number".

    The fix: the step direction is derived from the sign of the grounding pools' median signed wall error. Early walls (positive) step the threshold DOWN (85 → 80 — caution entered at a lower measured percent, earlier in the window); late walls (negative) step it UP. Both sides are gated identically (breadth ≥ 2 pools, ≥ 1 precision anchor, the existing volume gates); counter-evidence on the opposite side at any volume — materially disagreeing signs — produces the named counter-evidence-present gap, never a proposal. A symmetric floor joins the ceiling (MARGIN_MIN_PCT = 50, gap margin-at-floor). All step language now states the mechanism; "widen" is gone from the class.

    Tests pin the direction: positive error → downward step (85→80), negative → upward (85→90), mixed signs (both sides fully gated) → named gap, plus both bounds. Evidence (sandbox): quota-reweight + quota-reweight-pr 23/23; neighbours (forecast, accuracy, shadow, anomaly, analytics, gather-map) 163/163; re-run on the merged tree 68/68; tsc --noEmit clean; biome lint clean (format drift in this file pre-exists at HEAD, unchanged in kind).

    Re-run against the same S2 backtest ledger (~/workspace/issue-12696/accuracy-ledger.json, same inputs as the original run): the corrected generator grounded the margin proposal in the downward direction — 2 qualifying early-wall pools (meta +4741 min over 269 scored, anthropic:claude-pro 795.4 over 273), 1 precision anchor, 0 late-wall — and filed it through its own PR-only path: PR #12764 (NEAR_PCT 85 → 80, branch quota-proposal/caution-margin/NEAR_PCT/85-to-80). Run artifacts: ~/workspace/issue-12700/rerun-pr/. PR #12764 is a proposal like any other: it merges or not by the ordinary review path, and the #1342 A/B gate applies before the margin class becomes routine.

    #12762 remains open and unmerged for Felix's review.

  8. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: S6 merged; first corrected proposal held for Drewry's call on the #1342 gate
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Merged: PR #12762 — the re-weighting proposal generator, including the caution-margin direction fix (fix commit 652af2f; direction derived from the sign of the grounding pools' median signed wall error, mixed signs yield the named counter-evidence-present gap, floor/ceiling gaps added; the pre-existing firing test that encoded the defect was updated with its oracle stated). Suites at review: reweight 23/23, neighbours 163/163, tsc clean.

    The re-run on the S2 ledger filed the corrected proposal as PR #12764 (NEAR_PCT 85 → 80). Felix verified its evidence and direction and is HOLDING the merge: #1342's controlled A/B gate ("before any pool change lands") is open, and NEAR_PCT drives the pool-state derivation the babysitter consumes. The merge-vs-hold call is with Drewry; the PR stays open meanwhile. #12700's implementation scope is complete.

  9. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: PR #12764 merged on Drewry's decision — the #1342-gate hold is discharged by his call
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    NEAR_PCT is now 80 on main (PR #12764, the corrected generator's proposal). Felix had held the merge for the #1342 controlled A/B gate; Drewry reviewed the choice and directed the merge on the backtest evidence. S6 (#12700) is complete: generator merged (PR #12762 with the direction fix), first proposal corrected (PR #12761 closed wrong-direction), second proposal merged. Remaining on the epic: S4 stays gated on S3's ≥1-week shadow record (clock starts at the laptop aggregator rebuild); S7 scores this change's expected effect once live rows flow.

  10. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Done record — Lane VP (archer). Closing as completed: the work landed and was recorded on this issue, but the close itself never took effect.

    Fresh first-hand verification (GitHub API, this pass):

    Felix's completion note on this issue (2026-11-23T02:28:50Z) already declared S6 complete; this record performs the close that note announced. The stage-3 epic #12694 stays open on its remaining slices (S4/S5/S7 tracked separately).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codekind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)status:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions