Skip to content

M2: wind down proof safely before the hard wall with zero pending requests #768

Open

Description

@EffortlessSteven

Parent

#763 — M2 Adaptive proof loop.

Depends on #767 for portfolio replanning and terminal request semantics.

Problem

A fixed cutoff wastes useful short work near the deadline, while an unbounded planner risks losing receipts, cleanup time, or the final report. The runner needs duration-aware admission and drain behavior rather than an abrupt global stop.

The hard invariant is:

pending proof requests at reporter start = 0

Not every request must execute. Every request must receive a terminal disposition before reporting.

Selected design

For each candidate task:

latest_safe_start =
  hard_deadline
  - estimated_p95_duration
  - receipt/artifact/posting/cleanup_margin

As the deadline approaches:

  • stop admitting long tasks first;
  • continue admitting short high-value work while it can finish safely;
  • drain in-flight work;
  • persist completed receipts immediately;
  • terminalize queued work with explicit reasons;
  • reserve time for lane reconsideration, reporter compilation, artifacts, and cleanup.

Scope

  • Track remaining wall time and explicit cleanup/reporting reserve.
  • Estimate task duration from command family defaults plus observed repository history where available.
  • Make admission decisions per task, not through one global allow-heavy switch.
  • Stop launching tasks whose latest_safe_start has passed.
  • Allow short, high-value tasks after longer tasks are no longer admissible.
  • Cancel or classify in-flight work only under an explicit policy; never silently discard it.
  • Route all completed receipts before reporter start.
  • Terminalize non-started requests as deferred_hard_wall with selected higher-value work and timing basis.
  • Emit a bounded wind-down artifact showing deadline, reserve, admitted/drained/deferred tasks, and final queue state.

Non-goals

Acceptance criteria

  • Long tasks are rejected once they cannot finish inside p95 + reserve.
  • Short high-value tasks may still be admitted afterward.
  • In-flight tasks drain or receive an explicit terminal receipt; none disappear.
  • Every completed receipt reaches interested lanes before reporter compilation.
  • Every queued request is terminalized before reporter start.
  • deferred_hard_wall records timing basis and is not rendered as maintainer homework.
  • Required missing evidence can still make the gate inconclusive; optional deferred work does not.
  • Artifact/posting/cleanup reserve is preserved in deterministic clock fixtures.
  • The final artifact reports zero pending requests.

Proof

  • Fake-clock fixtures for long-task rejection and short-task admission.
  • In-flight drain, timeout, and cancellation fixtures.
  • Receipt-routing-before-reporter fixture.
  • Required-versus-optional deferred evidence fixture.
  • Queue terminalization and artifact verifier tests.
  • Planner/broker/CLI suites, workspace tests, fmt, Clippy, policy-check, exact-diff RIPR, authoritative gate.

Rollback

Restore conservative early admission cutoff while retaining terminal dispositions. Do not restore a path that begins reporting with pending requests.

Claim boundary

This proves internal safe wind-down and queue closure. It does not prove GitHub workflow watchdog behavior or runner replacement across separate Actions runs.

Activity

  1. EffortlessSteven commented on Jul 15, 2026

    @EffortlessSteven
    MemberAuthor

    Research update — verified current state (2026-07-14)

    I verified the proof-shutdown and deadline infrastructure. The hard invariant (pending requests at reporter start = 0) is partially enforced — terminal dispositions exist but duration-aware admission/drain is not built.

    Current facts

    Component Status
    Terminal proof-request dispositions Built (#747/#751) — every request gets a terminal answer (executed/skipped/timed_out/budget_exhausted)
    Final pending-request guard Built — the reporter does not start while requests are pending
    Duration-aware admission (latest_safe_start) Not built — no p95 estimation or deadline-minus-margin admission
    Drain behavior (stop long tasks first, continue short ones) Not built — current cutoff is abrupt
    Proof lease budget Built — ProofLeaseBudget bounds resource use per run

    The latest_safe_start formula is the core design

    The issue proposes: latest_safe_start = hard_deadline - estimated_p95_duration - receipt/artifact/posting/cleanup_margin. This is sound. The p95 estimation needs historical data (per-command-type runtime distribution), which calibration.json could accumulate over runs.

    Recommendation

    Depends on #767 (portfolio replanning) for the planning substrate. The admission/drain logic operates on the portfolio planner candidate set. The p95 estimation could start with conservative static estimates per ProofKind and refine from calibration data.

    This is M2 and correctly depends on #767. I have not started implementation — this is the verified assessment.

  2. EffortlessSteven commented on Aug 11, 2026

    @EffortlessSteven
    MemberAuthor

    Child split from the live-run investigation

    #862 now owns the duration-accounting prerequisite for this wind-down contract.

    The observed failure is concrete: required proof reserved 1500s of an 1800s budget but consumed about 62.5s. Later 600s red/green candidates were declined despite more than 58 minutes remaining before the hard wall. The current budget treats a safety timeout as permanently consumed time.

    Recommended order:

    1. scheduler: give executable work one canonical identity and explicit subsumption rules #860 canonical task identity;
    2. scheduler: enforce one live resource authority across baseline, sensors, and proof #861 live resource authority and terminal resource release;
    3. proof: release unused timeout reservations and replan from actual and learned duration #862 separate p50/p95/reserved/actual timing, release unused reservation, and replan;
    4. finish this issue's latest-safe-start, drain, reporting/cleanup reserve, and zero-pending-work acceptance.

    #862 does not replace this issue. It fixes the accounting needed for duration-aware admission to be meaningful.

  3. EffortlessSteven commented on Aug 24, 2026

    @EffortlessSteven
    MemberAuthor

    Product deadline semantics amendment

    Keep the existing latest-safe-start/hard-wall contract, but expose the deadline phases explicitly so the scheduler/model loop can optimize and wind down predictably:

    first-useful-signal target
    ordinary-decision target
    optional-work admission stop / soft deadline
    finalization reserve
    hard kill wall
    

    Before the signal target, bias toward early discriminating evidence. After the optional-work stop, admit no broad/weak optional work; short high-value work may still start if p95 + reserve fits. At finalization reserve, start no new executable work, terminalize queued requests, drain/persist terminal receipts, run only necessary reconsideration/final-lead/delivery work, and convert unsatisfied Required obligations to not_proven. Hard kill is for hung/unexpected work and must emit explicit timeout/cancel receipts.

    #862 supplies actual p50/p95/consumed-time inputs, #930/#934/#938 later supply model/cache-window economics, and #926 owns final outcome. Do not rely on being able to interrupt a live provider call to 'wrap up'; bound turns and stop launching new stages as the soft boundary approaches.

  4. EffortlessSteven commented on Aug 24, 2026

    @EffortlessSteven
    MemberAuthor

    PR-sized decomposition — #945 C2.3–C2.4

    1. C2.3 deadline state machine — explicit signal target, decision target, optional-admission stop, finalization reserve and hard kill; pure fake-clock latest-safe-start decisions.
    2. C2.4 live wind-down — stop weak/long optional admission, drain or terminalize every task, route all receipts, preserve final lead/delivery/verification reserve and prove zero pending work.

    Soft boundaries guide convergence; the hard wall catches hangs. Required work that cannot complete becomes NOT_PROVEN; optional deferred work stays artifact-only and never becomes maintainer homework.

  5. EffortlessSteven commented on Aug 24, 2026

    @EffortlessSteven
    MemberAuthor

    Concrete PR decomposition

    #994 signal/decision/optional-stop/finalization/hard-wall state machine
    → #995 live drain, cancel/terminalize, receipt routing and zero pending before finalization
    

    #768 consumes #993 duration estimates and #991 scheduler authority. Long/weak optional work stops first; Required work that cannot fit becomes NOT_PROVEN; final judgment/delivery reserve is protected; hard kill is only for genuine hangs. Close only with every queued/in-flight item terminally accounted.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions