Skip to content

fix(addie): let a certification completion retry after a known gate rejection - #9196

Merged
bokelley merged 4 commits into
mainfrom
fix/academy-9085-9086
Nov 23, 2026
Merged

bokelley merged 4 commits into
mainfrom
fix/academy-9085-9086

Conversation

@bokelley

@bokelley bokelley commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9085

Root cause

Addie's tool executor fences identical mutations within one model turn. createAddieToolExecutor adds each mutation's replay key to dispatchedSideEffects before dispatch and refuses a second identical call with Error: Duplicate external action blocked; its prior outcome was not retried automatically.

The key stayed in the set even when complete_certification_module returned a definitive gate rejection. A gate rejection writes nothing. The production traces behind the escalations all follow the same sequence in one turn:

  1. complete_certification_module({module_id, scores}) returns NOT COMPLETED — … You must save at least one teaching checkpoint (or … has no preliminary_scores).
  2. checkpoint_teaching_progress saves the missing checkpoint, with every criterion verified and preliminary scores set.
  3. The identical complete_certification_module call is refused as a duplicate. Sage then tells the learner completion is blocked and escalates.

The other replay guards already treat these outcomes as retry-safe. The durable reservation check in ThreadService and the interrupted-turn policy in blockCheckpointedToolReplays both accept a normal return from a DURABLE_HANDLER_OUTCOME_TOOLS handler as a known outcome (durable_outcome: 'known'). Only the in-turn fence ignored it.

Read-only production data, last 120 days: the duplicate block fired on complete_certification_module in 11 threads and on start_certification_module in 6. Each one followed a known gate result. Most learners recovered in a later turn. Two escalated learners, and one who did not escalate, are still stuck in_progress.

Fix

server/src/addie/side-effect-claims.ts adds SAME_TURN_RETRYABLE_TOOLS: complete_certification_module and start_certification_module. server/src/addie/model-providers/tool-orchestration.ts releases the fence for these two once their handler returns normally.

A known outcome alone does not make a repeat safe. checkpoint_teaching_progress inserts a new row on every call, so replaying an older identical checkpoint would make its evidence the latest. These two handlers re-check every gate before they write:

  • After a gate result, such as NOT COMPLETED or an unmet prerequisite, the same call made again is decided afresh through policy, the durable reservation and the handler.
  • After a success, a repeat takes the handler's own already-recorded path. complete_certification_module returns Module X completed! This module was already recorded as complete. with no second write and no second award. start_certification_module resumes the in-progress row, keeping its status and started_at, and advances the attempts counter as every resume does.
  • A thrown handler has an unknown outcome and stays fenced. Every other mutation stays fenced as before, including the other durable-handler tools.

CODE_VERSION is bumped to 2026.11.3 because this changes Addie tool dispatch. There is no changeset: this is app-only.

Known residual: delivery paths that persist only at the end of the turn

On the streaming web, Slack-streaming and Tavus paths, each tool result is persisted as it ends (buildToolResultCheckpoint). That settles the durable reservation before the next call, so the in-turn retry now goes through. The non-streaming paths (processMessage in routes/addie-chat.ts, Slack bolt-app.ts, email-conversation-handler.ts) persist results only after the turn. There, an identical retry in the same turn is still refused, now by the durable reservation check ("durable outcome reservation failed") instead of the in-turn fence. It still fails closed, and the next turn succeeds because the end-of-turn persistence settles the earlier reservation.

In production over the last 60 days, every certification thread that called these tools used a path that persists per tool. None used a non-streaming path. Persisting each durable outcome as it lands on the non-streaming paths means threading a settle callback through ProcessMessageOptions to eight call sites, so it is left for a follow-up.

Tests

server/tests/unit/addie/model-provider-tool-orchestration.test.ts:

  • An identical completion after a known gate rejection is dispatched again and succeeds.
  • A repeat after success is passed to the handler, not blocked.
  • start_certification_module is dispatched again after a prerequisite redirect.
  • Replaying an earlier identical checkpoint_teaching_progress after a later checkpoint is still blocked.
  • A thrown durable handler stays fenced.
  • A non-durable mutation stays fenced after a normal error return.

The re-dispatch tests fail on the pre-fix executor.

Learners already blocked

The code fix does not unblock learners who are already stuck. A reviewed, idempotent backfill has been handed to a maintainer and has not been run. It completes the module from the exact checkpoint that verified every criterion, writes an admin_module_completions audit row, and awards any credential that becomes eligible. No learner identifiers are in this PR.

🤖 Generated with Claude Code

bokelley and others added 2 commits November 23, 2026 15:30
…ejection

The per-turn duplicate-mutation fence kept every complete_certification_module
call it dispatched, including ones whose handler returned a definitive
"NOT COMPLETED" gate result without writing anything. Sage would save the
missing checkpoint or preliminary scores and call the identical completion
again in the same turn, and the executor refused it as a duplicate external
action, stranding the learner's module in progress.

A normal return from an allowlisted durable-handler tool now releases the
fence, matching the durable reservation and interrupted-turn replay rules
that already treat those outcomes as retry-safe. A repeat after success
reaches the handler's idempotent already-recorded path; a thrown handler
stays fenced.

Fixes #9085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 23, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — app-only fix to Addie's durable-handler replay fence with no blocking or medium findings.

What I checked:

  • tool-orchestration.ts:888 releases the in-turn replay fence only on a normal handler return when hasDurableHandlerOutcome(call.name); a thrown handler stays fenced (catch at L982 does not delete). Scope limited to the six certification tools in DURABLE_HANDLER_OUTCOME_TOOLS; non-durable mutations (create_github_issue) untouched.
  • Load-bearing safety claim verified: repeat-after-success reaches idempotent already-recorded paths (complete_certification_module L2126-2140, complete_certification_exam L2763-2785) with skip-if-held credential re-checks — no double-award.
  • Four new tests cover gate-rejection re-dispatch, repeat-after-success, thrown-stays-fenced, and non-durable-stays-fenced.
  • No protocol surface touched (no static/schemas/source/**, docs/reference/**, or dist/** changes); changeset correctly omitted per app-only scope. CODE_VERSION bumped to 2026.11.3.

Gate evaluation: No no-auto-approve team match. gated_paths is false. high_risk is true but both reasons are (modified) with zero medium-or-higher findings (rows 3/5 require a deletion or a medium finding). No critical/high/medium findings. No prior decision. Falls through to row 9 → approve.

bokelley and others added 2 commits November 23, 2026 15:43
…ion handlers

A known handler outcome does not make a repeat safe:
checkpoint_teaching_progress inserts a new row per call, so replaying an
older identical checkpoint later in the turn would make its evidence the
latest. Limit the release to complete_certification_module and
start_certification_module, which re-check every gate before writing and
take their own already-recorded path on a repeat after success.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve.

Clean pass. This PR narrows the durable-outcome fence release to a vetted SAME_TURN_RETRYABLE_TOOLS allowlist (complete_certification_module, start_certification_module), keeping checkpoint_teaching_progress and the exam tools fenced — a fail-closed tightening on the certification path. The subset constraint is enforced via as const satisfies, and six new dispatch tests cover the behavior. App-only change, no protocol wire surface touched, no changeset required, CODE_VERSION bump is correct.

High-risk flag is set only due to server/src/addie/** glob matches on modified files, but the reviewer found no medium-or-higher concerns, so the modifications are presumed safe (no deletions, no sensitive-category findings). gated_paths is false; no no-auto-approve team match. No Critical/High/Medium findings. Prior decision was also a clean approve.

Decision table: rows 1–8 do not fire (no critical/high/medium findings; gated_paths false; no deletions; no team gate), so falls through to row 9 → approve.

@bokelley
bokelley merged commit 475633c into main Nov 23, 2026
31 checks passed
@bokelley
bokelley deleted the fix/academy-9085-9086 branch November 23, 2026 17:28
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 25, 2026
…, certification retry (adcontextprotocol#9196), release-audit changesets (adcontextprotocol#8879), reporting subscriber suspend and resume (adcontextprotocol#9199), inventory goal forecast refusal (adcontextprotocol#9206), enum hoisting annotations (adcontextprotocol#9167), format_option_ref (adcontextprotocol#8876), claim-priority indexes (adcontextprotocol#9219)

Two conflicts.

Resolution ledger:
- semantic: package.json `test` -> union: this branch's chain (the
  suites it added and the build-cache and git-env steps) plus main's
  test:build-schemas-hoist-enum-annotations and
  test:build-schemas-hoist-inside-definitions, after
  test:build-schemas-exit-status. Every script main's chain runs is in
  the merged chain. Dependencies auto-merged to main's versions.
- semantic: server/src/training-agent/gcs-reporting.ts imports -> union:
  this branch's narrow `@adcp/sdk/utils` import of canonicalize; main's
  randomUUID import and its added `@adcp/sdk/server` names. The rest of
  the file auto-merged.
- mechanical: package-lock.json -> main's (auto-merged; this branch
  does not change it).

Checks: npm ci on main's lockfile (SDK 17.0.0-beta.40), npm run
typecheck, and the pre-commit hook's full run.
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.

fix(academy): duplicate action lock on complete_certification_module blocks module finalization

1 participant