Skip to content

fix(showcase): persist selected observations atomically in PocketBase - #7255

Merged
jpr5 merged 1 commit into
mainfrom
fix/showcase-pb-observation-transactions
Sep 17, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/showcase-pb-observation-transactions

Conversation

@jpr5

@jpr5 jpr5 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an authenticated PocketBase endpoint that commits a selected observation’s status, history, and durable job receipt together. A retry returns the recorded outcome without applying the observation twice. Previously a history failure could leave status committed independently.

This additive PocketBase prerequisite ships before the dependent harness writer. The migration adds a 2 MiB JSON receipt field to probe_jobs; existing clients retain their current behavior. This PR does not claim to fix the filtered D5 dashboard until the dependent harness changes ship.

Dependencies and rollout

PR #7222 remains open and contains harness changes only. These five PocketBase files have no runtime dependency on it. Deploy this PR through the normal PocketBase :latest workflow, verify the migration and authenticated route on staging, then merge the composed harness changes. Staging image references remain :latest.

Validation

Exact five-file bytes match reviewed source 6be7b81e474013b30604e176d686d6d937d0d21d, composed on current main 8f7c566e0e16e08348aba622617e75e390d10856. Formatter, lint (two existing warnings, no errors), all four JS syntax checks, and official local Docker build pass. PocketBase has no TypeScript configuration. Twelve real server/database transaction checks pass on both a fresh database and the pre-fix database upgraded in place; test-only failure hook is excluded from the production image.

The RED below exercises the old direct REST persistence boundary on the actual locally built baseline. GREEN uses the new real atomic route on the same failure scenario. This is a PocketBase transaction proof, not a claim to invoke the TypeScript writer. The dependent harness PR carries the real worker and three-native-cell value proof.

Local RED, before copying candidate files

{"case":"history failure rolls back attempted status","mode":"legacy","failed":{"status":400,"data":{"code":400,"message":"Something went wrong while processing your request.","data":{"transition":{"code":"validation_invalid_value","message":"Invalid value INVALID."}}}},"afterFailure":{"status":[{"collectionId":"rdanjfhwlvz2kmm","collectionName":"status","created":"2026-09-17 18:31:14.320Z","dimension":"d5","fail_count":1,"first_failure_at":"2026-09-17 18:31:14.282Z","id":"t3xrbsrxu3qgjmz","key":"d5:transaction-proof/1789669874282","observed_at":"2026-09-17 18:31:14.282Z","signal":{"proof":true},"state":"red","state_written_at":"2026-09-17 18:31:14.282Z","transitioned_at":"2026-09-17 18:31:14.282Z","updated":"2026-09-17 18:31:14.320Z","written_by":"transaction-proof"}],"history":[],"job":{"claimed_at":"","claimed_by":"","collectionId":"oaxnmt1kr1mddoy","collectionName":"probe_jobs","consecutive_orphan_count":0,"created":"2026-09-17 18:31:14.294Z","family":"","finished_at":"","id":"u4f1uzuhfgljjkd","lease_expires_at":"","payload":null,"probe_key":"d5:transaction-proof/1789669874282","reclaim_count":0,"requeued_at":"","result":{"proof":"immutable"},"result_processed":false,"run_id":"","status":"done","updated":"2026-09-17 18:31:14.294Z","version":0}}}
node:internal/modules/run_main:123
    triggerUncaughtException(
    ^

AssertionError [ERR_ASSERTION]: history failure must roll back status

1 !== 0

    at file:///Users/jpr5/.local/state/copilotkit/worktrees/CopilotKit/showcase-d5-final-integration/showcase/pocketbase/tests/observations.integration.mjs:140:8
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: 1,
  expected: 0,
  operator: 'strictEqual'
}

Node.js v22.16.0

Local GREEN, candidate and migrated database

{"case":"history failure rolls back attempted status","mode":"atomic","failed":{"status":500,"data":{"code":500,"data":{"code":"persistence_failure"},"message":"persistence_failure"}},"afterFailure":{"status":[],"history":[],"job":{"claimed_at":"","claimed_by":"","collectionId":"oaxnmt1kr1mddoy","collectionName":"probe_jobs","consecutive_orphan_count":0,"created":"2026-09-17 18:33:23.979Z","family":"","finished_at":"","id":"lzmgmpi9iiph5iq","lease_expires_at":"","payload":null,"probe_key":"d5:transaction-proof/1789670003956","reclaim_count":0,"requeued_at":"","result":{"proof":"immutable"},"result_observation_receipts":null,"result_processed":false,"run_id":"","status":"done","updated":"2026-09-17 18:33:23.979Z","version":0}}}
PASS history failure atomic rollback
PASS server-side status failure rolls back status/history/receipt
PASS server-side history failure rolls back status/history/receipt
PASS server-side receipt failure rolls back status/history/receipt
PASS replay is durable and preserves raw worker result; conflicting identity rejects
PASS 8 concurrent same-observation requests commit once; new job with same timestamp increments once
PASS old replay after newer job changes nothing
PASS stale prepared basis rejects without effects
PASS history fallback replay preserves original outcome after baseline appears
PASS concurrent different keys preserve both job receipts
PASS actual 2 MiB receipt schema validation failure rolls back all effects
PASS lost post-commit HTTP response retries to original receipt without duplicate history
ALL REAL POCKETBASE TRANSACTION CHECKS PASSED

Independent review of the full repair completed with zero mandatory findings; the fresh-main five-file composition is separately confirmed before publication. CI remains pending until this PR runs.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (4)
  • fix(showcase)
  • feat(showcase)
  • chore(release)
  • chore: release

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 511f32b0-9d73-4094-9bfe-d0886efb02cc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 42 services digest-pinned.

Run 2026-09-17 11:36:44 PDT — 0 finding(s).

@jpr5
jpr5 merged commit 1d2987f into main Sep 17, 2026
27 checks passed
@jpr5
jpr5 deleted the fix/showcase-pb-observation-transactions branch September 17, 2026 18:46
jpr5 added a commit that referenced this pull request Sep 17, 2026
…#7256)

## TL;DR

Keep filtered probe runs from changing excluded dashboard cells, and
persist selected D5 results with durable, atomic retry receipts. This PR
combines the reviewed reporting foundations from #7222 with the
dependent D5 persistence repair. It supersedes #7222; that parent is
deliberately not merged separately.

PocketBase prerequisite #7255 is already merged and verified on staging:
normal `:latest`, sole successful deployment, exact hook/migration
bytes, live 2 MiB receipt field and authenticated endpoint. This PR
contains only 13 harness files in two concern commits.

## Actual local RED → GREEN on the final composition

The fresh official main-baseline image and the final candidate both
execute the actual native browser probes successfully for Microsoft
.NET, .NET Harness, and Mastra. On main, each selected run incorrectly
also changes the excluded full-framework aggregate
(`unchangedControls:false`, two reds cleared). The candidate preserves
excluded records and clears only the selected row.

The reviewed #7222 intermediate image exposes an additional D5 namespace
regression: the same successful native observations leave the selected
row red and summary total zero. The combined candidate turns the SAME
three row IDs green, records total one, preserves excluded records, and
replays without changing status/history. Thus main's selected row was
already green; this PR does not mislabel it as an application failure or
claim three new application fixes.

Private PocketBase rows are explicitly labeled test sentinels for
detecting persistence loss and out-of-scope writes; they are not
invented application failures. The real native verdicts pass in every
phase.

All RED phases were run locally before restoring the respective reviewed
source files. Candidate source
`4b1c76bdfb9f9d9d6bf06e381ad7615ba57217b2` exactly matches the
independently reviewed bytes; the official local image is
`sha256:e97ece5636d37de7743ae95d19d66ec8e2ae21b7e27f7cb2fd21fb510b8c8615`.
Native browser/worker/real PocketBase runs used isolated local services
and AIMock, not CI or fabricated unit results.

### S05 raw final observer output

`red-main` — observer exit 2:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"8hhqhmmfztnabna","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true},{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`red-parent` — observer exit 1:

```json
{"actualWorkerPassed":true,"persistedState":"red","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"gftdymmzxgvq2qm","statusOutcomes":[],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`green-candidate` — observer exit 0:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"8ck5a5rs8floyzb","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```

### S06 raw final observer output

`red-main` — observer exit 2:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"wyftkyd5fy9344w","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true},{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`red-parent` — observer exit 1:

```json
{"actualWorkerPassed":true,"persistedState":"red","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"bjgumkld7fcs91z","statusOutcomes":[],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`green-candidate` — observer exit 0:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"3vc19es94r8e3ph","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```

### S07 raw final observer output

`red-main` — observer exit 2:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"30wkjgnotspcl1e","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true},{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`red-parent` — observer exit 1:

```json
{"actualWorkerPassed":true,"persistedState":"red","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"j74kmxgcwz1qyuv","statusOutcomes":[],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```
`green-candidate` — observer exit 0:

```json
{"actualWorkerPassed":true,"persistedState":"green","rollup":{"total":1,"passed":1,"failed":0},"agg":{"runRowId":"xdrsr5ctvrgdybd","statusOutcomes":[{"previousState":"red","newState":"green","transition":"red_to_green","firstFailureAt":null,"failCount":0,"persisted":true}],"overlayOutcomes":[],"skipped":false,"outageSkippedKeys":[],"droppedCommError":false,"corruptStateSkippedKeys":[]}}
```

## Review and validation

Independent composition review confirms all 13 file hashes, the six
parent-only files' 26-report review coverage, and the D5 changes'
12-report final review. Both reviews have zero remaining mandatory
findings. Current official local Docker build and three native paired
checks pass. Host formatter, lint (102 reviewed warnings, zero errors),
explicit typecheck, full suite (3,841 passed; 18 existing skips), and
full production build all pass. CI must pass before merge.

The prior real PocketBase/consumer failure proofs remain bound to
identical reviewed behavior, with all 88 frozen artifact hashes
reverified. These cover partial writes, lost responses, prefix retries,
process restart/stale sweep, observation identity, missing selected
observations, structural driver errors, summary accounting, malformed
timestamps, and concurrent row creation.


<details><summary>Preserved actual local A1 failure-surface
proof</summary>

# A1 raw local red-green proof for PR body

Selected status writes previously resolved after a PocketBase write
failure, so the result consumer latched the job and the run became
terminal without the required observation. Atomic per-job receipts now
preserve retryability and suppress replayed writes, including after
stale-run sweep and process restart.

TS commit `4994eb27f033eab4b24b960298e2fa271b405e0d`; PB component
`7e6b695cd67fe1f0939612337bd8eb2caff70367`. Private PocketBase on 42910,
real result consumer and real status writer. Native S06 capture
replayed; additional selected prefix, negative state, and
communication-error inputs are explicitly synthetic accepted protocol
cases. They are not native-producer bug claims.

## Single required status write failure

Red (`red.log`), then green (`atomic-single-green.log`):

```text
{"first":{"processed":1,"failures":0},"retry":{"processed":0,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"failureNotAcknowledged":false,"noFalseTerminal":false,"retrySucceeded":false,"sameRun":true,"noReplayWrites":true,"oneHistoryAdded":false}}
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":true,"sameRun":true,"noReplayWrites":true,"oneHistoryAdded":true}}
```

## Multiple selected cells: successful prefix then later failure

Red (`multi-candidate.log`), then green (`atomic-multi-final.log`):

```text
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":true,"sameRun":true,"prefixHistoryDuplicated":true,"noReplayWrites":true,"oneHistoryAdded":false}}
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":true,"sameRun":true,"prefixHistoryPreserved":true,"noReplayWrites":true,"oneHistoryAdded":true}}
```

## Real stale sweep and child-process restart

Red (`restart-red.log`), then green (`restart-final.log`):

```text
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"actualSweep":true,"newProcess":true,"prefixStatePreserved":true,"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":false,"sameRun":true,"prefixHistoryPreserved":true,"noReplayWrites":true,"oneHistoryAdded":false}}
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"actualSweep":true,"newProcess":true,"prefixStatePreserved":true,"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":true,"sameRun":true,"prefixHistoryPreserved":true,"noReplayWrites":true,"oneHistoryAdded":true}}
```

## New job identity and overlay fallback route change

Red (`identity-route-red.log`), then green (`identity-route-final.log`):

```text
{"distinctJobCounted":true,"distinctJobHistory":true,"oldReplayPreserved":true,"fallbackPersisted":true,"routeRetrySucceeded":true,"fallbackReplayPreserved":false}
{"distinctJobCounted":true,"distinctJobHistory":true,"oldReplayPreserved":true,"fallbackPersisted":true,"routeRetrySucceeded":true,"fallbackReplayPreserved":true}
```

## Selected history failure must roll back status and retry

Red (`history-red.log`), then green (`history-green.log`):

```text
{"first":{"processed":1,"failures":0},"retry":{"processed":0,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"statusRolledBack":false,"failureNotAcknowledged":false,"noFalseTerminal":false,"retrySucceeded":false,"sameRun":true,"noReplayWrites":true,"oneHistoryAdded":false}}
{"first":{"processed":0,"failures":1},"retry":{"processed":1,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"statusRolledBack":true,"failureNotAcknowledged":true,"noFalseTerminal":true,"retrySucceeded":true,"sameRun":true,"noReplayWrites":true,"oneHistoryAdded":true}}
```

## Lost response after real transaction commit

The proof consumes and discards one successful HTTP response after
PocketBase commits. The client retries and gets the stored receipt; one
history row lands. This tests the new atomic boundary, not an invented
pre-fix missing-endpoint bug.

```text
{"first":{"processed":1,"failures":0},"retry":{"processed":0,"failures":0},"replay":{"processed":0,"failures":0},"checks":{"committedResponseWasLost":true,"atomicRequestRetried":true,"consumerSucceeded":true,"oneHistoryAdded":true,"noReplayWrites":true,"finalStateGreen":true}}
```

Validation: full harness 3,832 passed / 18 existing skipped;
typecheck/build/format pass; lint 0 errors / 10 pre-existing warnings.
Schema/endpoint absence fails loudly; deploy PB migration and hook
before the new control-plane writer. Raw complete logs and JSON
snapshots are hash-bound in final-receipt.json.

</details>

<details><summary>Preserved actual local A2 failure-surface
proof</summary>

# A2 native driver diagnostic preservation

Scoped native D5 jobs exclude their full aggregate from status writes. A
genuine driver exception returns empty cells, `aggregateState: error`,
and the diagnostic in `aggregateSignal`, with no communication error.
The selected cells therefore received no error history.

The fix projects the driver error onto each selected key through the
existing status-writer error path. It preserves the prior durable
observation, advances its observed timestamp, and stores the actual
diagnostic in error history. It leaves executed-cell counts at zero and
the run failed. It does not modify the full aggregate or excluded cells.

## Local red-green proof

The same untouched native `createE2eFullDriver` runs through real
`runClaimedJob`, real queue report, real `createResultConsumer`, and a
private real PocketBase at port 42920. The accepted malformed `features`
input triggers the actual native TypeError `featureSource.filter is not
a function`. No driver, consumer, queue, or writer stub is used.
Baseline runtime is the existing eb3 proof image; green changes only the
compiled aggregator module using a read-only mount. This demonstrates
persistence of an actual native exception, not a successful test or a
product-cell green flip.

All complete outputs are retained next to this document (`red.log/json`,
`green.log/json`, `proof-receipt.json`). The selected status row remains
red, keeps its ID, and advances observed_at; its error history now
contains the exact diagnostic. The run remains failed with zero executed
cells. Controls and replay are unchanged.

### RED raw output

```text
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
{"level":"warn","msg":"pb-client.legacy-admin-auth-fallback","ts":"2026-09-17T05:33:50.251Z","hint":"/_superusers returned 404 — falling back to /api/admins (PB ≤0.22). Disable this warn after upgrading to PB 0.23+."}
{"level":"error","msg":"fleet.worker.job-driver-error","ts":"2026-09-17T05:33:50.778Z","workerId":"local-d5-worker","jobId":"sxlxy3eoil7cd2l","probeKey":"d5-single-pill-e2e:a2-driver-error","errName":"TypeError","err":"featureSource.filter is not a function"}
{
  "driverFailed": true,
  "diagnosticPreserved": false,
  "consumed": {
    "processed": 1,
    "failures": 0
  },
  "selectedHistory": [],
  "unchangedControls": true,
  "replayPreserved": true,
  "runs": {
    "page": 1,
    "perPage": 100,
    "totalItems": 1,
    "totalPages": 1,
    "items": [
      {
        "collectionId": "mbsz2pvgffrkd7y",
        "collectionName": "probe_runs",
        "created": "2026-09-17 05:33:50.803Z",
        "duration_ms": 4,
        "finished_at": "2026-09-17 05:33:50.804Z",
        "id": "9c6t0kjwihf1643",
        "job_id": "sxlxy3eoil7cd2l",
        "probe_id": "d5-single-pill-e2e:a2-driver-error",
        "started_at": "2026-09-17 05:33:50.800Z",
        "state": "failed",
        "summary": {
          "failed": 0,
          "passed": 0,
          "redsCleared": 0,
          "redsIntroduced": 0,
          "total": 0
        },
        "triggered": false,
        "updated": "2026-09-17 05:33:50.811Z"
      }
    ]
  }
}
```

### GREEN raw output

```text
{"level":"warn","msg":"pb-client.legacy-admin-auth-fallback","ts":"2026-09-17T05:35:29.220Z","hint":"/_superusers returned 404 — falling back to /api/admins (PB ≤0.22). Disable this warn after upgrading to PB 0.23+."}
{"level":"error","msg":"fleet.worker.job-driver-error","ts":"2026-09-17T05:35:29.687Z","workerId":"local-d5-worker","jobId":"ptpk5w3sgljiyjx","probeKey":"d5-single-pill-e2e:a2-driver-error","errName":"TypeError","err":"featureSource.filter is not a function"}
{
  "driverFailed": true,
  "diagnosticPreserved": true,
  "consumed": {
    "processed": 1,
    "failures": 0
  },
  "selectedHistory": [
    {
      "collectionId": "eg1ekz8jfyeploi",
      "collectionName": "status_history",
      "created": "2026-09-17 05:35:29.741Z",
      "dimension": "d5",
      "id": "fjsywn62kx5opk4",
      "key": "d5:a2-driver-error/shared-state",
      "observed_at": "2026-09-17 05:35:29.687Z",
      "signal": {
        "error": "featureSource.filter is not a function"
      },
      "state": "red",
      "transition": "error",
      "updated": "2026-09-17 05:35:29.741Z"
    }
  ],
  "unchangedControls": true,
  "replayPreserved": true,
  "runs": {
    "page": 1,
    "perPage": 100,
    "totalItems": 2,
    "totalPages": 1,
    "items": [
      {
        "collectionId": "mbsz2pvgffrkd7y",
        "collectionName": "probe_runs",
        "created": "2026-09-17 05:33:50.803Z",
        "duration_ms": 4,
        "finished_at": "2026-09-17 05:33:50.804Z",
        "id": "9c6t0kjwihf1643",
        "job_id": "sxlxy3eoil7cd2l",
        "probe_id": "d5-single-pill-e2e:a2-driver-error",
        "started_at": "2026-09-17 05:33:50.800Z",
        "state": "failed",
        "summary": {
          "failed": 0,
          "passed": 0,
          "redsCleared": 0,
          "redsIntroduced": 0,
          "total": 0
        },
        "triggered": false,
        "updated": "2026-09-17 05:33:50.811Z"
      },
      {
        "collectionId": "mbsz2pvgffrkd7y",
        "collectionName": "probe_runs",
        "created": "2026-09-17 05:35:29.728Z",
        "duration_ms": 24,
        "finished_at": "2026-09-17 05:35:29.747Z",
        "id": "7c7otr4omcoknz5",
        "job_id": "ptpk5w3sgljiyjx",
        "probe_id": "d5-single-pill-e2e:a2-driver-error",
        "started_at": "2026-09-17 05:35:29.723Z",
        "state": "failed",
        "summary": {
          "failed": 0,
          "passed": 0,
          "redsCleared": 0,
          "redsIntroduced": 0,
          "total": 0
        },
        "triggered": false,
        "updated": "2026-09-17 05:35:29.752Z"
      }
    ]
  }
}
```

The final PR body must include these raw outputs; this worker does not
create or push a PR.

</details>

<details><summary>Preserved actual local A4 failure-surface
proof</summary>

# A4 proof and handoff

Commit `6f4f00a68859b528661962be70b75bbb358ef777`, base
`eb3d9466e4648cea9ed509b0fa662ef9e9deb0ed`. Clean isolated concern
branch. Only aggregator source and regression tests changed. No
PR/push/deployment.

Scoped totals now use valid original observations retained by the
existing canonical-key write plan. First occurrence remains
authoritative without commError; trusted-negative replacement remains
authoritative with commError. Synthetic fallback rows do not count.
Explicit driver/communication errors remain failed, and rejecting all
original selected observations cannot manufacture a successful run.

## Integration

`observationProjectionCount` is recorded before fallback insertion.
Preserve that boundary when applying A2/A3 so synthetic diagnostics
remain excluded from totals. A1 changes only the subsequent writer
failure catch and does not conflict semantically. No new public helper
or signature.

## Reproduction

These are adversarial mutations of the real captured native S05 D5
result at `../../green-value-s05.json`, NOT claims that the producer
normally emits duplicate/corrupt states. The production queue
enqueue/claim/report and real consumer decode path accept them;
production writers persist to an isolated real PocketBase. No fake
writers or LLM calls. Original RED captured before source edits in
red.json/red.log. Final paired replay adds selected-state and replay
checks.

Local PB `d5-a4-pb` remains available on port 42940 for integration,
with owned pb-data here. Port 42941 unused. Observer command, from the
artifact directory:

```sh
docker --context desktop-linux run --rm --platform linux/amd64 --user 0 -v "$PWD:/proof" -v "$PWD/../..:/capture:ro" --entrypoint node showcase-d5-a4:local /proof/proof.mjs green-integration
```

For the baseline use image
`sha256:a7030a6f2e570e72dd01ff78dabc33882b0c2cee8f38c843b07aeb0d34f4f598`,
label `red-integration`. Expected exit 1 baseline, 0 candidate. Run
sequentially on this PB. The Dockerfile's parent resolves to the
baseline; replace result-aggregator.js with final integrated harness
build output, then use `docker --context desktop-linux buildx build
--builder desktop-linux --load --platform linux/amd64 -t
showcase-d5-a4:integration .` and use that image in the observer. Do not
run plain docker build (host default redirects to Depot).

## Validation

113 focused tests pass (four new tests observed failing first). Full
harness: 180 files passed, 2 existing skipped; 3832 tests passed, 18
existing skipped. Typecheck, full TypeScript build, format and lint pass
(eight pre-existing warnings). Language-service diagnostics empty. Local
Docker build succeeded with final emitted module. Receipt hashes bind
source and raw outputs. Manual checks ran before commit; hooks disabled
for commit. Independent CR remains the integration owner's next gate.

## Raw final RED

```jsonl
{"scenario":"duplicate-green-red","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":2},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":false}
{"scenario":"valid-and-corrupt","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":2},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":false}
{"scenario":"all-corrupt","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":0,"redsCleared":0,"redsIntroduced":0,"total":1},"state":"failed","history":[],"controlsUnchanged":true,"selectedState":"red","replayPreserved":true,"passed":false}
{"scenario":"explicit-error-with-duplicate","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":2},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":false}
{"scenario":"comm-duplicate","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":1,"redsCleared":0,"redsIntroduced":0,"total":2},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"red"}],"controlsUnchanged":true,"selectedState":"red","replayPreserved":true,"passed":false}
```

## Raw final GREEN

```jsonl
{"scenario":"duplicate-green-red","consumed":{"processed":1,"failures":0},"summary":{"failed":0,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":1},"state":"completed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":true}
{"scenario":"valid-and-corrupt","consumed":{"processed":1,"failures":0},"summary":{"failed":0,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":1},"state":"completed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":true}
{"scenario":"all-corrupt","consumed":{"processed":1,"failures":0},"summary":{"failed":0,"passed":0,"redsCleared":0,"redsIntroduced":0,"total":0},"state":"failed","history":[],"controlsUnchanged":true,"selectedState":"red","replayPreserved":true,"passed":true}
{"scenario":"explicit-error-with-duplicate","consumed":{"processed":1,"failures":0},"summary":{"failed":0,"passed":1,"redsCleared":1,"redsIntroduced":0,"total":1},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"green"}],"controlsUnchanged":true,"selectedState":"green","replayPreserved":true,"passed":true}
{"scenario":"comm-duplicate","consumed":{"processed":1,"failures":0},"summary":{"failed":1,"passed":0,"redsCleared":0,"redsIntroduced":0,"total":1},"state":"failed","history":[{"key":"d5:ms-agent-dotnet/shared-state-write","state":"red"}],"controlsUnchanged":true,"selectedState":"red","replayPreserved":true,"passed":true}
```

</details>

<details><summary>Preserved actual timestamp and creation-race
failure-surface proof</summary>

### Invalid-timestamp counters
## Invalid-timestamp transition counter repair

An accepted green observation with an invalid timestamp leaves the
durable status row red. The aggregator previously counted that
history-only observation as a cleared red. Exclude error transitions and
explicitly non-persisted outcomes from red transition counters.

### Actual local RED → GREEN

Same `round2-invalid-date.mjs` through the official AMD64 harness image,
real queue, real status writer, and local PocketBase atomic endpoint; no
cloud or CI proof. Baseline exit 1; candidate exit 0. The durable status
row stays red in both. This fixes the counter only, not the
intentionally retained durable colour or the separate observation
rollup.

RED raw output:
```text
{"level":"warn","msg":"pb-client.legacy-admin-auth-fallback","ts":"2026-09-17T15:59:54.867Z","hint":"/_superusers returned 404 — falling back to /api/admins (PB ≤0.22). Disable this warn after upgrading to PB 0.23+."}
{"level":"warn","msg":"status-writer.durable-unparseable-observed-at","ts":"2026-09-17T15:59:55.539Z","key":"d5:round2-invalid-date-1789660794730/selected","observedAt":"invalid-timestamp","currentObservedAt":"2026-09-17 15:59:54.730Z","hint":"incoming durable-write observedAt is unparseable — landing the history row with a substituted timestamp and skipping the durable upsert (PB would 400 on a non-date value)"}
{"bugReproduced":true,"state":"red","summary":{"failed":0,"passed":1,"redsCleared":1,"redsIntroduced":0,"selectedObservationFingerprint":"9382bff8aa3105e878dc9886a37996c6a337eea0f9a8f32e6e9403ad27ddc9a2","total":1}}
```
GREEN raw output:
```text
{"level":"warn","msg":"pb-client.legacy-admin-auth-fallback","ts":"2026-09-17T16:07:46.700Z","hint":"/_superusers returned 404 — falling back to /api/admins (PB ≤0.22). Disable this warn after upgrading to PB 0.23+."}
{"level":"warn","msg":"status-writer.durable-unparseable-observed-at","ts":"2026-09-17T16:07:47.688Z","key":"d5:round2-invalid-date-1789661266436/selected","observedAt":"invalid-timestamp","currentObservedAt":"2026-09-17 16:07:46.437Z","hint":"incoming durable-write observedAt is unparseable — landing the history row with a substituted timestamp and skipping the durable upsert (PB would 400 on a non-date value)"}
{"bugReproduced":false,"state":"red","summary":{"failed":0,"passed":1,"redsCleared":0,"redsIntroduced":0,"selectedObservationFingerprint":"714c566c75bc85f99ccdea8b44da79b02366a94a6ab50c75e9d2ac4f59d27a86","total":1}}
```

Candidate local image:
`sha256:09086b2550217c279691c4a4aa9d5a6e8d3c098f5298b386fbeabf6442faae1f`
(linux/amd64), built with the repository's unchanged harness Dockerfile
and the isolated candidate source. Focused regression tests: RED 3
failed /116 passed; GREEN119 passed. Additional complete checks recorded
separately in the final receipt.

Final validation: complete harness suite3841 passed/18 existing skipped;
typecheck and format passed; lint0 errors/8 unchanged baseline warnings.
Clean commit `9ba5f5ff5739d36bf3f02bfb38d7c329e5b4c3b4`; hooks passed
without bypass.


### Selected creation race
## Selected communication-error creation race

A selected observation could miss its live communication-error overlay
when another writer created the status row between the overlay read and
its history fallback. Keep the fallback bound to the absent-row basis. A
concurrent insertion now produces a transaction conflict and repeats
route selection, attaching the diagnostic to the newly created row.

### Actual local red/green proof

Uses the official harness Dockerfile and actual local PocketBase at port
43590. The probe schedules a real foreign status insert after the actual
empty status GET; there are no fake database responses.

- BEFORE edit, official baseline
`showcase-harness:d5-source-5becd15a53`: `round2-creation-race.mjs`
exits **1**. `insertions:1`, returned route `write`, live signal
`{foreign:true}`, replay retains the missing diagnostic (`red.log` and
`red/round2-creation-race-red.json`).
- The stricter assertion version against the same baseline also exits
**1**, `acceptance:false` (`red-strict.log`).
- AFTER, official candidate image
`sha256:4f62614c4c5326332543db86f6bbfe8130b2b8065363e1945d77e0c92267f0e5`:
same foreign-insert scenario exits **0**, `acceptance:true`; returned
route `overlay`, `applied:true`, `historyPersisted:true`. Live signal
includes both the foreign value and communication error; green state,
attribution and failure counter are unchanged. Replay does not alter the
row (`green.log`).
- Independent persisted readback: **PASS** — exactly one foreign
observation history and one selected overlay history; receipt route
`overlay`; replay creates no extra history (`persisted.log`).
- Official Docker build and explicit full `tsc --noEmit`: **PASS**. Full
suite plus source-context reruns covers **3838 passed, 18 existing
skips**, no remaining failures. The initial official build-stage run
lacked fixture sources; those failures and subsequent read-only
source-binding reruns are retained. Normal commit hooks and Prettier
check also pass.

This proves one persistence race; it does not claim any original staging
cell is resolved.


### Rollback test target
## Local red-green proof: rollback test targets the affected job

The old rollback check read the original job instead of the third job
whose transaction failed. Both negative controls PATCH the real private
PocketBase thirdJob receipt and verify that persisted mutation before
the assertion.

```text
RED stale receipt corruption: exit 0 — ALL REAL POCKETBASE TRANSACTION CHECKS PASSED
RED capacity receipt corruption: exit 0 — ALL REAL POCKETBASE TRANSACTION CHECKS PASSED
GREEN same stale corruption: exit 1 — AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal
GREEN same capacity corruption: exit 1 — AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal
GREEN intact real transaction suite: exit 0 — ALL REAL POCKETBASE TRANSACTION CHECKS PASSED
```

Both fixed failures identify the actual persisted `wrongJobControl`
receipt mismatch. Existing real transaction checks stay intact. Syntax,
format, applicable precommit hooks, and commitlint pass.



</details>

## Retained follow-ups

# Retained follow-ups for combined harness shipment

These preserve the two independent review inventories. Selected
observation transactions address the current selected-job write/retry
subject; they do not claim to resolve ordinary unfiltered write/ack
durability or the broader lifecycle subjects. Overlapping descriptions
remain traceable to their original inventories.

## Parent reporting-integrity inventory

# Consolidated follow-ups after round 3

All eighteen remain real, separately scoped follow-up obligations. No
item is erased or declared fixed by this status shipment. D1–D17 retain
their prior independent classifications; D18 is newly confirmed under
the distinct fleet-boot-stop-signal-ownership subject.

# Deferred — Out of Scope for this PR

## Bucket (c) — subject-neutral pre-existing (deferred backlog)

(none)

## Bucket (d) — out-of-this-PR subject (follow-up PR)

- showcase/harness/src/orchestrator.ts:3256 — follow-up: D1 —
Cross-environment pin-drift discovery activation.
- showcase/harness/src/orchestrator.ts:4280/4372 — follow-up: D2 —
Worker registration health recovery.
- showcase/harness/src/orchestrator.ts:2836 — follow-up: D3 — PID
saturation durable recovery.
- showcase/harness/src/fleet/control-plane/result-aggregator.ts:1061 —
follow-up: D4 — At-least-once aggregator write/ack durability.
- showcase/harness/src/probes/loader/probe-invoker.ts:731 — follow-up:
D5 — Detail-aware durable progress counts.
- showcase/harness/src/probes/loader/probe-invoker.ts:733 — follow-up:
D6 — Monotonic concurrent progress persistence.
- showcase/harness/src/probes/loader/probe-invoker.ts:771 — follow-up:
D7 — Invoker sibling cancellation/drain lifecycle.
- showcase/harness/src/orchestrator.test.ts:6325 — follow-up: D8 —
Control-plane test failure cleanup handle.
- showcase/harness/src/orchestrator.test.ts:2061 — follow-up: D9 —
Unregister regression must observe rejected attempt.
- showcase/harness/src/orchestrator.test.ts:4700 — follow-up: D10 —
HTTP-probe test temporary directory cleanup.
- showcase/harness/src/orchestrator.test.ts:1397 — follow-up: D11 — S3
test environment restoration.
- showcase/harness/src/orchestrator.test.ts:1395 — follow-up: D12 — Test
module factory isolation.
- showcase/harness/src/orchestrator.test.ts:235 — follow-up: D13 —
Shutdown regression must verify socket closure.
- showcase/harness/src/orchestrator.ts:1233 — follow-up: D14 — Legacy
boot bind failure leaks watchers, engine and subscriptions.
- showcase/harness/src/orchestrator.ts:3505 — follow-up: D15 —
Control-plane HTTP scheduler last-run cache is not hydrated on restart.
- showcase/harness/src/orchestrator.ts:3387 — follow-up: D16 —
Unserialized asynchronous reloads can restore stale schedule
configuration.
- showcase/harness/src/orchestrator.ts:3607 — follow-up: D17 — Port-zero
boot handles return requested zero instead of assigned port.

- showcase/harness/src/orchestrator.ts:4538 (also 4493) — follow-up: D18
— Fleet boot/stop signal-handler ownership; stopped generations retain
callbacks and can exit before a replacement drains. Independent
classification: round-3-signal-lifecycle-independent-classification.md.

Origin/classification evidence: round-1-complete-inventory.json;
independent-test-finding-classification.md;
runtime-durability-independent-classification.md;
round-2-lifecycle-independent-classification.md;
round-3-signal-lifecycle-independent-classification.md. Canonical
originating reports and line anchors remain in this directory.


## D5 persistence inventory

# Consolidated D5 follow-ups — bucket (d)

These are confirmed separate subjects, not waived defects and not
current D5 mandatory work. Inherited partition evidence:
../../confirmation/round-2-final-partition.md. Current classification:
round-3-final-partition.md. Bucket(c) empty.

1. Ordinary overlay row-deletion recovery: preserve HTTP404 status from
pb-client.update so ordinary overlay fallback classifies a vanished row.
Actual read/delete/PATCH repro required before a behavior fix; verify
selected atomic409 behavior remains intact.
2. Complete orphan-run boot cleanup: sweepStaleRuns currently visits
only first50. Real51+row proof required; bounded pagination must handle
changing rows and failures without infinite retry.
3. Bounded PocketBase transport operation: auth, fetch and body reads
lack one overall deadline. Real stalled auth/headers/body proof
required, including no attempt after deadline. Do not conflate retry
wait budget with total request deadline.
4. Docker/Railway health recovery documentation: HEALTHCHECK unhealthy
status does not itself restart container. Correct operational comment
against actual supervisor behavior; no implicit runtime restart change.
5. Ordinary probe-run lifecycle documentation: failed also includes
reported negative fleet outcomes, not only execution exceptions.
Document both callers without changing policy.
6. PocketBase retry exception documentation: exhausted429/5xx throws
typed PbHttpError, not Response. Correct existing comment; distinct from
implementing deadline #3.

All behavioral follow-up PRs require actual LOCAL RED before fix, SAME
actual GREEN after fix, raw output in PR body. Comment-only work
requires factual verification and emitted-code equivalence. No follow-up
is marked completed here.


## Rollout

After green CI, use normal main build and `:latest` staging deployments
for both control plane and worker. Verify both deployed
revisions/digests, then enqueue normal selected D5 runs and inspect
fresh persistence and dashboard results. No image pins, status
overrides, or direct staging database edits. Close superseded #7222 only
after this PR merges.
contextablemark added a commit that referenced this pull request Oct 1, 2026
Selected observations can persist a status row even when the
accompanying history write fails. This restores the admin-authenticated
PocketBase transaction endpoint from #7255 so status, history, and a
durable job receipt commit together. Matching retries return the
recorded outcome; stale bases and conflicting identities reject without
partial effects.

The additive, bounded receipt migration is restored byte-for-byte with
original authorship retained. The hook also rejects malformed receipt
maps and incomplete stored receipt entries before writes or replay
acknowledgements. Both defects were reproduced against real PocketBase
databases before correction.

Retained integration checks cover authentication, real
history/receipt-capacity validation rollback, receipt admission, durable
replay, concurrency, stale bases, history fallback, and preserved worker
results. The tests use the official image without custom fault hooks or
a proxy. Removed the test fault hook and legacy/missing-schema modes.
Prior upgraded-volume and application-image rollback evidence remains
available.

Validation: fresh real PocketBase integration suite, scoped Nx
format/lint, JavaScript syntax, and full official Docker image build.
These standalone JavaScript checks have no TypeScript configuration.

This is a database prerequisite: the showcase caller does not yet use
this route. It makes no pill-execution or fleet-health claim. Deploy
before dependent callers and observe a complete staging D5/D6 cycle
before the next rollout. Application rollback must retain schema and
data. No deployment is included.

Restart references: #7255, #7256, #7340. The archived caller requires a
separate narrow change because its retry/skip policy conflicts with the
approved design.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant