diff --git a/README.md b/README.md index 1bf8592..4ca01e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Support Desk +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](docs/RELEASING.md#source-version-0213). + [![CI](https://github.com/pegma-dev/support-desk/actions/workflows/ci.yml/badge.svg)](https://github.com/pegma-dev/support-desk/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) diff --git a/docs/ENGINEERING_FOLLOWUP.md b/docs/ENGINEERING_FOLLOWUP.md index 54b65de..7c15325 100644 --- a/docs/ENGINEERING_FOLLOWUP.md +++ b/docs/ENGINEERING_FOLLOWUP.md @@ -129,6 +129,16 @@ ports. Its route, privacy, tokenizer and checker qualification stay explicit; provider and host activation remain pending. Retest requests remain advisory until the owning trusted evidence workflow verifies their actual execution. +The [unpublished 0.2.13 SD05 checker group source](../packages/ai/README.md#unreleased-source-sd05-independent-check-provider-groups) +adds explicit route/static-allowlist/Admin group approval and hash-bound price +ceilings to independent whole-bundle checks only. Its separate live SD05 +purpose/wire evidence, Source/Work guards and `sf1` receipt domain remain +required. Approval renewal cannot change a queued selector, scope, price or +route-policy hash. Generators retain their endpoint-qualified route policy. +Published `0.2.12` still refuses SD05 group checks; hosts must await a verified +`0.2.13` release and qualify their actual group privacy, request, model and +Free CPU before activation. This source change supplies no live authority. + diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 63b4cf2..8fe2f75 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -1,5 +1,20 @@ # Release notes + + +## 0.2.13 source candidate — SD05 independent-check provider groups + +SD05 independent whole-bundle checks may explicitly opt into the same +route/static-allowlist/Admin-approved group scope and hash-bound price ceilings +as learning and engineering checks. The separate SD05 evidence and `sf1` MAC +domain, current Source/Work fences, approval renewal identity, conservative +native-charge accounting and exact receipt recovery remain required. +Generators, legacy absent-key routes/wires/hashes, defaults and external +dependency selections are unchanged. All five source package versions and exact +internal Support pins now select **unpublished `0.2.13`**; the root remains +private at `0.0.0`. No public release, live provider qualification or host +activation is included; published `0.2.12` retains its SD05 refusal. See the [source contract](../packages/ai/README.md#unreleased-source-sd05-independent-check-provider-groups). + diff --git a/docs/RELEASING.md b/docs/RELEASING.md index c54cb22..56a2fd2 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -1,5 +1,27 @@ # Release operations + + +## 0.2.13 source preparation: 2026-11-14 + +All five source package versions and exact internal Support pins select +**unpublished `0.2.13`**, including the root Support development pins and +matching workspace lock importers. The root remains private at `0.0.0`; exact +KB application/contracts `0.1.8` and all other external selections are unchanged. + +The candidate extends explicit route/static-allowlist/Admin-approved group +routing to SD05 independent checks only. Separate SD05 evidence, `sf1` receipt +binding, current Source/Work fences, immutable queued route identity and native +usage accounting remain required. Generators and omitted-option request bytes +and hashes are unchanged. See the [candidate notes](RELEASE_NOTES.md#0213-sd05-provider-group-checks). + +The required source gates below, configured review and CI must pass on the +reviewed head before the maintainer performs the protected signed-tag/OIDC +release. The current verified public release remains `0.2.12`, with its original +receipt, assets and history below unchanged. Candidate metadata is not a +publication receipt or authority for host adoption, paid calls, customer AI, +provider privacy/quality, requested clients or Free invocation/CPU acceptance. + ## Verified 0.2.12 publication: 2026-11-14 diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index ed3bdf6..4b47bf9 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1,5 +1,24 @@ # Upgrading synchronized Support Desk packages +## 0.2.13 source candidate: SD05 checker provider-group opt-in + +The source SD05 independent checker now accepts the existing explicit group +route, matching static allowlist scope and current Admin scope approval, with +the complete hash-bound `providerMaxPrice` policy. This is not a generator +capability or a default selector change. Its separate SD05 purpose/wire +evidence and receipt MAC, current Source/Work checks, native usage accounting +and finite approval/attempt lifetimes are retained. Benign approval-date +renewals cannot widen group scope or prices or replace a queued route hash. + +All five source versions and internal Support pins select unpublished +`0.2.13`, with root development pins and workspace lock importers synchronized. +External dependency selections remain unchanged. No published artifact is +claimed. Hosts must preserve the public `0.2.12` SD05 group refusal until a separately +verified release supplies the feature. Requalify the actual model, route hash, +full SYSTEM/USER wire, token counter and framing, provider-group privacy, +native cost and host Free CPU; do not relabel prior endpoint evidence or +activate customer AI from source tests. See the [adapter contract](../packages/ai/README.md#unreleased-source-sd05-independent-check-provider-groups). + The current verified synchronized release is `0.2.12`; see its [publication receipt](RELEASING.md#verified-0212-publication-2026-11-14). Hosts must qualify the [new checker wire](../packages/ai/README.md#optional-openrouter-adapter) diff --git a/package.json b/package.json index 8a976d3..800825e 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ "@pegma/spine": "0.1.2", "@pegma/storage-azure-tables": "0.4.0", "@pegma/storage-core": "0.4.0", - "@pegma/support-desk-ai": "0.2.12", - "@pegma/support-desk-application": "0.2.12", - "@pegma/support-desk-templates": "0.2.12", + "@pegma/support-desk-ai": "0.2.13", + "@pegma/support-desk-application": "0.2.13", + "@pegma/support-desk-templates": "0.2.13", "@types/node": "^26.6.6", "azurite": "^3.37.0", "prettier": "^3.9.10", diff --git a/packages/ai/README.md b/packages/ai/README.md index 6574749..611be89 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -1,7 +1,12 @@ # @pegma/support-desk-ai +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](../../docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](../../docs/RELEASING.md#source-version-0213). + The synchronized `0.2.12` release is published and strictly verified. Its -internal Support application pin is exact `0.2.12`; external KB +published internal Support application pin is exact `0.2.12`; external KB application/contracts retain exact verified public `0.1.8`. See the [publication receipt](../../docs/RELEASING.md#verified-0212-publication-2026-11-14) and [release notes](../../docs/RELEASE_NOTES.md#0212-opt-in-provider-group-checks). @@ -424,8 +429,9 @@ plans. Published `0.2.12` permits an explicitly approved provider group for learning and engineering independent checks. Structural support does not activate a host or authorize a live call. -Answering and generation routes retain their existing policies; the release -follow-up checker refuses group mode before funding. +Answering and generation routes retain their existing policies. Published +`0.2.12` release-follow-up checks refuse group mode before funding; the +unreleased source extension below is not a published host dependency. The host must set `providerSelectionScope: "provider_group"` in all three places: the independent-check route, its matching static allowlist entry, and @@ -475,6 +481,38 @@ as free or retried automatically. The dated receipt records SDK qualification and publication; each host's current privacy, evaluation and activation gates remain separate. + + +### 0.2.13 source candidate: SD05 independent-check provider groups + +The source `createSupportReleaseFollowupChecks` now permits the same explicit +three-part group opt-in described above. This extends only SD05 independent +checks, not `createSupportReleaseFollowupModel` or any generator. Hosts must +wait for a separately reviewed and verified public release; published `0.2.12` +still has its documented SD05 refusal. The five source versions and internal pins select unpublished `0.2.13`; +no default route, credential, host profile or provider choice is activated. + +SD05 still requires current, separate `route.releaseFollowup` evidence for +`support_release_followup` and `openrouter-support-release-followup-check-v1`. +Its validity must cover the current independent-check approval. Complete input, +purpose, Source/Work authority and before-physical-call guards remain mandatory. +The producer remains independent-check wire v2 with the unchanged verdict +schema; a group selector does not authorize an engineering receipt as SD05. + +The distinct `sf1` receipt MAC still binds the SD05 purpose, route-policy hash, +configuration and policy. A benign Admin approval renewal may extend only its +observation dates, within the existing evidence ceilings; it cannot change the +group, selector scope, prices or approved hash, or extend a retained attempt's +or receipt's lifetime. Deferred provider/receipt phases retain the exact queued +configuration identity and refuse semantic route changes even when separately +newly approved. Native charges, conservative unknown usage and no-automatic-retry +behavior are unchanged. Invalid groups reach no provider credential, funding +or fetch; existing receipt-signing-key reads/order are unchanged. + +Legacy absent-key route hashes and complete wire bytes retain their golden +regressions. Source/unit qualification does not establish live group privacy, +model quality, tokenizer framing, deployed Free CPU or activation acceptance. + ### Release follow-up provider ports Published `0.2.9` adds `createSupportReleaseFollowupModel(options, diff --git a/packages/ai/package.json b/packages/ai/package.json index 0581d0e..74c8705 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/support-desk-ai", - "version": "0.2.12", + "version": "0.2.13", "description": "Optional bounded, provider-neutral Support Desk answer coordinator.", "license": "MIT", "type": "module", @@ -42,7 +42,7 @@ "@pegma/knowledge-base-application": "0.1.8", "@pegma/knowledge-base-contracts": "0.1.8", "@pegma/spine": "0.1.2", - "@pegma/support-desk-application": "0.2.12", + "@pegma/support-desk-application": "0.2.13", "@pegma/storage-core": "0.4.0", "zod": "4.6.7" } diff --git a/packages/ai/src/openrouter/support-independent-checks-model.ts b/packages/ai/src/openrouter/support-independent-checks-model.ts index 722038f..973d80c 100644 --- a/packages/ai/src/openrouter/support-independent-checks-model.ts +++ b/packages/ai/src/openrouter/support-independent-checks-model.ts @@ -507,8 +507,8 @@ export function createSupportIndependentCheckModel( ) { const host = checkedLogicalHost(logicalHost); // Capture per-instance policy before callers can mutate the supplied object. - // SD05 alone opts into approval renewal and explicitly disables groups. - // Independent checks support groups only with route/allowlist/approval opt-in. + // SD05 alone opts into approval renewal. Group routing still requires the + // route, static allowlist and current approval to opt in together. const allowApprovalRenewal = attemptPolicy?.allowApprovalRenewal === true; const allowProviderGroup = attemptPolicy?.allowProviderGroup !== false; const sameRoute = ( @@ -725,7 +725,6 @@ export function createSupportIndependentCheckModel( const r = read(config.version); if ( !r?.releaseFollowup || - r.providerSelectionScope !== undefined || !live(r.releaseFollowup, Date.parse(options.clock.now())) || Date.parse(r.approval.validUntil) > Date.parse(r.releaseFollowup.validUntil) @@ -827,7 +826,6 @@ export function createSupportIndependentCheckModel( followupInput(input); if ( !route.releaseFollowup || - route.providerSelectionScope !== undefined || !live(route.releaseFollowup, Date.parse(options.clock.now())) || Date.parse(route.approval.validUntil) > Date.parse(route.releaseFollowup.validUntil) diff --git a/packages/ai/src/openrouter/support-release-followup-checks.ts b/packages/ai/src/openrouter/support-release-followup-checks.ts index cd6b03c..3344538 100644 --- a/packages/ai/src/openrouter/support-release-followup-checks.ts +++ b/packages/ai/src/openrouter/support-release-followup-checks.ts @@ -296,7 +296,7 @@ export function createSupportReleaseFollowupChecks( const host = checkedLogicalHost(logicalHost); const model = createSupportIndependentCheckModel(options, host, { allowApprovalRenewal: true, - allowProviderGroup: false, + allowProviderGroup: true, }); const policy = options.usagePolicy === undefined diff --git a/packages/application/README.md b/packages/application/README.md index df8523e..2d9763d 100644 --- a/packages/application/README.md +++ b/packages/application/README.md @@ -1,5 +1,10 @@ # @pegma/support-desk-application +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](../../docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](../../docs/RELEASING.md#source-version-0213). + The synchronized `0.2.12` release is published and strictly verified. It adds opt-in provider-group routing for optional AI independent checks without adding an application API. See the [publication receipt](../../docs/RELEASING.md#verified-0212-publication-2026-11-14) diff --git a/packages/application/package.json b/packages/application/package.json index 9706dd2..5d08fd7 100644 --- a/packages/application/package.json +++ b/packages/application/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/support-desk-application", - "version": "0.2.12", + "version": "0.2.13", "description": "Authorized application services, declared collections, and durable outbox records for Support Desk.", "license": "MIT", "type": "module", @@ -39,7 +39,7 @@ "@pegma/mail": "0.1.1", "@pegma/spine": "0.1.2", "@pegma/storage-core": "0.4.0", - "@pegma/support-desk-contracts": "0.2.12", - "@pegma/support-desk-core": "0.2.12" + "@pegma/support-desk-contracts": "0.2.13", + "@pegma/support-desk-core": "0.2.13" } } diff --git a/packages/contracts/README.md b/packages/contracts/README.md index ff5fb99..b292c7b 100644 --- a/packages/contracts/README.md +++ b/packages/contracts/README.md @@ -1,5 +1,10 @@ # @pegma/support-desk-contracts +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](../../docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](../../docs/RELEASING.md#source-version-0213). + The synchronized `0.2.12` release is published and strictly verified. See the [publication receipt](../../docs/RELEASING.md#verified-0212-publication-2026-11-14), [release notes](../../docs/RELEASE_NOTES.md#0212-opt-in-provider-group-checks) diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 4675d17..6339855 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/support-desk-contracts", - "version": "0.2.12", + "version": "0.2.13", "description": "Provider-neutral ticket and message contracts for Support Desk.", "license": "MIT", "type": "module", diff --git a/packages/core/README.md b/packages/core/README.md index c965493..383e366 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -1,5 +1,10 @@ # @pegma/support-desk-core +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](../../docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](../../docs/RELEASING.md#source-version-0213). + The synchronized `0.2.12` release is published and strictly verified. See the [publication receipt](../../docs/RELEASING.md#verified-0212-publication-2026-11-14), [release notes](../../docs/RELEASE_NOTES.md#0212-opt-in-provider-group-checks) diff --git a/packages/core/package.json b/packages/core/package.json index dc03d6a..f3db4fe 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/support-desk-core", - "version": "0.2.12", + "version": "0.2.13", "description": "Pure ticket creation and workflow transitions for Support Desk.", "license": "MIT", "type": "module", @@ -29,7 +29,7 @@ "directory": "packages/core" }, "dependencies": { - "@pegma/support-desk-contracts": "0.2.12" + "@pegma/support-desk-contracts": "0.2.13" }, "scripts": { "build": "tsc -p tsconfig.json", diff --git a/packages/templates/README.md b/packages/templates/README.md index 490a2c3..4f7bf10 100644 --- a/packages/templates/README.md +++ b/packages/templates/README.md @@ -1,5 +1,10 @@ # @pegma/support-desk-templates +This checkout prepares the synchronized **unpublished `0.2.13` candidate** +for SD05 independent-check provider groups. The current verified public release +remains `0.2.12`. See the [candidate notes](../../docs/RELEASE_NOTES.md#0213-sd05-provider-group-checks) +and [source preparation](../../docs/RELEASING.md#source-version-0213). + The synchronized `0.2.12` release is published and strictly verified. See the [publication receipt](../../docs/RELEASING.md#verified-0212-publication-2026-11-14), [release notes](../../docs/RELEASE_NOTES.md#0212-opt-in-provider-group-checks) diff --git a/packages/templates/package.json b/packages/templates/package.json index 94c3687..7fbc528 100644 --- a/packages/templates/package.json +++ b/packages/templates/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/support-desk-templates", - "version": "0.2.12", + "version": "0.2.13", "description": "Safe, versioned notification templates for Support Desk.", "license": "MIT", "type": "module", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ec85e0..ac60380 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,13 +39,13 @@ importers: specifier: 0.4.0 version: 0.4.0 '@pegma/support-desk-ai': - specifier: 0.2.12 + specifier: 0.2.13 version: link:packages/ai '@pegma/support-desk-application': - specifier: 0.2.12 + specifier: 0.2.13 version: link:packages/application '@pegma/support-desk-templates': - specifier: 0.2.12 + specifier: 0.2.13 version: link:packages/templates '@types/node': specifier: ^26.6.6 @@ -81,7 +81,7 @@ importers: specifier: 0.4.0 version: 0.4.0 '@pegma/support-desk-application': - specifier: 0.2.12 + specifier: 0.2.13 version: link:../application zod: specifier: 4.6.7 @@ -105,10 +105,10 @@ importers: specifier: 0.4.0 version: 0.4.0 '@pegma/support-desk-contracts': - specifier: 0.2.12 + specifier: 0.2.13 version: link:../contracts '@pegma/support-desk-core': - specifier: 0.2.12 + specifier: 0.2.13 version: link:../core packages/contracts: @@ -120,7 +120,7 @@ importers: packages/core: dependencies: '@pegma/support-desk-contracts': - specifier: 0.2.12 + specifier: 0.2.13 version: link:../contracts packages/templates: {} diff --git a/test/openrouter-release-followup-fixtures.ts b/test/openrouter-release-followup-fixtures.ts index 1d895c5..26bbc21 100644 --- a/test/openrouter-release-followup-fixtures.ts +++ b/test/openrouter-release-followup-fixtures.ts @@ -152,6 +152,9 @@ export async function followupControllerFixture( fixtureOptions: { readonly privateNote?: string; readonly maxModelAttempts?: number; + readonly configureChecker?: ( + wire: Awaited>, + ) => void | Promise; } = {}, ) { const wire = await checkerModelFixture(); @@ -249,6 +252,8 @@ export async function followupControllerFixture( validUntil: wire.route.approval.validUntil, }); // The factory snapshots policy at creation: create it only after clock alignment. + if (fixtureOptions.configureChecker) + await fixtureOptions.configureChecker(wire); const { approval: ignored, ...shifted } = wire.route; void ignored; wire.route.approval.requestPolicySha256 = @@ -261,7 +266,12 @@ export async function followupControllerFixture( export async function followupChecksFixture( store: Store = createMemoryStore(), - fixtureOptions: { readonly privateNote?: string } = {}, + fixtureOptions: { + readonly privateNote?: string; + readonly configureChecker?: ( + wire: Awaited>, + ) => void | Promise; + } = {}, ) { const base = await followupControllerFixture(store, fixtureOptions); const { f, wire } = base; diff --git a/tests/openrouter-provider-groups.test.ts b/tests/openrouter-provider-groups.test.ts index ddd3441..56a17de 100644 --- a/tests/openrouter-provider-groups.test.ts +++ b/tests/openrouter-provider-groups.test.ts @@ -587,8 +587,8 @@ describe("group routing preserves independent response guards", () => { }); }); -describe("SD05 remains outside provider-group approval", () => { - it("refuses a group at SD05 model resolution even though the ordinary independent checker accepts it", async () => { +describe("explicit capability and SD05 evidence refusals", () => { + it("retains the internal purpose-protocol opt-out even when the ordinary independent checker accepts a group", async () => { const f = await groupFixture(); expect(await f.model.resolve()).not.toBeNull(); const model = createSupportIndependentCheckModel(f.options, "pegma.dev", { @@ -598,9 +598,10 @@ describe("SD05 remains outside provider-group approval", () => { await refusesBeforeCredentials({ ...f, model }); }); - it("refuses a complete direct release_followup request before credentials despite live SD05 evidence", async () => { + it("refuses a direct release_followup group before credentials when its separate SD05 approval is absent", async () => { const f = await followupChecksFixture(createMemoryStore()); group(f.wire); + Reflect.deleteProperty(f.wire.route, "releaseFollowup"); await approve(f.wire); const ordinary = createSupportIndependentCheckModel( f.wire.options, @@ -648,9 +649,10 @@ describe("SD05 remains outside provider-group approval", () => { expect(f.wire.state.calls).toBe(0); }); - it("makes SD05 policy unavailable and holds an actual check before model credentials, authority or durable admission", async () => { + it("makes incomplete group policy unavailable and holds an SD05 check before credentials, authority or durable admission", async () => { const f = await followupChecksFixture(createMemoryStore()); group(f.wire); + Reflect.deleteProperty(f.wire.route.approval, "providerSelectionScope"); await approve(f.wire); const credential = vi.fn(() => "fictional-provider-key"); const authority = vi.fn(f.options.authority.resolve); diff --git a/tests/openrouter-release-followup-provider-groups.test.ts b/tests/openrouter-release-followup-provider-groups.test.ts new file mode 100644 index 0000000..188343e --- /dev/null +++ b/tests/openrouter-release-followup-provider-groups.test.ts @@ -0,0 +1,541 @@ +import { + createMemoryStore, + type CollectionDefinition, + type CollectionStore, + type Store, +} from "@pegma/storage-core"; +import { describe, expect, it, vi } from "vitest"; +import { + createSupportIndependentCheckModel, + createSupportReleaseFollowupChecks, + independentCheckRoutePolicyHash, + type ReleaseFollowupIndependentCheckInput, +} from "@pegma/support-desk-ai/openrouter"; +import { CHECK_PASS } from "../test/openrouter-fixtures.js"; +import { + followupChecksFixture, + followupModelFixture, +} from "../test/openrouter-release-followup-fixtures.js"; + +type Fixture = Awaited>; +type Wire = Fixture["wire"]; +const PRICE = { prompt: 0.05, completion: 0.1, request: 0 } as const; +const signal = () => new AbortController().signal; + +function group(wire: Wire) { + wire.route.endpointTag = "azure"; + wire.route.providerSelectionScope = "provider_group"; + wire.route.providerMaxPrice = { ...PRICE }; + wire.route.approval.providerSelectionScope = "provider_group"; + wire.options.allowlist[0]!.endpointTag = "azure"; + Reflect.set( + wire.options.allowlist[0]!, + "providerSelectionScope", + "provider_group", + ); +} +async function approve(wire: Wire) { + const { approval, ...base } = wire.route; + approval.requestPolicySha256 = await independentCheckRoutePolicyHash(base); +} +const fixture = () => + followupChecksFixture(createMemoryStore(), { configureChecker: group }); +function request(f: Fixture): ReleaseFollowupIndependentCheckInput { + return { + trustedInstructions: f.wire.c.trustedInstructions, + kind: "release_followup", + purpose: "support_release_followup", + facts: { + messages: ["The fictional export was empty."], + publicReleaseFacts: [ + { + ref: "release-1", + text: "The fictional deployed fix exports every row.", + }, + ], + }, + candidate: f.input.candidate, + outbound: f.input.exactBundle, + binding: f.input.binding, + targetBaseline: null, + validationRequirements: null, + }; +} +function directContext(f: Fixture) { + return { + ...f.wire.context, + deadline: new Date(Date.parse(f.wire.state.now) + 2_000).toISOString(), + }; +} +function wireBody(f: Fixture, index = 0) { + return JSON.parse(String(f.wire.state.requests[index]!.init.body)); +} + +/** Observe actual public Store admission calls; no seeded private checker rows. */ +function admissionStore(base: Store) { + const writes = vi.fn(); + const store: Store = { + collection(definition: CollectionDefinition): CollectionStore { + const records = base.collection(definition); + return { + ...records, + async update(key, decide, options) { + writes(definition.name); + return records.update(key, decide, options); + }, + }; + }, + }; + return { store, writes }; +} +async function refusesBeforeProviderOrAdmission(f: Fixture) { + const observed = admissionStore(f.store); + const credential = vi.fn(f.options.readApiKey), + authority = vi.fn(f.options.authority.resolve), + application = vi.fn(f.options.application); + const checks = createSupportReleaseFollowupChecks( + { + ...f.options, + store: observed.store, + readApiKey: credential, + authority: { resolve: authority }, + application, + }, + "pegma.dev", + ); + expect( + await checks.resolvePolicy(f.input.binding.checkPolicyVersion, signal()), + ).toEqual({ outcome: "unavailable" }); + expect(await checks.forWork(f.f.key).check(f.input, f.context)).toEqual({ + outcome: "held", + }); + expect(credential).not.toHaveBeenCalled(); + expect(authority).not.toHaveBeenCalled(); + expect(application).not.toHaveBeenCalled(); + expect(observed.writes).not.toHaveBeenCalled(); + expect(f.wire.state.calls).toBe(0); + // Existing receipt-HMAC key reads are deliberately outside these provider assertions. +} + +describe("SD05 independent-check provider-group opt-in", () => { + it("checks the actual bundle, verifies its sf1 receipt and posts through the public application once", async () => { + const f = await fixture(), + port = f.checks.forWork(f.f.key); + const checked = await port.check(f.input, f.context); + expect(checked.outcome).toBe("checked"); + if (checked.outcome !== "checked") + throw new Error("Actual SD05 checked receipt required"); + expect(checked.receipt).toMatch(/^sf1\./u); + expect( + await f.checks.sdkVerifier.verify( + checked.receipt, + f.input.binding, + signal(), + ), + ).not.toBeNull(); + expect( + await f.checks + .currentVerifierFor(f.f.key) + .verify(checked.receipt, f.input.binding, signal()), + ).not.toBeNull(); + expect(wireBody(f).provider).toEqual({ + only: ["azure"], + allow_fallbacks: false, + data_collection: "deny", + zdr: true, + require_parameters: true, + max_price: PRICE, + }); + await f.f.prepareBundle({ + exactBundle: f.input.exactBundle, + checksReceipt: checked.receipt, + checkPolicyVersion: f.input.binding.checkPolicyVersion, + }); + expect((await f.f.post()).result.messageId).toBeTruthy(); + expect(f.wire.state.calls).toBe(1); + }); + + it("changes only provider selection/price in the complete direct wire and retains legacy content", async () => { + const f = await followupChecksFixture(), + input = request(f), + context = directContext(f); + const legacy = createSupportIndependentCheckModel( + f.wire.options, + "pegma.dev", + ); + expect(await legacy.resolve()).not.toBeNull(); + await legacy.generate(input, context, f.wire.c); + const legacyWire = wireBody(f); + group(f.wire); + await approve(f.wire); + const grouped = createSupportIndependentCheckModel( + f.wire.options, + "pegma.dev", + ); + expect(await grouped.resolve()).not.toBeNull(); + expect( + grouped.parseVerdict( + (await grouped.generate(input, context, f.wire.c)).outputJson, + ), + ).toEqual(CHECK_PASS); + const groupedWire = wireBody(f, 1); + expect(groupedWire.provider).toEqual({ + ...legacyWire.provider, + only: ["azure"], + max_price: PRICE, + }); + expect( + JSON.stringify({ ...groupedWire, provider: legacyWire.provider }), + ).toBe(JSON.stringify(legacyWire)); + expect(f.wire.state.calls).toBe(2); + }); + + it.each(Array.from({ length: 8 }, (_, value) => value))( + "requires all three opt-ins while retaining legacy mask %i", + async (mask) => { + const f = await followupChecksFixture(); + if (mask & 1) { + f.wire.route.endpointTag = "azure"; + f.wire.options.allowlist[0]!.endpointTag = "azure"; + f.wire.route.providerSelectionScope = "provider_group"; + f.wire.route.providerMaxPrice = { ...PRICE }; + } + if (mask & 2) + f.wire.route.approval.providerSelectionScope = "provider_group"; + if (mask & 4) + Reflect.set( + f.wire.options.allowlist[0]!, + "providerSelectionScope", + "provider_group", + ); + await approve(f.wire); + if (mask !== 0 && mask !== 7) return refusesBeforeProviderOrAdmission(f); + const checks = createSupportReleaseFollowupChecks(f.options, "pegma.dev"); + expect( + (await checks.forWork(f.f.key).check(f.input, f.context)).outcome, + ).toBe("checked"); + expect(f.wire.state.calls).toBe(1); + }, + ); + + for (const mode of ["missing", "undefined", "contradictory"] as const) { + it.each([ + "route scope", + "approval scope", + "allowlist scope", + "price", + ] as const)( + `holds a ${mode} %s without provider credentials or funding`, + async (field) => { + const f = await fixture(); + const target = + field === "approval scope" + ? f.wire.route.approval + : field === "allowlist scope" + ? f.wire.options.allowlist[0]! + : f.wire.route; + const property = + field === "price" ? "providerMaxPrice" : "providerSelectionScope"; + if (mode === "missing") Reflect.deleteProperty(target, property); + else + Reflect.set( + target, + property, + mode === "undefined" + ? undefined + : field === "price" + ? { ...PRICE, request: 1 } + : "endpoint", + ); + // An own undefined route key cannot obtain a canonical approval hash. + // Preserve the last valid approval and exercise the runtime refusal. + if ( + mode !== "undefined" || + field === "approval scope" || + field === "allowlist scope" + ) + await approve(f.wire); + await refusesBeforeProviderOrAdmission(f); + }, + ); + } + + it.each([ + "missing", + "expired", + "future", + "wrong purpose", + "wrong wire", + "short window", + ] as const)( + "retains the separate SD05 profile requirement: %s", + async (fault) => { + const f = await fixture(), + evidence = f.wire.route.releaseFollowup!; + if (fault === "missing") + Reflect.deleteProperty(f.wire.route, "releaseFollowup"); + if (fault === "expired") evidence.validUntil = f.wire.state.now; + if (fault === "future") + evidence.verifiedAt = new Date( + Date.parse(f.wire.state.now) + 1, + ).toISOString(); + if (fault === "wrong purpose") + Reflect.set(evidence, "purpose", "support_independent_check"); + if (fault === "wrong wire") + Reflect.set( + evidence, + "wireVersion", + "openrouter-support-independent-check-v2", + ); + if (fault === "short window") + evidence.validUntil = new Date( + Date.parse(f.wire.route.approval.validUntil) - 1, + ).toISOString(); + await approve(f.wire); + await refusesBeforeProviderOrAdmission(f); + }, + ); + + it("keeps generator group selection unsupported and never reads its provider key", async () => { + const f = await followupModelFixture(); + Reflect.set(f.route, "providerSelectionScope", "provider_group"); + Reflect.set(f.route, "providerMaxPrice", PRICE); + Reflect.set(f.route.approval, "providerSelectionScope", "provider_group"); + expect( + (await f.model.configuration.resolve(undefined, signal())).outcome, + ).toBe("unavailable"); + await expect( + f.model.model.generate(f.input, f.context, f.c), + ).rejects.toThrow(); + expect(f.key).not.toHaveBeenCalled(); + expect(f.state.calls).toBe(0); + }); +}); + +describe("SD05 group renewal and exact receipt recovery", () => { + it("defers provider and receipt work in real later invocations and never repeats the physical call", async () => { + const f = await fixture(), + checks = createSupportReleaseFollowupChecks( + { ...f.options, deferred: true }, + "pegma.dev", + ), + port = checks.forWork(f.f.key); + expect(await port.check(f.input, f.context)).toMatchObject({ + outcome: "deferred", + callState: "not_called", + }); + expect(f.wire.state.calls).toBe(0); + const [pending] = await checks.scanPending(); + expect(pending?.phase).toBe("provider"); + expect( + await checks.precomputePending(pending!.operationId, f.context, f.f.key), + ).toMatchObject({ outcome: "received" }); + expect((await checks.scanPending())[0]?.phase).toBe("receipt"); + expect( + await checks.precomputePending(pending!.operationId, f.context, f.f.key), + ).toMatchObject({ outcome: "checked" }); + const checked = await port.check(f.input, f.context); + expect(checked.outcome).toBe("checked"); + if (checked.outcome !== "checked") + throw new Error("Actual group receipt required"); + expect( + await port.verify(checked.receipt, f.input.binding, signal()), + ).not.toBeNull(); + expect(await port.check(f.input, f.context)).toEqual(checked); + await checks.precomputePending(pending!.operationId, f.context, f.f.key); + expect(f.wire.state.calls).toBe(1); + }); + + it.each(["price", "group", "hash"] as const)( + "does not turn a renewed %s into permission to run an old queued request", + async (change) => { + const f = await fixture(); + const extra = { + ...f.wire.options.allowlist[0]!, + endpointTag: "fixture-other-group", + }; + f.wire.options.allowlist.push(extra); + f.wire.route.approval.validUntil = new Date( + Date.parse(f.wire.state.now) + 120_000, + ).toISOString(); + const key = vi.fn(f.options.readApiKey), + checks = createSupportReleaseFollowupChecks( + { ...f.options, deferred: true, readApiKey: key }, + "pegma.dev", + ); + await checks.forWork(f.f.key).check(f.input, f.context); + const [pending] = await checks.scanPending(); + expect(pending).toBeDefined(); + f.f.advance(1_000); + f.wire.state.now = f.f.clock.now(); + f.wire.route.approval.verifiedAt = f.wire.state.now; + f.wire.route.approval.validUntil = new Date( + Date.parse(f.wire.state.now) + 180_000, + ).toISOString(); + if (change === "price") + f.wire.route.providerMaxPrice = { ...PRICE, prompt: 0.055 }; + if (change === "group") f.wire.route.endpointTag = extra.endpointTag; + await approve(f.wire); + if (change === "hash") + f.wire.route.approval.requestPolicySha256 = "f".repeat(64); + if (change !== "hash") + expect(await checks.resolvePolicy(undefined, signal())).toMatchObject({ + outcome: "ready", + }); + expect( + ( + await checks.precomputePending( + pending!.operationId, + f.context, + f.f.key, + ) + ).outcome, + ).toBe("held"); + expect(key).not.toHaveBeenCalled(); + expect(f.wire.state.calls).toBe(0); + }, + ); + + it.each(["before provider", "after provider"] as const)( + "allows a benign approval extension %s without extending the queued receipt expiry", + async (phase) => { + const f = await fixture(), + original = new Date( + Date.parse(f.wire.state.now) + 30_000, + ).toISOString(); + f.wire.route.approval.validUntil = original; + let renewed = false; + const renew = () => { + if (renewed) return; + renewed = true; + f.f.advance(1_000); + f.wire.state.now = f.f.clock.now(); + f.wire.route.approval.verifiedAt = f.wire.state.now; + f.wire.route.approval.validUntil = new Date( + Date.parse(f.wire.state.now) + 180_000, + ).toISOString(); + }; + const confirm = f.options.releaseEvidence.confirm; + const checks = createSupportReleaseFollowupChecks( + { + ...f.options, + deferred: true, + deferredRetentionMilliseconds: 60_000, + readApiKey: () => { + if (phase === "before provider") renew(); + return "fictional-key"; + }, + releaseEvidence: { + ...f.options.releaseEvidence, + confirm: async (...args) => { + const proof = await confirm(...args); + if (phase === "after provider" && f.wire.state.calls === 1) + renew(); + return proof; + }, + }, + }, + "pegma.dev", + ); + expect( + await checks.forWork(f.f.key).prepare!(f.input, f.context), + ).toMatchObject({ outcome: "deferred" }); + const [pending] = await checks.scanPending(); + // The original receipt-key/approval window, not the default 60s receipt + // limit or retention, is the decisive bound captured before renewal. + expect(pending!.expiresAt).toBe(original); + expect( + await checks.precomputePending( + pending!.operationId, + f.context, + f.f.key, + ), + ).toEqual({ outcome: "received" }); + const checked = await checks.precomputePending( + pending!.operationId, + f.context, + f.f.key, + ); + expect(renewed).toBe(true); + expect(checked.outcome).toBe("checked"); + if (checked.outcome !== "checked") + throw new Error("Benign renewed receipt required"); + const proof = await checks.sdkVerifier.verify( + checked.receipt!, + f.input.binding, + signal(), + ); + expect(proof).not.toBeNull(); + expect(proof!.validUntil).toBe(original); + expect(Date.parse(proof!.validUntil)).toBeLessThan( + Date.parse(f.wire.route.approval.validUntil), + ); + f.f.advance(Date.parse(original) - Date.parse(f.f.clock.now())); + f.wire.state.now = f.f.clock.now(); + expect( + await checks.sdkVerifier.verify( + checked.receipt!, + f.input.binding, + signal(), + ), + ).toBeNull(); + expect(f.wire.state.calls).toBe(1); + }, + ); + + it.each(["price", "hash", "approval expiry", "source authority"] as const)( + "holds a late %s mutation before the physical callback can dispatch", + async (change) => { + const f = await fixture(); + const key = vi.fn(() => { + if (change === "price") + f.wire.route.providerMaxPrice = { ...PRICE, prompt: 0.04 }; + if (change === "hash") + f.wire.route.approval.requestPolicySha256 = "f".repeat(64); + if (change === "approval expiry") + f.wire.route.approval.validUntil = f.wire.state.now; + if (change === "source authority") f.state.active = false; + return "fictional-provider-key"; + }); + const checks = createSupportReleaseFollowupChecks( + { ...f.options, readApiKey: key }, + "pegma.dev", + ); + expect( + (await checks.forWork(f.f.key).check(f.input, f.context)).outcome, + ).toBe("held"); + expect(key).toHaveBeenCalledTimes(1); + expect(f.wire.state.calls).toBe(0); + }, + ); + + it.each([ + "missing cost", + "unexpected provider", + "reasoning tokens", + "unknown fee", + "over budget", + ] as const)( + "withholds an SD05 receipt after %s without a second opportunity", + async (fault) => { + const f = await fixture(); + if (fault === "missing cost") + Reflect.deleteProperty(f.wire.state.document.usage, "cost"); + if (fault === "unexpected provider") + f.wire.state.document.provider = "unapproved provider"; + if (fault === "reasoning tokens") + Reflect.set(f.wire.state.document.usage, "completion_tokens_details", { + reasoning_tokens: 1, + }); + if (fault === "unknown fee") + Reflect.set(f.wire.state.document.usage, "cost_details", { + unreviewed_fee: 0.001, + }); + if (fault === "over budget") f.wire.state.document.usage.cost = 0.001001; + const port = f.checks.forWork(f.f.key); + expect((await port.check(f.input, f.context)).outcome).toBe("held"); + expect((await port.check(f.input, f.context)).outcome).toBe("held"); + expect(f.wire.state.calls).toBe(1); + }, + ); +}); diff --git a/tests/release-packages.test.ts b/tests/release-packages.test.ts index 911f33c..8a16325 100644 --- a/tests/release-packages.test.ts +++ b/tests/release-packages.test.ts @@ -90,7 +90,7 @@ describe("release package metadata", () => { ]); }); - it("ships the synchronized 0.2.12 package set with exact internal pins", () => { + it("ships the synchronized 0.2.13 package set with exact internal pins", () => { const manifests = RELEASE_PACKAGES.map(({ directory }) => JSON.parse( readFileSync( @@ -105,24 +105,24 @@ describe("release package metadata", () => { }>; expect(manifests.map(({ name, version }) => ({ name, version }))).toEqual([ - { name: "@pegma/support-desk-contracts", version: "0.2.12" }, - { name: "@pegma/support-desk-core", version: "0.2.12" }, - { name: "@pegma/support-desk-templates", version: "0.2.12" }, - { name: "@pegma/support-desk-application", version: "0.2.12" }, - { name: "@pegma/support-desk-ai", version: "0.2.12" }, + { name: "@pegma/support-desk-contracts", version: "0.2.13" }, + { name: "@pegma/support-desk-core", version: "0.2.13" }, + { name: "@pegma/support-desk-templates", version: "0.2.13" }, + { name: "@pegma/support-desk-application", version: "0.2.13" }, + { name: "@pegma/support-desk-ai", version: "0.2.13" }, ]); expect(manifests[1]?.dependencies?.["@pegma/support-desk-contracts"]).toBe( - "0.2.12", + "0.2.13", ); expect(manifests[3]?.dependencies?.["@pegma/support-desk-contracts"]).toBe( - "0.2.12", + "0.2.13", ); expect(manifests[3]?.dependencies?.["@pegma/support-desk-core"]).toBe( - "0.2.12", + "0.2.13", ); expect( manifests[4]?.dependencies?.["@pegma/support-desk-application"], - ).toBe("0.2.12"); + ).toBe("0.2.13"); expect( manifests[4]?.dependencies?.["@pegma/support-desk-contracts"], ).toBeUndefined(); @@ -245,7 +245,7 @@ packages: "@pegma/support-desk-contracts" ], ).toEqual({ - specifier: "0.2.12", + specifier: "0.2.13", version: "link:../contracts", }); expect( diff --git a/tests/release-verification.test.ts b/tests/release-verification.test.ts index 88e0590..97d3a0c 100644 --- a/tests/release-verification.test.ts +++ b/tests/release-verification.test.ts @@ -1230,7 +1230,7 @@ describe("source-bound original release artifact", () => { }); it("reads real gzip/tar artifacts and accepts the independently pinned exact five-package candidate", async () => { - expect(releaseVerificationVersion).toBe("0.2.12"); + expect(releaseVerificationVersion).toBe("0.2.13"); const f = fixture(); expect( f.manifest.packages.map(({ name, version }) => ({ name, version })),