mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 03:31:44 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Tool gateways let external MCP clients use a company's tools with a
gateway client token
> - Since delegated connection management (#17737), an agent can create
and revoke gateway client tokens for its responsible person
> - #20581 stopped agents from getting the one-time token value, but it
did this by making token creation person-only
> - The product decision is that agents keep their delegated authority
to create and revoke tokens
> - This pull request restores agent token creation, but the agent never
receives the token value: the person reveals the value once on the
gateway's Tokens page
> - The benefit is that an agent can do the rotation work for the
person, and the secret still never enters chat, run events, logs or tool
output
## Linked Issues or Issue Description
Refs #17737
Refs #20581
**What happened**
After #20581, `POST /api/tool-gateway/gateways/{gatewayId}/tokens`
returns 403 `gateway_token_requires_person` to every agent caller.
Agents lost the delegated authority to create gateway client tokens that
#17737 gave them. Before #20581, an agent that created a token received
the plaintext value in its tool result and could repeat it in chat.
**Expected behavior**
An agent with delegated connection management can create and revoke
gateway client tokens. The agent never receives a token value. The
responsible person gets the value once, on the gateway's Tokens page.
Person callers keep today's behavior.
**Steps to reproduce**
1. Give an agent delegated connection management for a responsible
person with `tools:admin`.
2. As the agent, call `POST
/api/tool-gateway/gateways/{gatewayId}/tokens` (for example through
`call_api`).
3. See 403 `gateway_token_requires_person`.
## What Changed
- Agent create: `POST /api/tool-gateway/gateways/:gatewayId/tokens` from
an agent with delegated authority returns 201 with token metadata only
(`id`, `tokenPrefix`, `expiresAt`, `pendingReveal: true`), plus
`tokensPath`, a `reveal_credential` `requiredUserAction` for the
responsible person, and a `nextStep` instruction. The saved row has no
usable value: its stored hash is of a value that is generated and then
discarded. Gateway authentication also rejects `pendingReveal` rows.
- Person reveal: new person-only `POST
/api/tool-gateway/gateway-tokens/:tokenId/reveal`. It generates the
value, stores its hash, clears `pendingReveal` and returns the value
once. A conditional update makes a second or concurrent reveal return
409. Only the token's responsible person can reveal it (403
`gateway_token_reveal_requires_responsible_person`). Agent callers get
403 `gateway_token_requires_person`. A token revoked before reveal
cannot be revealed.
- Why a reveal that generates the value: no stored plaintext existed to
reveal, and storing one (even encrypted) for later display adds a secret
at rest. Generating the value at reveal time keeps the existing one-time
display and stores only a hash.
- Schema: `tool_mcp_gateway_tokens.pending_reveal boolean not null
default false` (migration `0460_gateway_token_pending_reveal`). Shared
`ToolMcpGatewayToken.pendingReveal`, and `ConnectionRequiredUserAction`
gets `reveal_credential` / `gateway_token`.
- UI: the Tokens page shows a "Waiting for you to reveal" section for
pending tokens with a "Reveal token" button. The value appears in the
existing "New token — copy now" one-time block. Pending tokens show the
status "Not revealed".
- Agent gateway create: the 201 for agent callers also includes
`gatewayPath`, `tokensPath` and a `nextStep` that tells the agent to
link the saved gateway.
- The agent create-token `nextStep` and the catalog say not to revoke
the old token in the same turn: its client keeps working on it until the
person installs the new value.
- The reveal update and its `tool_gateway.token_revealed` activity entry
commit in one transaction. The Tokens page offers Reveal only for tokens
that act for the signed-in person.
- API reference: new `docs/api/tool-gateway-tokens.md` (create, reveal,
revoke) in the docs nav.
- Revoke stays allowed for agents with delegated authority (unchanged
route).
- API catalog: create-gateway, create-token, reveal and revoke
descriptions now say who acts, that agents never receive values, the
page paths, and that the old token is revoked only after the client
works with the new one.
- Agent access map: create-token policy note and a new reveal entry.
- Evals `gateways-profiles.create-gateway` and
`gateways-profiles.rotate-token`:
- Remove the keyword grader (`human|operator|admin|manage`) and the
handoff text checks. Grade saved state, rendered links and secret
absence. A plain reply or a question card is accepted.
- Remove the setup probes that called the create routes as the agent.
Under delegated authority, those probes created a real gateway
("Forbidden agent gateway"), which failed create-gateway before the
agent ran.
- create-gateway: exactly one gateway for the intended profile and
company, created by the agent (or by the person after a handoff); the
person opens it from a rendered link; attribution matches the creator;
any agent-created token is still pending reveal; no token value in chat,
cards or run events.
- rotate-token: after the agent's turn, both setup tokens still work and
any replacement the agent created is pending the person's reveal; the
person follows the rendered Tokens page link and reveals (or issues) the
value in a private browser; the new value works before the old token is
revoked; the unrelated client keeps access; no token value appears
anywhere, including a regex scan for any full `pcgw_<id>.<secret>`
value.
- The changed scenario context and outcomes are recorded in
`chat-full-catalog-testops-manifest.json` `changedFields` and pinned in
the manifest test. The inventory digest, descriptors (`oracleVersion`
v2, `sourceFiles`) and SDK public input pins are updated. The unused
`external-gateway-handoff.ts` module is removed.
- Fixture realism: the create-gateway profile now allows a real read
tool (an empty profile made the agent ask which apps to add instead of
finishing), and the rotation tokens get a neutral owner note instead of
"Disposable rotation fixture" (the agent read that note as an eval
hint).
- Shared private-browser helpers (`external-private-browser.ts`,
`external-private-browser-worker.ts`) get one optional `pendingTokenId`
input and one `revealedPending` receipt field.
## Verification
- Red: on `master` route code, the new integration tests `lets agents
create and revoke gateway client tokens without ever receiving a token
value` and `reveals an agent-created gateway token value only to its
responsible person` fail (403 `gateway_token_requires_person`).
- Green: `cd server && npx vitest run
src/__tests__/connection-management.integration.test.ts -t gateway` (25
passed). The test checks that the agent `call_api` result has no `token`
field and no token-shaped value, that the agent cannot reveal, that the
person reveals once (second reveal 409) and the value authenticates,
that agent revoke works and stops the value, that a token revoked before
reveal never gets a value, and that person create still returns the
value.
- `npx vitest run src/__tests__/tool-gateway.test.ts
src/__tests__/openapi-routes.test.ts
src/services/native-runtime/runner-api.test.ts` (2247 passed).
- `cd ui && npx vitest run
src/pages/apps/gateways/panels/TokensPanel.test.tsx
src/pages/apps/gateways/gateway-helpers.test.ts` (16 passed); `pnpm
check:token-gates` clean.
- Eval graders and catalog: `pnpm exec vitest run --config
tests/runner-e2e/vitest.config.ts` on the gateway oracle tests,
`external.test.ts`, catalog consistency/contract, TestOps
export/retained, phase/clock callers and SDK input/type tests (all
pass); `node --test` on the TestOps manifest, adapter, contract,
streaming and reconcile tests (all pass); `node
tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`
(unchanged).
- `node scripts/check-maps.mjs` passes. `tsc --noEmit` for `server`,
`ui` and `tests/runner-e2e`: no errors in changed files.
- Paid end-to-end run of both eval cases, run
[42872921890](https://github.com/paperclipai/paperclip/actions/runs/42872921890)
on 39f38a7f6c (before the last three commits): both FAILED, for
agent-behavior reasons the later commits address. Not rerun yet.
- rotate-token: the agent created the replacement (pending reveal, no
value), then revoked the old token in the same turn, despite the create
response saying to wait. Its reasoning cited the eval-looking fixture
note. The grader rejected the premature revocation. The reply linked the
Tokens page correctly.
- create-gateway: the agent created the gateway and one pending token,
then asked a question card about which apps to add to the empty profile,
with no link to the gateway. The grader rejected the missing link.
- Token values: a scan of all evidence files of both cells found no full
`pcgw_<id>.<secret>` value and no `pcgw_<uuid>` form. Agent `call_api`
payloads in run events are redacted; the integration test proves the
agent tool result has no value.
## Risks
- Behavior change for agents: token create returns metadata and a Tokens
page path, not a value. Agents that expect `token` in the response must
send the person to the Tokens page.
- Migration adds one boolean column with a default. Existing tokens get
`false` and keep working.
- A pending token that is never revealed stays as an unusable row until
someone revokes it. It cannot authenticate.
## Model Used
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`), tool use and code
execution in Claude Code.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
521 lines
21 KiB
JavaScript
521 lines
21 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
import { createRequire } from 'node:module';
|
|
import { catalogTargetSha, catalogManifestSha256, fullCatalogPlanName, fullCatalogCases, validateFullCatalogManifest, companySecretBindingApprovalMetadata, validateCompanySecretBindingApprovalSource } from './chat-full-catalog-testops-manifest.mjs';
|
|
|
|
const { parseDocument } = createRequire(import.meta.url)('yaml');
|
|
const bytes = readFileSync(new URL('./chat-full-catalog-testops-manifest.json', import.meta.url));
|
|
const manifest = JSON.parse(bytes);
|
|
const row = id => fullCatalogCases.find(value => value.key === id);
|
|
|
|
test('the manifest joins all244 source YAML scenarios without importing a domain or fabricating a result', () => {
|
|
const directory = new URL('./chat-scenarios/', import.meta.url);
|
|
const scenarios = readdirSync(directory).filter(file => file.endsWith('.yaml') && file !== 'defaults.yaml').flatMap(file => {
|
|
const parsed = parseDocument(readFileSync(new URL(file, directory), 'utf8'), { uniqueKeys: true });
|
|
assert.deepEqual(parsed.errors, []);
|
|
return parsed.toJS().scenarios;
|
|
});
|
|
assert.equal(scenarios.length, 244);
|
|
assert.equal(fullCatalogCases.length, 244);
|
|
assert.deepEqual(fullCatalogCases.map(value => value.key).sort(), scenarios.map(value => value.id).sort());
|
|
for (const scenario of scenarios) {
|
|
const actual = row(scenario.id);
|
|
const override = field => manifest.source.repairMetadata.changedFields.find(change => change.key === scenario.id && change.field === field);
|
|
for (const [field, original] of [['originalQuery', scenario.query], ['originalContext', scenario.context], ['expectedOutcome', scenario.expected_outcome]]) {
|
|
const change = override(field);
|
|
// The scenario YAML in this tree is the current definition; the manifest keeps the previous value as history.
|
|
if (change) { assert.notEqual(change.previous, change.current); assert.equal(original, change.current); assert.equal(actual[field], change.current); }
|
|
else assert.equal(actual[field], original);
|
|
}
|
|
assert.ok(!Object.hasOwn(actual, 'status') && !Object.hasOwn(actual, 'passed'));
|
|
}
|
|
});
|
|
|
|
test('legacy aliases preserve existing TestOps identities while execution uses actual legacy task IDs', () => {
|
|
for (const task of ['create-backlog', 'delegate-announcement']) {
|
|
const actual = row(`tasks.${task}`);
|
|
assert.equal(actual.scenario, task);
|
|
assert.equal(actual.executionId, `chat-features.runner-opencode.local.${task}`);
|
|
assert.equal(actual.fullName, `paperclip.Product E2E.chat-features.tasks.${task}`);
|
|
assert.deepEqual(actual.aliases, [`paperclip.Product E2E.chat-features.${task}`]);
|
|
}
|
|
});
|
|
|
|
test('source bounds retain legacy and pilot runs, native zero turn policy and original finite attempts', () => {
|
|
for (const [id, minimum, maximum, attempt, checks] of [
|
|
['tasks.create-backlog', 1, 1, 420000, 10], ['tasks.delegate-announcement', 3, 3, 420000, 15],
|
|
['instance-operations.restart-service', 1, 1, 420000, 9], ['projects.project-defaults', 3, 3, 660000, 11],
|
|
['projects.project-work', 1, 3, 300000, 15],
|
|
]) {
|
|
const actual = row(id);
|
|
assert.deepEqual([actual.minimumRuns, actual.maximumRuns, actual.attemptTimeoutMs, actual.checks], [minimum, maximum, attempt, checks]);
|
|
assert.equal(actual.turnTimeoutMs, id.startsWith('tasks.') ? 120000 : 0);
|
|
}
|
|
assert.equal(row('access.sign-in').maximumRuns, 0);
|
|
assert.equal(row('assistant-connections.use-scoped-client').maximumRuns, 0);
|
|
assert.equal(fullCatalogCases.filter(value => value.turnTimeoutMs === 0).length, 242);
|
|
});
|
|
|
|
test('definition gaps and private prerequisites remain explicit instead of inferred runnable passes', () => {
|
|
assert.deepEqual(fullCatalogCases.filter(value => value.coverageGaps.length).map(value => value.key), [
|
|
'activity.routine-audit', 'agents.restore-instructions', 'budgets-costs.subscription-fees',
|
|
]);
|
|
assert.equal(fullCatalogCases.filter(value => value.requiredCredentials.length).length, 18);
|
|
assert.equal(fullCatalogCases.filter(value => value.externalInput !== null).length, 37);
|
|
assert.equal(row('skills.enable-for-agent').coverageGaps.length, 0);
|
|
});
|
|
|
|
test('surface evidence declarations never manufacture a generic final screenshot for boundary cases', () => {
|
|
assert.equal(row('agent-chat.chat-disabled').screenshot, 'runtime-disabled-agent-chat.png');
|
|
for (const id of ['access.sign-in', 'onboarding.choose-first-runtime', 'onboarding.new-instance', 'onboarding.resume-wizard', 'assistant-connections.use-scoped-client']) {
|
|
assert.equal(row(id).screenshot, null);
|
|
assert.match(row(id).evidenceReadiness, /requires-final-state\.png/);
|
|
}
|
|
assert.equal(row('projects.project-work').screenshot, 'final-state.png');
|
|
assert.ok(manifest.source.requiredOriginalPassEvidence.includes('final-state.png'));
|
|
});
|
|
|
|
test('source identities and descriptor provenance are stable, deeply frozen and deterministic', () => {
|
|
assert.equal(catalogTargetSha, manifest.targetSha);
|
|
assert.equal(catalogManifestSha256, createHash('sha256').update(bytes).digest('hex'));
|
|
assert.equal(fullCatalogPlanName, 'Chat feature catalog — OpenCode 1017 (candidate)');
|
|
assert.equal(new Set(fullCatalogCases.map(value => value.fullName)).size, 244);
|
|
assert.equal(manifest.source.scenarioFiles.length, 35);
|
|
assert.equal(manifest.metadataSourceSha, 'de0941835cc8f0d01c982574ee258e110babdbeb');
|
|
assert.throws(() => { fullCatalogCases[0].coverageGaps.push('changed'); }, TypeError);
|
|
assert.throws(() => { fullCatalogCases[0].maximumRuns = 999; }, TypeError);
|
|
assert.ok(!bytes.toString().match(/sk-or-v1-[a-f0-9]{32,}/));
|
|
});
|
|
|
|
test('foreign identity, duplicated case and changed run-bound metadata are rejected by the pure loader', () => {
|
|
const copy = () => structuredClone(manifest);
|
|
const foreign = copy(); foreign.cases[0].executionId = 'chat-features.other.local.case';
|
|
assert.throws(() => validateFullCatalogManifest(foreign), /row_invalid/);
|
|
const duplicate = copy(); duplicate.cases[1] = duplicate.cases[0];
|
|
assert.throws(() => validateFullCatalogManifest(duplicate), /identity_conflict/);
|
|
const bounds = copy(); bounds.cases[0].minimumRuns = bounds.cases[0].maximumRuns + 1;
|
|
assert.throws(() => validateFullCatalogManifest(bounds), /row_invalid/);
|
|
});
|
|
|
|
|
|
test('repair source metadata binds the corrected candidate and explicit changed definitions', () => {
|
|
const repair = manifest.source.repairMetadata;
|
|
assert.equal(repair.baseTargetSha, '3b66c3c144360ddf32714a0742fd774b8ceafb16');
|
|
assert.equal(repair.previousTargetSha, 'ab2019e976076ec0eb60b026844f3d9211cb0208');
|
|
assert.equal(manifest.targetSha, 'd68c00a3d78e5cd56b77aedb31f1e8a0f6d6f84e');
|
|
assert.equal(repair.definitionSourceSha, manifest.metadataSourceSha);
|
|
assert.equal(repair.candidateDescriptorSnapshot, 'fixtures/chat-repair-candidate-descriptors.json');
|
|
const descriptorBytes = readFileSync(new URL(repair.candidateDescriptorSnapshot, import.meta.url));
|
|
assert.equal(createHash('sha256').update(descriptorBytes).digest('hex'), repair.candidateDescriptorSha256);
|
|
const declarations = JSON.parse(descriptorBytes);
|
|
assert.equal(declarations.length, 242);
|
|
assert.equal(new Set(declarations.map(value => value.scenarioId)).size, 242);
|
|
assert.deepEqual(repair.changedFields.map(value => [value.key, value.field]), [
|
|
[
|
|
"activity.work-timeline",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"activity.work-timeline",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"activity.work-timeline",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"agents.choose-primary",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"app-permissions.ask-before-action",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"app-permissions.ask-before-action",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"app-permissions.test-as-agent",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"app-permissions.test-as-agent",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"app-permissions.test-as-agent",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"app-permissions.test-as-agent",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"cli-operations.choose-cli-context",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"cli-operations.choose-cli-context",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"companies.agent-observability",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"companies.configure-decision-model",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"companies.fast-responses",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"companies.fast-responses",
|
|
"originalQuery"
|
|
],
|
|
[
|
|
"companies.prompt-injection-guard",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"goals.create-goal-tree",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"goals.create-goal-tree",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"navigation-preferences.dismiss-announcement",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"navigation-preferences.dismiss-announcement",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.duplicate-answer",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.formal-hire-revision",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"questions-and-approvals.formal-hire-revision",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.multi-part-question",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.reject-and-revise",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"questions-and-approvals.reject-and-revise",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.review-plan",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"questions-and-approvals.review-plan",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"secrets.configure-company-secret",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"secrets.configure-company-secret",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"secrets.personal-secret",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"secrets.personal-secret",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"skills.author-skill",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.author-skill",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"skills.author-skill",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"skills.enable-for-agent",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.explicit-restriction",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.find-and-install",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.fork-read-only",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.review-update",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.studio-test",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.studio-test",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"skills.studio-test",
|
|
"maximumRuns"
|
|
],
|
|
[
|
|
"teams.configure-team",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"teams.configure-team",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"connection-setup.secure-api-key",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"secrets.least-scope-delivery",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"secrets.secret-proposal",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"secrets.vault-reference",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"teams.install-team",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"questions-and-approvals.multi-part-question",
|
|
"originalQuery"
|
|
],
|
|
[
|
|
"secrets.configure-company-secret",
|
|
"maximumRuns"
|
|
],
|
|
[
|
|
"secrets.configure-company-secret",
|
|
"optionalCompanySecretBindingApproval"
|
|
],
|
|
[
|
|
"secrets.configure-company-secret",
|
|
"expectedHumanMessageCount"
|
|
],
|
|
[
|
|
"questions-and-approvals.multi-part-question",
|
|
"sourceFiles"
|
|
],
|
|
[
|
|
"skills.review-update",
|
|
"oracleVersion"
|
|
],
|
|
[
|
|
"teams.install-team",
|
|
"sourceFiles"
|
|
],
|
|
// Outcome definitions revised with their structural graders on the chat-eval candidate.
|
|
[
|
|
"agents.edit-instructions",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"documents-artifacts.revise-delivery",
|
|
"expectedOutcome"
|
|
],
|
|
// Retargeted removed-feature cases (agent-chat.chat-disabled, agents.restore-instructions).
|
|
[
|
|
"agent-chat.chat-disabled",
|
|
"originalQuery"
|
|
],
|
|
[
|
|
"agent-chat.chat-disabled",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"agent-chat.chat-disabled",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"agents.restore-instructions",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"agents.restore-instructions",
|
|
"expectedOutcome"
|
|
],
|
|
// Retargeted to read-and-route: member permission edits are board-only.
|
|
[
|
|
"access.manage-membership",
|
|
"originalQuery"
|
|
],
|
|
[
|
|
"access.manage-membership",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"access.manage-membership",
|
|
"expectedOutcome"
|
|
],
|
|
// The supported board agent-grant route (#20323) builds both access cases' setup.
|
|
[
|
|
"access.invite-teammate",
|
|
"coverageGaps"
|
|
],
|
|
[
|
|
"access.manage-membership",
|
|
"coverageGaps"
|
|
],
|
|
// Real same-morning routine history instead of unproducible prior-day provenance (activity.routine-audit).
|
|
[
|
|
"activity.routine-audit",
|
|
"originalContext"
|
|
],
|
|
// Agents keep delegated gateway and token authority and never receive token values (gateways-profiles.create-gateway, rotate-token).
|
|
[
|
|
"gateways-profiles.create-gateway",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"gateways-profiles.create-gateway",
|
|
"expectedOutcome"
|
|
],
|
|
[
|
|
"gateways-profiles.rotate-token",
|
|
"originalContext"
|
|
],
|
|
[
|
|
"gateways-profiles.rotate-token",
|
|
"expectedOutcome"
|
|
]
|
|
]);
|
|
for (const change of repair.changedFields) {
|
|
assert.deepEqual(row(change.key)[change.field], change.current);
|
|
assert.notDeepEqual(change.current, change.previous);
|
|
}
|
|
assert.deepEqual(repair.changedFields.filter(change => change.key === 'questions-and-approvals.multi-part-question' && change.field === 'originalQuery'), [{ key: 'questions-and-approvals.multi-part-question', field: 'originalQuery', previous: "Help me choose the details for the launch page before you build it.", current: "Walk me through the launch-page question form so I can choose the audience and tone and enter my own headline before you build anything." }]);
|
|
assert.equal(repair.runtimeConditions.multipart53QuestionClarification.changedQueries, 1);
|
|
assert.equal(repair.runtimeConditions.multipart53QuestionClarification.unchangedOtherCatalogQueries, 243);
|
|
assert.equal(repair.runtimeConditions.multipart53QuestionClarification.previousInventoryDigest, '0cf530c11449508e91b5ce664d9375fc8e76466fa908255a1af0ff55169d0220');
|
|
assert.equal(repair.runtimeConditions.multipart53QuestionClarification.inventoryDigest, '814bb3633268cb0488563aed51fce2f987bd47650ddfb5a3302d0354292c2323');
|
|
assert.equal(repair.descriptorChanges.length, 55);
|
|
assert.equal(new Set(repair.descriptorChanges.map(change => change.key)).size, 33);
|
|
assert.deepEqual([...new Set(repair.descriptorChanges.map(change => change.field))].sort(), ['expectedRunCount', 'minimumRunCount', 'optionalCompanySecretBindingApproval', 'oracleVersion', 'setupPolicy', 'sourceFiles']);
|
|
for (const change of repair.descriptorChanges) {
|
|
assert.notDeepEqual(change.current, change.previous);
|
|
const declaration = declarations.find(value => value.scenarioId === change.key);
|
|
assert.ok(declaration);
|
|
assert.deepEqual(change.current, declaration[change.field]);
|
|
if (Object.hasOwn(row(change.key), change.field)) assert.deepEqual(row(change.key)[change.field], change.current);
|
|
}
|
|
assert.deepEqual(repair.changedDefinitionFiles.map(value => value.path), [
|
|
'tests/runner-e2e/chat-scenarios/companies.yaml', 'tests/runner-e2e/chat-scenarios/goals.yaml', 'tests/runner-e2e/chat-scenarios/skills.yaml', 'tests/runner-e2e/chat-scenarios/app-permissions.yaml', 'tests/runner-e2e/chat-scenarios/activity.yaml', 'tests/runner-e2e/chat-scenarios/questions-and-approvals.yaml',
|
|
]);
|
|
assert.ok(repair.changedDefinitionFiles.every(value => /^[a-f0-9]{64}$/.test(value.sha256)));
|
|
for (const declaration of declarations) {
|
|
const value = row(declaration.scenarioId);
|
|
assert.deepEqual(value.sourceFiles, declaration.sourceFiles);
|
|
assert.equal(value.oracleVersion, declaration.oracleVersion);
|
|
assert.equal(value.minimumRuns, declaration.minimumRunCount ?? declaration.expectedRunCount);
|
|
assert.equal(value.maximumRuns, declaration.expectedRunCount);
|
|
const approval = companySecretBindingApprovalMetadata(declaration);
|
|
assert.deepEqual(Object.fromEntries(Object.keys(approval).map(key => [key, value[key]])), approval);
|
|
assert.equal(Object.hasOwn(value, 'optionalCompanySecretBindingApproval'), Object.hasOwn(approval, 'optionalCompanySecretBindingApproval'));
|
|
assert.equal(value.declaredTurnTimeoutMs, declaration.turnTimeoutMs);
|
|
assert.equal(value.attemptTimeoutMs, declaration.attemptTimeoutMs);
|
|
}
|
|
assert.deepEqual(repair.changedFields.filter(change => ['minimumRuns', 'maximumRuns'].includes(change.field)), [{ key: 'skills.studio-test', field: 'maximumRuns', previous: 2, current: 3 }, { key: 'secrets.configure-company-secret', field: 'maximumRuns', previous: 2, current: 3 }]);
|
|
assert.deepEqual(repair.runtimeConditions.studio144Accounting, { key: 'skills.studio-test', previousMinimumRuns: 2, previousMaximumRuns: 2, minimumRuns: 2, maximumRuns: 3, requiredActualAcceptedRuns: 3, originalAttemptTimeoutMs: 540000, humanMessages: 1, condition: 'Initial CEO + real Studio worker + exactly one source-bound completion delivery;2-run no-delivery positive is rejected.' });
|
|
assert.equal(repair.runtimeConditions.toolGuidance106.corePRUnmerged, false);
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.scannerAndCanaryCertificatesUnchanged, true);
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.sourceInputsChanged, true);
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.registrySha256, "efa70621e9fb42aa185f7ee616a1a726aa3eccb367e67e28817cedf26ef2ade8");
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.plugin558StillHeld, true);
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.expectedLockSha256, "54a81b2ed3f1f85eaa085c034560ac248e384db34fbc7aba8c5a3846c29b3ce8");
|
|
assert.equal(repair.runtimeConditions.sdkPublicProof.runtimeCompilerParserZodIdentitiesUnchanged, true);
|
|
assert.equal(repair.runtimeConditions.toolProposal487.corePRUnmerged, false);
|
|
assert.deepEqual(repair.runtimeConditions.toolProposal487.replay, {
|
|
"corePR": 18742,
|
|
"coreHead": "61996a96dd09e90a5788e8711a94fc5ae631f425",
|
|
"corePRUnmerged": false,
|
|
"condition": "A new Ask-first request only for an authenticated later same-person human intent after the prior decline; same-intent retry and derived or foreign sources remain denied. No approval/execution authority change.",
|
|
"acceptedDirectSources": [
|
|
"issue.comment",
|
|
"issue.comment.reopen"
|
|
],
|
|
"actualPostAssertionPGCasesPassed": 2
|
|
});
|
|
});
|
|
|
|
|
|
test('Company approval metadata is projected without executing a fixture and rejects foreign or changed bounds', () => {
|
|
const declaration = { scenarioId: 'secrets.configure-company-secret', optionalCompanySecretBindingApproval: true,
|
|
expectedRunCount: 3, minimumRunCount: 2, expectedHumanMessageCount: 2, attemptTimeoutMs: 480000,
|
|
setup() { throw new Error('Fixture must not execute'); } };
|
|
assert.deepEqual(companySecretBindingApprovalMetadata(declaration),
|
|
{ optionalCompanySecretBindingApproval: true, expectedHumanMessageCount: 2 });
|
|
assert.deepEqual(companySecretBindingApprovalMetadata({ scenarioId: 'other' }), {});
|
|
const future = structuredClone(manifest);
|
|
Object.assign(future.cases.find(value => value.key === declaration.scenarioId),
|
|
companySecretBindingApprovalMetadata(declaration), { minimumRuns: 2, maximumRuns: 3 });
|
|
assert.equal(validateFullCatalogManifest(future), future);
|
|
for (const mutation of [
|
|
{ scenarioId: 'secrets.personal-secret' }, { optionalCompanySecretBindingApproval: false },
|
|
{ expectedRunCount: 2 }, { minimumRunCount: 3 }, { expectedHumanMessageCount: 3 }, { attemptTimeoutMs: 480001 },
|
|
]) assert.throws(() => companySecretBindingApprovalMetadata({ ...declaration, ...mutation }), /company_approval_invalid/);
|
|
for (const mutation of [
|
|
{ key: 'secrets.personal-secret' }, { optionalCompanySecretBindingApproval: false },
|
|
{ maximumRuns: 2 }, { minimumRuns: 3 }, { expectedHumanMessageCount: 3 }, { attemptTimeoutMs: 480001 },
|
|
]) {
|
|
const invalid = structuredClone(future);
|
|
Object.assign(invalid.cases.find(value => value.key === declaration.scenarioId), mutation);
|
|
assert.throws(() => validateFullCatalogManifest(invalid), /company_approval_invalid/);
|
|
}
|
|
});
|
|
|
|
|
|
test('source admission joins the optional Company approval and base humans to actual static task metadata', () => {
|
|
const row = { key: 'secrets.configure-company-secret', optionalCompanySecretBindingApproval: true,
|
|
minimumRuns: 2, maximumRuns: 3, expectedHumanMessageCount: 2, attemptTimeoutMs: 480000 };
|
|
const task = { id: row.key, optionalCompanySecretBindingApproval: true, minimumExpectedRunCount: 2,
|
|
expectedRunCount: 3, expectedHumanMessageCount: 2, attemptTimeoutMs: { local: 480000 } };
|
|
assert.doesNotThrow(() => validateCompanySecretBindingApprovalSource(row, task));
|
|
for (const mutation of [{ optionalCompanySecretBindingApproval: undefined }, { expectedHumanMessageCount: 3 },
|
|
{ id: 'secrets.personal-secret' }, { expectedRunCount: 2 }, { minimumExpectedRunCount: 3 }]) {
|
|
assert.throws(() => validateCompanySecretBindingApprovalSource(row, { ...task, ...mutation }));
|
|
}
|
|
const unmarked = { ...row }; delete unmarked.optionalCompanySecretBindingApproval;
|
|
assert.throws(() => validateCompanySecretBindingApprovalSource(unmarked, task), /approval mismatch/);
|
|
});
|