Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b3ed133
Preserve accepted review work and add per-PR pauses
benhook1013 Nov 23, 2026
903624a
Resolve the Hosted review batch and carry current main
benhook1013 Nov 24, 2026
ac1f5ad
Harden review admission, selection, and authorization continuity
benhook1013 Nov 25, 2026
1ee22d2
Preserve explicit review refusal attribution and test scan budgets
benhook1013 Nov 25, 2026
0b128b0
Require durable automatic acceptance for interrupted source retries
benhook1013 Nov 25, 2026
3c6b94b
Validate detached wait custody and fence degraded historical scheduling
benhook1013 Nov 25, 2026
b11221e
Match historical wait tests to the guarded two-column lookup
benhook1013 Nov 25, 2026
93fcf15
Strengthen retained review scheduling and backup evidence boundaries
benhook1013 Nov 25, 2026
56d6b94
Bound optional queued diagnostics to the selection response deadline
benhook1013 Nov 25, 2026
234b15e
Roll back provisional selection frame on a typed finish refusal
benhook1013 Nov 25, 2026
d8a5148
Settle only unused preparation with typed round-history refusal
benhook1013 Nov 25, 2026
c377c5a
Keep selected review children from settling a rearmed lane
benhook1013 Nov 27, 2026
fba6978
Isolate unreadable review planning and settle proven unused CLI attempts
benhook1013 Nov 27, 2026
f959d76
Fix Hosted review evidence and CLI preparation recovery
benhook1013 Nov 28, 2026
f812667
Harden review scheduling and retained attempt recovery
benhook1013 Nov 28, 2026
eb54c94
Carry current main into FireController stack head
benhook1013 Nov 29, 2026
b87b252
Require durable review authorization and enqueue proof
benhook1013 Nov 29, 2026
4e3c300
Retry exact CLI settlement after transient contention
benhook1013 Nov 29, 2026
814f13b
Settle proven unused CLI work after a prewrite refusal
benhook1013 Nov 29, 2026
482f34d
Harden review selection history and settlement readback
benhook1013 Nov 29, 2026
6b80c07
Harden scheduling evidence and review settlement continuity
benhook1013 Nov 29, 2026
1e4446b
Guard FireController review recovery and local scheduling holds
benhook1013 Nov 29, 2026
9d34690
Use bounded supervisor readiness assertion
benhook1013 Nov 29, 2026
a8b2e8e
Preserve verified review recovery and validate retained scheduling hi…
benhook1013 Nov 29, 2026
4dd406e
Preserve review scheduling through guarded retries and pauses
benhook1013 Nov 29, 2026
7128b4d
Test guarded legacy Hosted continuity
benhook1013 Nov 29, 2026
87a6366
Separate retained review regression qualification
benhook1013 Nov 29, 2026
da4ef7c
Separate additional retained review compatibility tests
benhook1013 Nov 29, 2026
70b00bb
Complete batched Hosted and CLI review fixes
benhook1013 Nov 29, 2026
32eac8c
Address combined Hosted and CLI review findings
benhook1013 Nov 29, 2026
7e0b405
Complete retained CLI settlement and index resource lookups
benhook1013 Nov 29, 2026
8e9732f
Address current combined Hosted and CLI review findings
benhook1013 Nov 29, 2026
98e882f
Move further retained review regressions into qualification PR
benhook1013 Nov 29, 2026
7d23f29
Align #115 with current main
benhook1013 Nov 29, 2026
7f72acc
Address retained scheduling and recovery review findings
benhook1013 Nov 29, 2026
cdb2d6d
Stop repeated CLI preparation for a held predecessor
benhook1013 Nov 29, 2026
602b5d7
Batch exact retained custody receipt reads
benhook1013 Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The [Hosted source foundation](delivery.md#hosted-source-foundation) records the
- [Hosted capacity settlement](hosted-settlement.md): guarded administrator recovery after verified external termination, preserving evidence and preventing automatic reposts.
- [Per-PR review rounds](review-round-controls.md): explicit native grants, close, taper, cumulative accounting and bound-client contracts.
- [Retained review operations](review-operations.md): provider-free discovery, compact status and original Hosted observer diagnostics.
- [Review scheduling](review-scheduling.md): per-PR pauses, accepted review work and retained-state recovery.
- [Native review execution](review-execution.md): durable operations, provider adapters, isolated workspaces and the remaining dispatch/cutover boundary.
- [Source refresh and observed policy](review-source.md): explicit background source reads, retained observations and provider-free policy assessment.
- [Job checkpoints](job-checkpoints.md): immutable progress records, guarded appends, explicit latest/archive reads and integration status.
Expand Down
2 changes: 1 addition & 1 deletion docs/review-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Hosted allowance attribution uses the same [current-source actor policy](provide

When native projection is enabled, each journal transition updates its browser attempt in the same transaction. Preparing and held are distinct states; held attempts retain their actual stop time. Interrupted active or posting work becomes uncertain without an invented finish time. A missing current PR observation leaves the transition ledger-only; a trusted fresh observation can establish that first row. Publication preserves current PR facts and imported history, and exact replay creates no new snapshot. Initial metadata is a fallback inside the publication transaction: if another observation creates current PR facts after a missing-row read, those current facts take precedence over the prepared fallback. If retained attempt capacity is already full, the request is durably held before creating an attempt or reservation. If a later administrator observation replaces the snapshot, omits the live native attempt and fills its capacity, automatic transitions remain ledger-only; they neither copy snapshot rows nor block execution or restart recovery. Existing native rows still update at capacity. Explicit publication retains its atomic capacity refusal. Other projection failures roll back the journal transition as well.

Attempt settlement retries only the same guarded local journal transition within a finite budget. It reconciles an already committed transition before retrying and never repeats provider dispatch. If the outcome cannot be recorded, the supervisor reports a failure, cancels its other work and retains reservations for inspection and recovery.
Attempt settlement retries only the same guarded local journal transition within a finite budget. It reconciles an already committed transition before retrying and never repeats provider dispatch. For a source-less CLI refusal that the original driver certified before usage, a live supervisor may give the same guarded settlement one additional bounded window after a local timeout or overload. The original ownership marker remains in place, and neither preparation nor dispatch runs again. After a positive allowance query, the native driver must retire the exact unconsumed review permit before handing off settlement. A qualifying pre-write refusal requires proof that no allowance was retained. A qualifying local publication refusal after a successful positive allowance write instead carries the exact retained observation and verifies it again in the guarded settlement. Both paths preserve the original request and never authorize a review. Unknown outcomes are not proof of non-use. If the outcome cannot be recorded, the supervisor reports a failure, cancels its other work and retains reservations for inspection and recovery.

## Hosted adapter

Expand Down
33 changes: 33 additions & 0 deletions docs/review-scheduling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Review scheduling

## Pause a PR

A project writer can pause new reviews for a PR before its first review intent or while it has queued work. The pause covers undispatched Hosted and CLI work. It preserves accepted operation identities and their cooldown deadlines, and collection of an already issued review can continue. An optional reason explains the pause. Resuming clears that reason.

When the owned CLI driver observes a pause at its final local check before starting the review process, it can retain the original request using an attempt-bound no-start receipt. It releases the exact unused reservation and keeps the prior attempt as history. Resume takes the ordinary admission path with a new attempt; an issued action or uncertain outcome never uses this automatic path.

Draft eligibility, [round settings](review-round-controls.md), earned taper, channel closure and operation controls remain separate. To resume an individually paused operation, use its [operation control](retained-review-quota-controls.md).

Use `GET` and `POST /api/v1/projects/{project_id}/reviews/pulls/{number}/scheduling` to read or update the pause. A write supplies `expected_revision`, `paused` and an optional `reason`, with the normal explicit idempotency key. An unconfigured PR reads as revision zero and unpaused. Keep the original request and key when a mutation result is uncertain.

Project scheduling is read-only. `GET /api/v1/projects/{project_id}/reviews/scheduling` shows the retained revision, settings, authorizing worker and pauses for currently queued PRs. It reports unavailable authorization and provider holds without exposing credentials. The per-PR read can find controls outside the queue.

## Accepted work

A pending operation without a retained selection link is eligible as a direct request only when the exact public enqueue receipt matches its original project, principal, worker, configuration revision, channel, pull request, and head. The same rule applies when counting a direct request as a queue fence. If neither a valid selection link nor a direct receipt establishes origin, the controller does not admit the operation as direct. This requirement does not change settled history or recovery of already-admitted work.

Explicit selection uses the existing durable queue. Automatic origin in retained state requires matching attribution, an authorized original worker and complete relevant scheduling history. Queued or selecting work retains its original authorizer. An already selected operation can retain that original authorizer through a manager change when both authorizers remain valid and the intervening history proves continuous enablement of its channel. Missing or conflicting attribution and ambiguous legacy selections hold for operator investigation. Legacy explicit origin can be proven by an exact retained mutation receipt, a caller-supplied PR pin or complete history from before automatic scheduling for that channel.

Current queued diagnostics identify an earlier accepted Hosted request before the later request's independent cooldown. The bounded local read uses compatible active queue and quota bindings. A paused, cancelled or invalid earlier request releases that turn. CLI shared-account quota diagnostics retain the original deadline while the accepted account and current configuration still agree.

Version 5 of `X-FC-Operation-Wait` extends version 3 with optional `queue_ahead_pull_number` in the round-progress read. Older response versions omit it. It reports the accepted predecessor without changing allowance or deadlines.

## Backup and restore

Backups retain scheduling settings, PR pauses, acceptance events and automatic attribution. Inspection checks their consistency. Older bundles may omit the optional domain. Version-one Hosted-only settings migrate with automatic CLI off. Restore lands in an inactive destination with provider execution held. Historical authorizers remain evidence after revocation or retirement.

A legacy bundle can omit a PR control when its unique latest canonical event proves an unpaused resume. Restore retains that event's actor, revision and time in the destination control and preserves the journal. A missing paused control or ambiguous history blocks restore.

A linked selection with proven custody retains its original child identifier and observed revision in a diagnostic record. Quarantine preserves the child, authorizer, retained evidence and any existing provider action. A held child cannot obtain new admission or reserve a queued turn. Ambiguous provenance holds for investigation.

The active selection custody migration is forward-only. Before upgrading, retain a verified rollback backup whose `review_selection` schema is version 1. For binary rollback, restore that bundle to a separate inactive destination and use the [backup recovery procedure](backups.md). Backups containing `review_selection` schema version 2 require compatible readers and retain custody records pending an explicit retention policy. The selection schema version is independent of the bundle manifest version.
53 changes: 35 additions & 18 deletions internal/adoptionholds/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ type Facts struct {
Open int64 `json:"open"`
}

// projectStateError marks validated corruption in retained project records.
// Shared schema failures and operational database errors must remain unmarked.
type projectStateError struct{ error }

func (e *projectStateError) Unwrap() error { return e.error }

// IsProjectStateError reports a validated project-local retained-data failure.
// Public status codes alone do not distinguish it from shared storage failures.
func IsProjectStateError(err error) bool {
var local *projectStateError
return errors.As(err, &local)
}

func projectStateUnavailable() error {
return &projectStateError{unavailable()}
}

func validTime(s string) bool {
v, e := time.Parse(time.RFC3339Nano, s)
return e == nil && !v.IsZero() && len(s) <= 64
Expand Down Expand Up @@ -65,14 +82,14 @@ func readSourceWithVersion(ctx context.Context, q Query, project, namespace stri
return out, err
}
if !retainedInteger(repositoryValue, &out.Source.RepositoryID) || !retainedText(snapshotValue, &out.Source.SnapshotSHA256) || !retainedInteger(revisionValue, &out.Revision) || !validSource(out.Source) || out.Revision < 1 {
return out, unavailable()
return out, projectStateUnavailable()
}
var repository int64
if err = q.QueryRowContext(ctx, `SELECT github_repository_id FROM projects WHERE id=?`, project).Scan(&repositoryValue); err != nil {
return out, err
}
if !retainedInteger(repositoryValue, &repository) || repository < 1 {
return out, unavailable()
return out, projectStateUnavailable()
}
if repository != out.Source.RepositoryID {
return out, core.Fail("repository_changed", "The retained source belongs to a different repository.", 409)
Expand Down Expand Up @@ -109,15 +126,15 @@ func VerifyRetainedSource(ctx context.Context, q Query, project string, source m
return retainedSourceReadError(err)
}
if !retainedText(bodyValue, &body) || !retainedText(shaValue, &sha) {
return unavailable()
return projectStateUnavailable()
}
var batch m.Batch
if digest([]byte(body)) != sha || strictjson.Decode([]byte(body), &batch) != nil {
return unavailable()
return projectStateUnavailable()
}
normalized, canonical, err := NormalizeBatch(batch)
if err != nil || string(canonical) != body || normalized.Source != source || *normalized.ExpectedRevision != revision-1 {
return unavailable()
return projectStateUnavailable()
}
return nil
}
Expand Down Expand Up @@ -149,14 +166,14 @@ func readDetailWithSources(ctx context.Context, q Query, project, id string, sou
return d, err
}
if !retainedText(idValue, &d.ID) || !retainedText(projectValue, &d.ProjectID) || !retainedText(namespaceValue, &namespace) || !retainedInteger(sourceRevisionValue, &d.SourceRevision) || !retainedText(bodyValue, &body) || !retainedText(shaValue, &sha) || !retainedText(statusValue, &d.Status) || !retainedInteger(revisionValue, &d.Revision) || !retainedText(actorValue, &d.ActorID) || !retainedText(workerValue, &d.WorkerID) || !retainedText(createdValue, &d.CreatedAt) {
return d, unavailable()
return d, projectStateUnavailable()
}
if !identifier.MatchString(d.ID) || d.ProjectID != project || !sourceKey(namespace) || !identifier.MatchString(d.ActorID) || !identifier.MatchString(d.WorkerID) || !validTime(d.CreatedAt) || digest([]byte(body)) != sha || strictjson.Decode([]byte(body), &d.Original) != nil {
return d, unavailable()
return d, projectStateUnavailable()
}
normalized, err := NormalizeObligation(d.Original)
if err != nil || string(encode(normalized)) != body {
return d, unavailable()
return d, projectStateUnavailable()
}
state, found := sources[namespace]
if !found {
Expand All @@ -171,15 +188,15 @@ func readDetailWithSources(ctx context.Context, q Query, project, id string, sou
}
d.Source = state.Source
if d.SourceRevision < 1 || d.SourceRevision > state.Revision {
return d, unavailable()
return d, projectStateUnavailable()
}
var key string
var keyValue any
if err = q.QueryRowContext(ctx, `SELECT source_key FROM review_adoption_obligations WHERE id=?`, id).Scan(&keyValue); err != nil {
return d, retainedSourceReadError(err)
}
if !retainedText(keyValue, &key) || key != d.Original.SourceKey {
return d, unavailable()
return d, projectStateUnavailable()
}
rows, err := q.QueryContext(ctx, `SELECT project_id,pull_number FROM review_adoption_targets WHERE obligation_id=? ORDER BY pull_number LIMIT 102`, id)
if err != nil {
Expand All @@ -196,7 +213,7 @@ func readDetailWithSources(ctx context.Context, q Query, project, id string, sou
}
if !retainedText(ownerValue, &owner) || !retainedInteger(numberValue, &n) || owner != project || !pull(n) || len(numbers) >= 101 {
rows.Close()
return d, unavailable()
return d, projectStateUnavailable()
}
numbers = append(numbers, n)
}
Expand All @@ -216,22 +233,22 @@ func readDetailWithSources(ctx context.Context, q Query, project, id string, sou
err = q.QueryRowContext(ctx, `SELECT revision,reason,evidence_json,actor_id,worker_id,resolved_at FROM review_adoption_resolutions WHERE obligation_id=?`, id).Scan(&revisionValue, &reasonValue, &refsValue, &actorValue, &workerValue, &resolvedValue)
if errors.Is(err, sql.ErrNoRows) {
if d.Status != "open" || d.Revision != latestRevision {
return d, unavailable()
return d, projectStateUnavailable()
}
return d, nil
}
if err != nil {
return d, err
}
if !retainedInteger(revisionValue, &resolution.Revision) || !retainedText(reasonValue, &resolution.Reason) || !retainedText(refsValue, &refs) || !retainedText(actorValue, &resolution.ActorID) || !retainedText(workerValue, &resolution.WorkerID) || !retainedText(resolvedValue, &resolution.ResolvedAt) {
return d, unavailable()
return d, projectStateUnavailable()
}
if d.Status != "resolved" || d.Revision != latestRevision+1 || resolution.Revision != d.Revision || !text(resolution.Reason, 4096) || !identifier.MatchString(resolution.ActorID) || !identifier.MatchString(resolution.WorkerID) || !validTime(resolution.ResolvedAt) || strictjson.Decode([]byte(refs), &resolution.Evidence) != nil || !m.ValidResolutionEvidence(resolution.Evidence) || string(encode(resolution.Evidence)) != refs {
return d, unavailable()
return d, projectStateUnavailable()
}
previous := resolution.Revision - 1
if _, err := m.NormalizeResolution(m.ResolveRequest{ExpectedRevision: &previous, Reason: resolution.Reason, Evidence: resolution.Evidence}); err != nil {
return d, unavailable()
return d, projectStateUnavailable()
}
d.Resolution = &resolution
return d, nil
Expand Down Expand Up @@ -259,7 +276,7 @@ func readFacts(ctx context.Context, q Query, project string, number int64, stopA
break
}
if !retainedText(idValue, &id) || !identifier.MatchString(id) {
err = unavailable()
err = projectStateUnavailable()
break
}
ids = append(ids, id)
Expand All @@ -282,7 +299,7 @@ func readFacts(ctx context.Context, q Query, project string, number int64, stopA
return facts, nil
}
if facts.Open > 1<<53-1 {
return facts, unavailable()
return facts, projectStateUnavailable()
}
}
after = id
Expand Down Expand Up @@ -321,7 +338,7 @@ func readFactsIfPresent(ctx context.Context, q Query, project string, number int
func retainedSourceReadError(err error) error {
var failure *core.Error
if errors.Is(err, sql.ErrNoRows) || errors.As(err, &failure) && failure.Code == "not_found" {
return unavailable()
return projectStateUnavailable()
}
return err
}
Expand Down
Loading
Loading