Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion api/stovepipe/proto/stovepipe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ message RecordFixReportRequest {
string fix_id = 3;
// Executor-owned JSON object (at most 256 KiB). Its presence does not imply a published change.
string payload_json = 4;
// Stable executor-owned occurrence ID within this fix (at most 255 bytes). Omit for the original singleton report.
string report_id = 5;
}

message RecordFixReportResponse {}
Expand All @@ -598,7 +600,7 @@ service Stovepipe {
// the minted request ID. The caller hands off asynchronously; validation happens later.
rpc Ingest(IngestRequest) returns (IngestResponse) {}
// RecordFixReport stores the report and schedules a status check, even if the submission is not yet recorded.
// Repeating the same payload succeeds; a different payload for the same report key returns ALREADY_EXISTS.
// Reports may arrive in any order. Repeating an identical report succeeds; changing the payload for the same queue, executor, fix and report ID returns ALREADY_EXISTS.
// Only trusted executor workloads should be authorized to call this method.
rpc RecordFixReport(RecordFixReportRequest) returns (RecordFixReportResponse) {}
// GetRequestHistoryByID returns retained history for one request ID.
Expand Down
16 changes: 13 additions & 3 deletions api/stovepipe/protopb/stovepipe.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

331 changes: 166 additions & 165 deletions api/stovepipe/protopb/stovepipe.pb.yarpc.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/stovepipe/protopb/stovepipe_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/stovepipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ Queue enablement is stored separately from validation results. The first `Ingest

## Recording repair results

`RecordFixReport` stores an immutable executor report before scheduling fix tracking; an identical replay retries a missed enqueue. Conflicting payloads for the same `(queue, executor_id, fix_id)` are rejected. Tracking starts only on callback, not on submission. Request history shows fix acceptance and then one availability event per associated fix and change URL; availability does not establish issue recovery. Enable traffic only after **all** writers schedule fix tracking and the final schema and workers are deployed; API-only writers cannot wake their old rows. The reference host permits this method only over loopback TCP; other deployments must authorize trusted executor workloads.
`RecordFixReport` stores an immutable executor report before scheduling fix tracking; an identical replay retries a missed enqueue. The executor may report multiple occurrences for the same fix. Use a stable `report_id` for each occurrence and reuse it on delivery retries; omitting it selects the original singleton report. Conflicting payloads for the same `(queue, executor_id, fix_id, report_id)` are rejected. Tracking starts only on callback, not on submission. Request history shows fix acceptance and then one availability event per associated fix and change URL; availability does not establish issue recovery. Do not enable named reports until every worker understands report-scoped queue messages and progress; older workers discard the new field. Enable traffic only after **all** writers schedule fix tracking and the final schema and workers are deployed; API-only writers cannot wake their old rows. The reference host permits this method only over loopback TCP; other deployments must authorize trusted executor workloads.
4 changes: 2 additions & 2 deletions service/stovepipe/server/handler/record_fix_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func TestRecordFixReport(t *testing.T) {
} {
t.Run(tt.name, func(t *testing.T) {
c := controllermock.NewMockRecordFixReportController(gomock.NewController(t))
c.EXPECT().RecordFixReport(gomock.Any(), entity.FixReport{Queue: "main", ExecutorID: "repair", FixID: "42", Payload: json.RawMessage(`{}`)}).Return(tt.err)
c.EXPECT().RecordFixReport(gomock.Any(), entity.FixReport{Queue: "main", ExecutorID: "repair", FixID: "42", ReportID: "refresh/12/completed", Payload: json.RawMessage(`{}`)}).Return(tt.err)
s := &StovepipeServer{fixReportController: c}
resp, err := s.RecordFixReport(peer.NewContext(t.Context(), &peer.Peer{Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}}), &pb.RecordFixReportRequest{Queue: "main", ExecutorId: "repair", FixId: "42", PayloadJson: `{}`})
resp, err := s.RecordFixReport(peer.NewContext(t.Context(), &peer.Peer{Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1")}}), &pb.RecordFixReportRequest{Queue: "main", ExecutorId: "repair", FixId: "42", ReportId: "refresh/12/completed", PayloadJson: `{}`})
require.Equal(t, tt.code, status.Code(err))
if tt.err == nil {
require.NotNil(t, resp)
Expand Down
1 change: 1 addition & 0 deletions service/stovepipe/server/mapper/record_fix_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ProtoToFixReport(req *pb.RecordFixReportRequest) entity.FixReport {
Queue: req.GetQueue(),
ExecutorID: req.GetExecutorId(),
FixID: req.GetFixId(),
ReportID: req.GetReportId(),
Payload: json.RawMessage(req.GetPayloadJson()),
}
}
6 changes: 4 additions & 2 deletions stovepipe/controller/fixtrack/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Fix tracking

A fix report schedules one durable task per queue, executor ID, and fix ID. Tracking observes existing work through the executor's optional `ReportTracker` capability. It never submits a repair or depends on the per-issue submission receipt being written. An observed outcome is a complete snapshot, including all known change URLs, and does not imply the original issues were fixed.
A fix report schedules one durable task per queue, executor ID, fix ID and report ID. Tracking observes existing work through the executor's optional `ReportTracker` capability. It never submits a repair or depends on the per-issue submission receipt being written. An observed outcome is a complete snapshot, including all change URLs known from that report, and does not imply the original issues were fixed.

While publication is pending, the controller durably saves progress and postpones that delivery with backoff from 30 seconds up to 15 minutes. The next check time survives redelivery. A terminal outcome stops polling; an unavailable tracker or exhausted pending-check budget produces an inconclusive outcome, not a failed fix. Storage and backend errors follow the host's retry classifier. Optimistic locking prevents a stale worker from overwriting progress.
While publication is pending, the controller durably saves progress and postpones that delivery with backoff from 30 seconds up to 15 minutes. The next check time survives redelivery. A terminal outcome stops polling that report, not later reports for the same fix; an unavailable tracker or exhausted pending-check budget produces an inconclusive outcome, not a failed fix. Storage and backend errors follow the host's retry classifier. Optimistic locking prevents a stale worker from overwriting progress.

A rejected task or exhausted infrastructure retry goes to the terminal reconciler, which stores `inconclusive` without calling the executor again. Dead-letter recovery preserves discovered links and never overwrites a terminal observation. Its storage retries are unlimited.

## Request history

`fix_submitted` records acceptance for an issue opening. `fix_available` is a separate immutable occurrence per request, executor, fix ID and canonical change URL. New associations read retained observations, and successful observation writes read retained associations. Both sides use the primary store and replay the same occurrence ID after interrupted writes. Terminal and dead-letter recovery replay the retained URLs without invoking the executor. The history timestamp is when availability was recorded for that request, not when the change was created. A dry run has no change links and emits no `fix_available` event.

Each report has an independent retry budget and outcome. The version guard covers all reports for the fix so concurrent workers cannot erase each other’s observations. All reports share the first verified observation of each change URL; redelivery and sibling reports cannot duplicate request history.
14 changes: 11 additions & 3 deletions stovepipe/controller/fixtrack/dlq.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,28 @@ func (c *terminalController) Process(ctx context.Context, delivery consumer.Deli
return err
}
store := scoped.GetFixReportStore()
progress, err := store.GetTrackingState(ctx, key.ExecutorId, key.FixId)
snapshot, err := store.GetTrackingState(ctx, key.ExecutorId, key.FixId)
if storage.IsNotFound(err) {
c.logger.Warnw("no callback for dead letter", "queue", key.QueueName, "executor_id", key.ExecutorId, "fix_id", key.FixId)
return nil
}
if err != nil {
return err
}
if err := fixhistory.ProjectAvailability(ctx, scoped, c.logs, key.QueueName, key.ExecutorId, key.FixId, progress.Availability); err != nil {
if err := fixhistory.ProjectAvailability(ctx, scoped, c.logs, key.QueueName, key.ExecutorId, key.FixId, snapshot.Availability); err != nil {
return err
}
progress := reportProgress(snapshot, key.ReportId)
if progress.State != "" && progress.State != entity.FixStatePending {
return nil
}
// Another report can own the shared snapshot; a dead letter cannot create a missing receipt.
if _, err := store.Get(ctx, key.ExecutorId, key.FixId, key.ReportId); storage.IsNotFound(err) {
return nil
} else if err != nil {
return err
}
progress.Checks++
progress.State, progress.Reason, progress.NextCheckAt = entity.FixStateInconclusive, "tracking_abandoned", 0
return store.UpdateTrackingState(ctx, key.ExecutorId, key.FixId, progress, progress.Version, progress.Version+1)
return store.UpdateTrackingState(ctx, key.ExecutorId, key.FixId, withReportProgress(snapshot, key.ReportId, progress), snapshot.Version, snapshot.Version+1)
}
54 changes: 44 additions & 10 deletions stovepipe/controller/fixtrack/fixtrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ func (c *trackingController) Process(ctx context.Context, delivery consumer.Deli
if err := fixhistory.ProjectAvailability(ctx, queueStore, c.logs, queue, executorID, fixID, current.Availability); err != nil {
return err
}
if current.State != "" && current.State != entity.FixStatePending {
reportID := request.GetReportId()
progress := reportProgress(current, reportID)
if progress.State != "" && progress.State != entity.FixStatePending {
return nil
}
if delay := current.NextCheckAt - c.now().UnixMilli(); delay > 0 {
if delay := progress.NextCheckAt - c.now().UnixMilli(); delay > 0 {
delivery.Hold(delay)
return nil
}
report, err := store.Get(ctx, executorID, fixID)
report, err := store.Get(ctx, executorID, fixID, reportID)
if err != nil {
return err
}
Expand All @@ -100,7 +102,8 @@ func (c *trackingController) Process(ctx context.Context, delivery consumer.Deli
return err
}

next := entity.FixTrackingState{FixObservation: observation, Availability: maps.Clone(current.Availability)}
next := current
next.Availability = maps.Clone(current.Availability)
added := map[string]entity.FixAvailability{}
for _, change := range observation.ChangeURLs {
if _, ok := next.Availability[change]; ok {
Expand All @@ -117,27 +120,29 @@ func (c *trackingController) Process(ctx context.Context, delivery consumer.Deli
next.Availability[change] = first
added[change] = first
}
progress = entity.FixReportProgress{FixObservation: observation, Checks: progress.Checks + 1}
newVersion := current.Version + 1
switch observation.State {
case entity.FixStatePending:
if newVersion >= maxPendingChecks {
next.State, next.Reason = entity.FixStateInconclusive, "poll_budget_exhausted"
if progress.Checks >= maxPendingChecks {
progress.State, progress.Reason = entity.FixStateInconclusive, "poll_budget_exhausted"
} else {
delay := min(initialPollDelay<<min(current.Version, maxPollDoublings), maxPollDelay)
next.NextCheckAt = c.now().Add(delay).UnixMilli()
delay := min(initialPollDelay<<min(progress.Checks-1, maxPollDoublings), maxPollDelay)
progress.NextCheckAt = c.now().Add(delay).UnixMilli()
}
case entity.FixStateSucceeded, entity.FixStateFailed, entity.FixStateSkipped, entity.FixStateInconclusive:
default:
return fmt.Errorf("invalid observed fix state %q", observation.State)
}
next = withReportProgress(next, reportID, progress)
if err := store.UpdateTrackingState(ctx, executorID, fixID, next, current.Version, newVersion); err != nil {
return err
}
if err := fixhistory.ProjectAvailability(ctx, queueStore, c.logs, queue, executorID, fixID, added); err != nil {
return err
}
if next.State == entity.FixStatePending {
delivery.Hold(max(next.NextCheckAt-c.now().UnixMilli(), 0))
if progress.State == entity.FixStatePending {
delivery.Hold(max(progress.NextCheckAt-c.now().UnixMilli(), 0))
}
return nil
}
Expand All @@ -157,3 +162,32 @@ func (c *trackingController) observeFix(ctx context.Context, report entity.FixRe
}
return entity.FixObservation{State: entity.FixStateInconclusive, Reason: "tracker_unavailable"}, nil
}

func reportProgress(snapshot entity.FixTrackingState, reportID string) entity.FixReportProgress {
if reportID != "" {
return snapshot.Reports[reportID]
}
checks := snapshot.UnnamedChecks
if len(snapshot.Reports) == 0 {
checks = snapshot.Version
}
return entity.FixReportProgress{FixObservation: snapshot.FixObservation, NextCheckAt: snapshot.NextCheckAt, Checks: checks}
}

func withReportProgress(snapshot entity.FixTrackingState, reportID string, progress entity.FixReportProgress) entity.FixTrackingState {
if reportID == "" {
snapshot.FixObservation, snapshot.NextCheckAt = progress.FixObservation, progress.NextCheckAt
if len(snapshot.Reports) != 0 {
snapshot.UnnamedChecks = progress.Checks
}
return snapshot
}
snapshot.Reports = maps.Clone(snapshot.Reports)
if len(snapshot.Reports) == 0 {
// Before the first named report, the shared version counted only unnamed observations.
snapshot.UnnamedChecks = snapshot.Version
snapshot.Reports = make(map[string]entity.FixReportProgress)
}
snapshot.Reports[reportID] = progress
return snapshot
}
4 changes: 3 additions & 1 deletion stovepipe/controller/fixtrack/fixtrack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestFixTrack(t *testing.T) {
store.EXPECT().ListRequests(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
last := store.EXPECT().GetTrackingState(gomock.Any(), report.ExecutorID, report.FixID).Return(tt.current, nil)
if tt.want.State != "" {
store.EXPECT().Get(gomock.Any(), report.ExecutorID, report.FixID).Return(report, nil)
store.EXPECT().Get(gomock.Any(), report.ExecutorID, report.FixID, "").Return(report, nil)
var registrations []fixer.Registration
if !tt.noExecutor {
observe := fixermock.NewMockReportTracker(mock)
Expand All @@ -82,6 +82,7 @@ func TestFixTrack(t *testing.T) {
registrations = []fixer.Registration{{ID: report.ExecutorID, Executor: executor}}
}
executors.EXPECT().For(fixer.Config{QueueName: report.Queue}).Return(registrations, nil)
tt.want.Version = tt.current.Version
last = store.EXPECT().UpdateTrackingState(gomock.Any(), report.ExecutorID, report.FixID, tt.want, tt.current.Version, tt.current.Version+1).Return(tt.writeErr)
}
if tt.holdMs != 0 {
Expand Down Expand Up @@ -126,6 +127,7 @@ func TestDeadLetterRetainsOutcome(t *testing.T) {
scoped.EXPECT().GetFixReportStore().Return(store)
store.EXPECT().GetTrackingState(gomock.Any(), "e", "f").Return(tt.current, nil)
if tt.write {
store.EXPECT().Get(gomock.Any(), "e", "f", "").Return(entity.FixReport{}, nil)
want := tt.current
want.State, want.Reason, want.NextCheckAt = entity.FixStateInconclusive, "tracking_abandoned", 0
store.EXPECT().UpdateTrackingState(gomock.Any(), "e", "f", want, tt.current.Version, tt.current.Version+1).Return(tt.err)
Expand Down
Loading
Loading