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
57 changes: 57 additions & 0 deletions .github/workflows/adk-parallel-replay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: ADK completed sibling replay regression
on:
pull_request:
paths:
- 'examples/adk-parallel-replay/**'
- 'sdk/typescript/**'
- '.github/workflows/adk-parallel-replay.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
replay:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
label: [release-2.11.0, pr-base, pr-fixed]
include:
- label: release-2.11.0
ref: ''
options: ''
- label: pr-base
ref: c220fca16a7e7f7620bde799c50b240f2451ef79
options: '--adk-src upstream-adk/src'
- label: pr-fixed
ref: 3e309d5d3eb753343590e28baf5b8efc547645c8
options: '--adk-src upstream-adk/src --expect-kept'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
if: matrix.ref != ''
with:
repository: google/adk-python
ref: ${{ matrix.ref }}
path: upstream-adk
sparse-checkout: src
- uses: actions/setup-node@v4
with:
node-version: '24.19.0'
- uses: actions/setup-python@v5
with:
python-version: '3.12.10'
- run: npm ci --prefix sdk/typescript
- run: npm run build --prefix sdk/typescript
- run: python -m pip install -r examples/adk-parallel-replay/requirements.lock.txt
- run: python -m pip check
- run: python examples/adk-parallel-replay/verify.py ${{ matrix.options }} --label ${{ matrix.label }} --output evidence/${{ matrix.label }}.json
- run: python examples/adk-parallel-replay/check_evidence.py evidence/${{ matrix.label }}.json
- name: Concurrent boundary and malformed effect controls
if: matrix.label == 'release-2.11.0'
run: node examples/adk-parallel-replay/concurrent-boundary.mjs --local evidence/concurrent-boundary.json
- uses: actions/upload-artifact@v4
with:
name: adk-parallel-${{ matrix.os }}-${{ matrix.label }}
path: evidence/*.json
93 changes: 93 additions & 0 deletions examples/adk-parallel-replay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# ADK completed-sibling replay regression

This isolated lab reproduces [Google ADK #7428](https://github.com/google/adk-python/issues/7428) and compares the exact base and proposed head of [PR #7429](https://github.com/google/adk-python/pull/7429). A successful ticket tool finishes before its parallel pager sibling raises. On affected ADK, the completed tool's response disappears from session history and the next model request.

The provider is a disposable loopback HTTP service. Every write commits a new row to its own SQLite journal; it has **no native deduplication**. The verifier counts those rows independently of Once receipts. Runtime uses no real model or remote provider, and needs no credentials.

## Observed comparison

| ADK code | Completed result saved | History-based retry: raw / Once effects | Forced retry: raw / Once effects |
| --- | --- | --- | --- |
| Released `google-adk==2.11.0` | no | 2 / 1 | 2 / 1 |
| PR base `c220fca16a7e7f7620bde799c50b240f2451ef79` | no | 2 / 1 | 2 / 1 |
| Proposed fix `3e309d5d3eb753343590e28baf5b8efc547645c8` | yes | 1 / 1 | 2 / 1 |

The PR base comparison isolates the proposed fix from other changes since the release. The original pager error propagates unchanged in every version. The failed pager gets no invented response. The scripted model repeats the write if history contains no successful result; a separate adversarial mode forces repetition even when the fixed ADK retains it. This does not reproduce the contributor's live-model 10/10 measurement.

## Protection contract and assertions

The host captures `host-ticket-intent-001` outside model output. ADK call IDs change between attempts; they are transport metadata, never logical identity. Tenant/tool identity, project and title are all effect-bearing fields. Every protected call starts a fresh Node process using the same durable Once file, so a cached in-memory receipt cannot satisfy replay.

Seven real ADK runner scenarios assert history, next-model-request contents, exact receipt replay and independent effect counts: raw/protected history-based retry; raw/protected forced retry; changed-title `CONFLICT`; lost-acknowledgement `UNKNOWN`; and crash-after-commit `UNKNOWN`. The crash host reports uncertainty rather than pretending the missing boundary response is success.

Three additional boundary cases (confirmed, lost acknowledgement, hard crash) each verify title, project and tenant conflicts before dispatch; missing identity rejection; and expected-but-missing ledger rejection. The ambiguous cases remain `UNKNOWN` after unavailable truth or `NOT_FOUND`; neither permits redispatch. An authoritative loopback lookup requires exactly one row matching the original identity **and complete effect**, then confirms and durably replays the receipt. All cases retain exactly one provider effect.

An event handshake orders tool completion before sibling failure; there is no sleep-based scheduling. The test-only claim lease is 1 ms so an abandoned claim is expired by the fresh-process recovery attempt. It is not a production lease recommendation. The host remembers that an existing ledger is expected and checks its presence before SDK initialization; this fixture is not a general host provisioning implementation.

## Run

Requirements: Node 24.19.0 and Python 3.12.10 (CI pins both). Create an isolated Python environment first. From the repository root:

```sh
python -m venv .venv
# POSIX: source .venv/bin/activate
# PowerShell: .venv\Scripts\Activate.ps1
npm ci --prefix sdk/typescript
npm run build --prefix sdk/typescript
python -m pip install -r examples/adk-parallel-replay/requirements.lock.txt
python examples/adk-parallel-replay/verify.py --output release.json
python examples/adk-parallel-replay/check_evidence.py release.json
```

For the source comparison, clone Google ADK separately and create two detached worktrees:

```sh
git clone https://github.com/google/adk-python.git upstream-adk
git -C upstream-adk fetch origin pull/7429/head
git -C upstream-adk worktree add ../adk-base c220fca16a7e7f7620bde799c50b240f2451ef79
git -C upstream-adk worktree add ../adk-fixed 3e309d5d3eb753343590e28baf5b8efc547645c8
python examples/adk-parallel-replay/verify.py --adk-src adk-base/src --label pr-base --output base.json
python examples/adk-parallel-replay/verify.py --adk-src adk-fixed/src --expect-kept --label pr-fixed --output fixed.json
```

Git resolves those worktree paths relative to `upstream-adk`, so both worktrees are created in the repository root. If running Git from another directory, use absolute worktree paths. Do not run Python with `-O`: the verifier refuses execution with assertions disabled. All Python dependencies are version-pinned; this is a version lock, not a hash-verified supply-chain lock. Run `python -m pip check` to check the installed dependency graph.

Generated JSON has `schema_version: 1` and `status: PASS` only after all assertions pass. It includes the source revision (when supplied), ADK runner/SDK entry/requirements SHA-256 hashes, receipts, independently read provider rows, and each no-dispatch safety probe with before/after row counts. Reconciliation is a read-only operation despite the fixture lookup using HTTP POST. `NOT_FOUND` and unavailable truth responses are injected adapter responses, not a demonstration of real-provider absence. Evidence records machine-observable fixture assertions; it is not an independently authored audit or a tamper-proof provider attestation.

`check_evidence.py` checks the generated JSON offline. A separate falsification control rejects mismatched effects and non-unique lookup rows, and verifies that a new host intent can create another ticket. That control deliberately bypasses Once once to create a duplicate; its three provider rows are reported separately and are not included in the protected-scenario counts. The fixture has no native idempotency; providers with sufficient native idempotency or constraints should use them. A retry must retain the original intent ID; minting a new one would permit another effect.

`--sdk-url file:///absolute/path/to/node_modules/@once-agent/sdk/dist/index.js` tests a clean packed or published consumer. The checked evidence records both against released ADK, using SDK 0.1.25. Default execution uses the repository SDK build. The separate workflow repeats the release/base/fix matrix and uploads generated evidence. Its remote result must be checked separately from local results.

## Validation recorded on 9 October 2026

All five local fixture runs passed again from a clean checkout/environment: release, exact PR base, exact PR head, clean packed Once consumer and clean registry consumer. Each runs seven ADK scenarios, three boundary cases and the separate lookup/fresh-intent falsification control (35 ADK scenarios, 15 boundary cases, five falsification controls total). All five JSON files passed the offline checker. `evidence.json` contains their model/session observations, receipts, probe traces and independently counted provider rows. Recorded platform: Windows, Python 3.12.10, Node 24.19.0. Full `npm run test:release --prefix sdk/typescript` exited 0 (200 Node tests plus package/contract/regression scripts); the focused safety subset passed 58/58 and the additional SDK safety regression 2/2. These are local results; inspect CI separately for the current PR commit.

The focused upstream tests are taken from the proposed head in both comparisons:

```sh
PYTHONPATH=adk-fixed/src python -m pytest adk-fixed/tests/unittests/test_runners.py adk-fixed/tests/unittests/flows/llm_flows/tools/test_batch_executor.py -k 'tool_error or keep_completed or plain_result' -q
# Repeat with PYTHONPATH=adk-base/src, keeping the same head test files.
```

The head passed 16 tests; the base failed 14 and passed the two regression guards (200 deselected). Optional upstream-test dependencies are separate from the fixture lock: `a2a-sdk[http-server]==1.2.2`, `pytest-mock==3.16.0`, `google-api-core==2.28.1`, and `opentelemetry-api==1.42.1`. The full upstream suite was not run.

Repository checks passed: SDK build; `node --test test/tool-call.test.mjs test/local.test.mjs test/wrap-tool.test.mjs test/wrap-tool-mcp.test.mjs test/first10.test.mjs` from `sdk/typescript` (58 tests); `npm run test:first10-package`; `npm run test:wrap-tool-package` (14 ESM/CJS checks plus TypeScript contracts); `node scripts/generate-first10-proof.mjs --check`; `node scripts/check-site-surface.mjs`; and `node scripts/generate-site-surface.mjs --check` from the root. No proof asset drift required regeneration. Initial restricted-network fixture execution and direct invocation of package scripts did not pass; the recorded passes use loopback access and the required npm entry points.

## Limits

### Supplementary same-machine boundary concurrency

`node examples/adk-parallel-replay/concurrent-boundary.mjs SDK_FILE_URL OUTPUT.json`
starts twelve fresh Node workers against one durable authority and a separate provider
SQLite journal. It asserts one original effect, exact receipt recovery for blocked
workers, five malformed effect shapes rejected before dispatch, changed-effect
conflict and a second effect only for a new intentional host identity. It uses a
30-second lease; the sequential crash lab's 1 ms lease is unsuitable for this
overlap test. Cold SQLite initialization can fail closed with `STATE_UNAVAILABLE`;
the test records that status and requires subsequent same-identity receipt replay.
This qualifies the local boundary only, not ADK runner concurrency or distributed
storage. Windows passes do not qualify this supplementary test on Linux.

See the [adversarial comparison review](adversarial-review.md) and [experimental branch deployment controls](deployment-controls.md). CI repeats all three ADK variants on Windows and Linux with pinned runtimes, checks the installed dependency graph and verifies the generated JSON before uploading it. A failed rerun removes any old output at its requested path so stale PASS evidence cannot be mistaken for a current result.

This is deterministic same-machine integration evidence with independently counted **fixture** effects. ADK session history is in memory; Once state and provider effects are durable SQLite. The Once boundary restarts, but this does not qualify whole-framework crash recovery, distributed authority, live mode, confirmation/control-flow results, cancellation races, opaque provider retries, real-model decisions or production providers. It changes no protection kernel or public API. It demonstrates neither universal exactly-once execution nor independent production qualification, adoption or endorsement by Google.
25 changes: 25 additions & 0 deletions examples/adk-parallel-replay/adversarial-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Comparison review, 9 October 2026

## What the comparison establishes

Raw and protected cases use the same scripted model, tool inputs, logical intent and non-deduplicating loopback provider. Every POST commits a provider journal row. The verifier queries that journal separately from boundary output. Each scenario gets isolated provider and Once files: the shared intent string across scenarios does not represent one global operation.

The model's history-based policy is an explicit assumption, not evidence of every real model's decision. The proposed ADK fix keeps the successful result and therefore avoids that scripted repeat (raw and protected both have one effect). Forced replay deliberately ignores retained history and shows the separate external-effect boundary (raw two, protected one). Keeping successful tool history and protecting an external effect solve different failure paths. The reported callback workaround in #7428 also retains results but changes exception propagation; it is not tested by this lab.

## Identity and effects

The host owns `host-ticket-intent-001` outside model output; ADK call IDs vary. Tenant/tool, project and title are bound. All routes in the protected scenario enter the boundary. Changing title/project/tenant conflicts before another provider row is added. A fresh host intent is allowed to create a second ticket; changing identity is not an acceptable retry. Native provider idempotency is intentionally absent. This does not establish superiority over adequate native idempotency or a database constraint.

## Restart and uncertainty

Each protected tool invocation starts a fresh Node process with the same durable SQLite path; exact confirmed receipts replay across processes. Crash after provider commit leaves uncertainty and the next process returns UNKNOWN without POSTing again. Lost acknowledgement is simulated by throwing after receipt parsing; it is not a TCP fault injection. The 1 ms lease only expedites sequential fixture recovery. There are no overlapping claims or distributed authorities. ADK sessions and the Python host's expected-ledger flag stay in memory. The whole framework does not restart. Expected-but-missing state rejection is host logic and does not establish general provisioning, filesystem attack resistance or atomic state admission.

## Reconciliation and evidence

The provider lookup accepts exactly one matching operation row with the complete effect. Changed effects and duplicate rows return UNKNOWN in a separate falsification control. That control deliberately performs one bypass write to create the duplicate and reports its three rows separately. Unavailable truth and NOT_FOUND are injected adapter responses; they leave uncertainty blocked. Successful authoritative fixture lookup produces the exact ticket/effect receipt, then another fresh process replays it. Before/after provider counts are checked and recorded for every no-dispatch probe.

The SDK trusts the host's reconciliation callback. No claim is made that Once itself validates arbitrary provider truth. These are independently counted fixture effects, not independent authorship, production qualification, tamper-proof attestation or evidence of Google endorsement. Source revisions and entry hashes aid reproduction, but the dependency lock pins versions without distribution hashes. The offline checker validates JSON consistency; it cannot prove that supplied JSON came from a genuine run.

## Unqualified paths

No live model/provider, whole-runner crash recovery, concurrent/distributed authority, cancellation race, opaque provider retry, live mode or confirmation/control-flow result coverage. The full upstream ADK suite is not run. No universal exactly-once claim. PR #7429 remains an upstream proposal; this lab does not endorse or speak for Google.
43 changes: 43 additions & 0 deletions examples/adk-parallel-replay/boundary.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Disposable test boundary. Every request runs in a new Node process.
import { readFileSync, existsSync } from 'node:fs';
const request = JSON.parse(readFileSync(0, 'utf8'));
const { protectToolCall } = await import(request.sdkUrl || new URL('../../sdk/typescript/dist/index.js', import.meta.url).href);
try {
// The host remembers whether authority should already exist across restart.
// Do not let SDK initialization recreate expected-but-missing state.
if (request.expectedState && !existsSync(request.statePath)) {
throw Object.assign(Error('Expected ledger missing'), { code: 'STATE_UNAVAILABLE' });
}
const result = await protectToolCall({
operationId: request.operationId,
effect: request.effect,
statePath: request.statePath,
leaseMs: request.leaseMs ?? 1,
metadata: request.metadata,
execute: async effect => {
const response = await fetch(request.providerUrl + '/tickets', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ operationId: request.operationId, effect }),
signal: AbortSignal.timeout(5000),
});
if (!response.ok) throw Error('Provider response failed');
const receipt = await response.json();
if (request.mode === 'crash') process.exit(71);
if (request.mode === 'lost-ack') throw Error('Acknowledgement lost after provider commit');
return receipt;
},
reconcile: request.reconcile ? async ({ operationId, effect }) => {
if (request.reconcile === 'NOT_FOUND') return { status: 'NOT_FOUND' };
if (request.reconcile === 'UNKNOWN') return { status: 'UNKNOWN' };
const response = await fetch(request.providerUrl + '/lookup', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ operationId, effect }), signal: AbortSignal.timeout(5000),
});
if (!response.ok) return { status: 'UNKNOWN' };
return response.json();
} : undefined,
});
console.log(JSON.stringify({ status: 'CONFIRMED', result }));
} catch (error) {
console.log(JSON.stringify({ status: error.code || 'ERROR', message: error.message }));
}
Loading
Loading