@muggleai/works 5.34.0-staging.308 → 5.34.0-staging.310
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/{chunk-C4L5SKOX.js → chunk-SMUHQITB.js} +27 -14
- package/dist/{chunk-L4ZDHFEJ.js → chunk-TVA5J73U.js} +294 -73
- package/dist/cli.js +2 -2
- package/dist/index.js +2 -2
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/skills/_shared/dev-loop/fresh-session.md +1 -1
- package/dist/plugin/skills/_shared/dev-loop/run.md +2 -1
- package/dist/plugin/skills/_shared/test-case-design.md +8 -0
- package/dist/plugin/skills/do/e2e-acceptance.md +1 -1
- package/dist/plugin/skills/muggle-browser-task/SKILL.md +3 -0
- package/dist/plugin/skills/muggle-test/SKILL.md +1 -1
- package/dist/plugin/skills/muggle-test/execute-remote.md +1 -1
- package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +1 -0
- package/dist/plugin/skills/muggle-test-import/SKILL.md +2 -0
- package/dist/plugin/skills/muggle-test-regenerate-missing/SKILL.md +1 -1
- package/dist/release-manifest.json +4 -4
- package/dist/{src-Z5YREWY6.js → src-5M2MYBRC.js} +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-mcp.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/skills/_shared/dev-loop/fresh-session.md +1 -1
- package/plugin/skills/_shared/dev-loop/run.md +2 -1
- package/plugin/skills/_shared/test-case-design.md +8 -0
- package/plugin/skills/do/e2e-acceptance.md +1 -1
- package/plugin/skills/muggle-browser-task/SKILL.md +3 -0
- package/plugin/skills/muggle-test/SKILL.md +1 -1
- package/plugin/skills/muggle-test/execute-remote.md +1 -1
- package/plugin/skills/muggle-test-feature-local/SKILL.md +1 -0
- package/plugin/skills/muggle-test-import/SKILL.md +2 -0
- package/plugin/skills/muggle-test-regenerate-missing/SKILL.md +1 -1
- package/scripts/postinstall.mjs +12 -13
- package/scripts/release-integrity/classifyTrustRootFailure.mjs +67 -0
- package/scripts/release-integrity/constants.mjs +55 -0
- package/scripts/release-integrity/enforceReleaseSignature.mjs +62 -0
- package/scripts/release-integrity/findBundleMismatch.mjs +58 -0
- package/scripts/release-integrity/index.d.mts +10 -1
- package/scripts/release-integrity/index.mjs +1 -0
- package/scripts/release-integrity/resolveIntegrityPolicy.mjs +11 -2
- package/scripts/release-integrity/verifyReleaseSignature.mjs +60 -8
|
@@ -49,7 +49,8 @@ Per test case, or per record when it has [records](#records), branch on `mode`:
|
|
|
49
49
|
**Replay**
|
|
50
50
|
1. `muggle-remote-test-script-get` (the record's `testScriptId`; with no records, the latest replayable script — the lane-scoped one the caller resolved during classification per [`../failure-mode-handling.md`](../failure-mode-handling.md) §A) → note `actionScriptId`.
|
|
51
51
|
2. `muggle-remote-action-script-get` with that id → full `actionScript` (see [`action-script.md`](action-script.md)), plus the `pinnedAccount` and `freshSession` its `actionParams` recorded.
|
|
52
|
-
3. `muggle-
|
|
52
|
+
3. `muggle-remote-test-case-get` for the script's `testCaseId` → its current `description`, which holds the run's [limits](../test-case-design.md#limits).
|
|
53
|
+
4. `muggle-local-execute-replay` with `testScript`, `actionScript`, `testCaseDescription` (that `description`), `localUrl`, `cwd`, `showUi`, `pinnedAccount` and `freshSession` (each copied from the recording's `actionParams` when present; see [`fresh-session.md`](fresh-session.md)), `timeoutMs` (see [`timeouts.md`](timeouts.md)).
|
|
53
54
|
|
|
54
55
|
**Regen**
|
|
55
56
|
1. `muggle-remote-test-case-get` → full test case object.
|
|
@@ -10,3 +10,11 @@ Every test case verifies exactly **one** user-observable behavior. Never bundle
|
|
|
10
10
|
**Never bake bootstrap into a test case description.** Signup, login, seed data, prerequisite navigation, tear-down — none of these belong inside the test case body. Write only the verification itself. Setup arrives as its own prerequisite case: the chain runs ahead of the target, and the session it leaves behind is what the target starts from. Nothing is spliced into the case body.
|
|
11
11
|
|
|
12
12
|
**Never consolidate the generator's output.** When `muggle-remote-test-case-generate-from-prompt` returns N micro-tests from a single prompt, that decomposition is the authoritative one. Do not "merge them into 1 for simplicity," do not "rewrite them to share bootstrap," do not "collapse them to match a 4 UC / 4 TC plan." Accept what the generator gave you.
|
|
13
|
+
|
|
14
|
+
## Limits
|
|
15
|
+
|
|
16
|
+
Anything a test must or must not touch, including which target and which path, goes in the test case's stored `description` before the run. A limit stated only in chat with the coding agent does not reach the run.
|
|
17
|
+
|
|
18
|
+
- Store it with `muggle-remote-test-case-create`, or with `muggle-remote-test-case-update` on an existing case, keeping the stored text and adding to it. When a generator wrote the draft, check that the limit survived into its `description`.
|
|
19
|
+
- Every run reads the stored text: local and cloud, generation, regeneration and replay. Text given for one run adds to it and never replaces it.
|
|
20
|
+
- A use case edit that really changes `title`, `description` or `url`, and every `muggle-remote-use-case-update-from-prompt` call, replaces the use case's test cases and drops their limits. Store them again afterwards.
|
|
@@ -122,7 +122,7 @@ Create what the scope planned, before any run:
|
|
|
122
122
|
|
|
123
123
|
1. **New use cases** — one `muggle-remote-use-case-create-from-prompts` call with every `newUseCases` instruction in its `instructions` array. Map each created use case back to its key.
|
|
124
124
|
2. **New test cases** — one `muggle-remote-test-case-generate-from-prompt` per `newTestCases` entry, all in one message, with `projectId`, the resolved `useCaseId`, and the entry's `instruction`.
|
|
125
|
-
3. **Create every generated case** — `muggle-remote-test-case-create` for each, in parallel. Accept the generator's decomposition as-is ([`../_shared/test-case-design.md`](../_shared/test-case-design.md)): N micro-tests from one instruction are N test cases. Record each `testCaseId` against its key; the report and a Stage 7.5 re-run name new cases by id.
|
|
125
|
+
3. **Create every generated case** — `muggle-remote-test-case-create` for each, in parallel. Accept the generator's decomposition as-is ([`../_shared/test-case-design.md`](../_shared/test-case-design.md)): N micro-tests from one instruction are N test cases. Anything the request says a case must or must not touch goes in that case's `description` ([limits](../_shared/test-case-design.md#limits)); add it if the generator's draft dropped it. Record each `testCaseId` against its key; the report and a Stage 7.5 re-run name new cases by id.
|
|
126
126
|
|
|
127
127
|
A failed create leaves its entry `INCONCLUSIVE` with reason `case creation failed: <error>`; it stays in the report.
|
|
128
128
|
|
|
@@ -108,6 +108,8 @@ Do not proceed further.
|
|
|
108
108
|
|
|
109
109
|
2. Load and call `muggle-remote-action-script-get` with `actionScriptId`.
|
|
110
110
|
|
|
111
|
+
3. Load and call `muggle-remote-test-case-get` with the test case ID from Step 4. Keep its `description`.
|
|
112
|
+
|
|
111
113
|
Tell the user: `Executing task...`
|
|
112
114
|
|
|
113
115
|
## Step 7 — Execute locally
|
|
@@ -115,6 +117,7 @@ Tell the user: `Executing task...`
|
|
|
115
117
|
Load and call `muggle-local-execute-replay` with:
|
|
116
118
|
- `testScript`: the full object from Step 6 (from `muggle-remote-test-script-get`)
|
|
117
119
|
- `actionScript`: the content from Step 6 (from `muggle-remote-action-script-get`)
|
|
120
|
+
- `testCaseDescription`: the `description` from Step 6 (from `muggle-remote-test-case-get`)
|
|
118
121
|
- `localUrl`: from Step 1
|
|
119
122
|
- `mutations`: the `mutations[]` array from Step 1 (omit if empty)
|
|
120
123
|
|
|
@@ -42,7 +42,7 @@ Reach for these when the user is weighing Muggle Test against hand-written specs
|
|
|
42
42
|
|
|
43
43
|
## Test Case Design: One Atomic Behavior Per Test Case
|
|
44
44
|
|
|
45
|
-
Every test case verifies exactly **one** user-observable behavior, carries no signup, login, navigation, or seed-data steps, and the generator's decomposition is kept as-is. The full rule, with examples: [`_shared/test-case-design.md`](../_shared/test-case-design.md).
|
|
45
|
+
Every test case verifies exactly **one** user-observable behavior, carries no signup, login, navigation, or seed-data steps, and the generator's decomposition is kept as-is. The full rule, with examples: [`_shared/test-case-design.md`](../_shared/test-case-design.md). Anything the user said a test must or must not touch, including which target and which path, goes in its stored `description` before the run ([limits](../_shared/test-case-design.md#limits)); stated only in this chat, it does not reach the run.
|
|
46
46
|
|
|
47
47
|
**Never skip the generate→review cycle.** Even when you are 100% confident about the right shape, always present the generated test cases to the user before calling `muggle-remote-test-case-create`. "I'll skip the generate→review cycle and create directly" is a sign you're about to get it wrong.
|
|
48
48
|
|
|
@@ -25,7 +25,7 @@ Branch each test case on its `mode`, then issue **all** workflow-start calls in
|
|
|
25
25
|
- `url`: The preview/staging URL
|
|
26
26
|
- `goal`: From the test case
|
|
27
27
|
- `precondition`: From the test case (use `"None"` if empty)
|
|
28
|
-
- `instructions`:
|
|
28
|
+
- `instructions`: The test case's `description`, plus anything specific to this run. The stored `description` always reaches the run, so a limit belongs there ([limits](../_shared/test-case-design.md#limits)).
|
|
29
29
|
- `expectedResult`: From the test case
|
|
30
30
|
|
|
31
31
|
**Replay-mode test case** — `muggle-remote-workflow-start-test-script-replay` against the latest replayable script for that test case (resolve via `muggle-remote-test-script-list` with `runEnvironmentType: "remote"` if not already in hand from the classification step). Tag results with `mode: "replay"` so the router routes failures correctly.
|
|
@@ -109,6 +109,7 @@ Prompt for projects: "Pick the project to group this test into:"
|
|
|
109
109
|
- **Test case — Create new test case** (requires a chosen `useCaseId`): User provides an instruction describing what to test.
|
|
110
110
|
1. `muggle-remote-test-case-generate-from-prompt` with `projectId`, `useCaseId`, `instruction` — **preview only** (server test-case prompt preview); show the returned draft(s); get confirmation via `AskUserQuestion`.
|
|
111
111
|
2. Persist the accepted draft with `muggle-remote-test-case-create`, mapping preview fields into the required properties (`title`, `description`, `goal`, `expectedResult`, `url`, etc.). Then continue from **section 5** with that `testCaseId`.
|
|
112
|
+
- **Limits:** anything the user said the test must or must not touch, including which target and which path, goes in the chosen test case's stored `description` before the run, on a new case or an existing one ([limits](../_shared/test-case-design.md#limits)). Stated only in this chat, it does not reach the run.
|
|
112
113
|
|
|
113
114
|
### 3. Ensure Local Services Are Ready
|
|
114
115
|
|
|
@@ -343,6 +343,8 @@ For each use case, run a bulk-preview job to generate its test cases.
|
|
|
343
343
|
url: <from testCase.url>
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
+
Anything the source says a test must or must not touch stays in `description`; add it if the preview dropped it ([limits](../_shared/test-case-design.md#limits)).
|
|
347
|
+
|
|
346
348
|
Print progress: `Creating test cases for "User Authentication"... (1/3)`
|
|
347
349
|
|
|
348
350
|
It is safe to create test cases for different use cases in parallel once their bulk-preview
|
|
@@ -146,7 +146,7 @@ Send a single bulk request instead of dispatching one workflow per test case:
|
|
|
146
146
|
- `projectId` — from Step 2
|
|
147
147
|
- `name` — `"muggle-test-regenerate-missing: bulk ({count} test cases)"` where `{count}` is the number of selected test cases
|
|
148
148
|
- `testCaseIds` — array of all selected test case IDs from Step 5
|
|
149
|
-
2. The backend handles looking up full test case details (goal, precondition,
|
|
149
|
+
2. The backend handles looking up full test case details (goal, precondition, description, expectedResult, url), so there is no need to call `muggle-remote-test-case-get` per test case.
|
|
150
150
|
3. Parse the response to get the `items` array with per-test-case status. Each item contains the test case ID, dispatch status, and (when successful) the workflow runtime ID.
|
|
151
151
|
|
|
152
152
|
**Failure handling:** the bulk API returns per-item status in the response `items` array. Individual test cases may fail (validation error, missing field, etc.) while others succeed. Surface failures in the Step 7 report — partial progress beats no progress.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release": "5.34.0-staging.
|
|
3
|
-
"buildId": "run-
|
|
4
|
-
"commitSha": "
|
|
5
|
-
"buildTime": "2026-11-
|
|
2
|
+
"release": "5.34.0-staging.310",
|
|
3
|
+
"buildId": "run-310-1",
|
|
4
|
+
"commitSha": "8357ccb201eb2959719b07ba87cedd1967b3bee4",
|
|
5
|
+
"buildTime": "2026-11-05T22:51:37Z",
|
|
6
6
|
"serviceName": "muggle-ai-works-mcp"
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CLAUDE_CODE_AUTH_STATUS_ARGS, CLAUDE_CODE_CHECK_TIMEOUT_MS, CLAUDE_CODE_EXECUTABLE, CLAUDE_CODE_EXECUTABLE_NOT_FOUND_CODE, CLAUDE_CODE_SESSION_LINK_ENV_VARS, CLAUDE_CODE_VERSION_ARGS, CheckoutFreshnessVerdict, ClaudeCodeReadiness, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ELECTRON_APP_RESOURCES_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, StackCheckVerdict, StackClaimVerdict, StackLeaseEndReason, StackMismatchKind, StackPortAction, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, compareQueuePlaces, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackReap, decideStackRelease, decideStackRunEnd, decideStackRunStart, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, describeStackMismatch, e2e_exports as e2e, evaluateCheckoutFreshness, findVacatedNeeds, finishStackRun, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir2 as getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports as localQa, lookUpCheckoutPullRequest, markOnboardingCompleted, maskLlmApiKey, mcp_exports as mcp, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, e2e_exports as qa, readPreferencesMetadata, readRunView, readServiceStackStatus, reapServiceStack, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveElectronAppResourcesDir, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, startStackRun, stopVacatedServices, toDisplayRef, toolRequiresAuth, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-
|
|
1
|
+
export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, BUSY_EXIT_CODE, CLAUDE_CODE_AUTH_STATUS_ARGS, CLAUDE_CODE_CHECK_TIMEOUT_MS, CLAUDE_CODE_EXECUTABLE, CLAUDE_CODE_EXECUTABLE_NOT_FOUND_CODE, CLAUDE_CODE_SESSION_LINK_ENV_VARS, CLAUDE_CODE_VERSION_ARGS, CheckoutFreshnessVerdict, ClaudeCodeReadiness, DEFAULT_LOCAL_LLM_BASE_URL, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ELECTRON_APP_RESOURCES_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, LLM_CREDENTIALS_FILE_MODE, LLM_CREDENTIALS_FILE_NAME, LLM_SOURCE_HEADER, LLM_SOURCE_OPTIONS, LLM_SOURCE_OWNED_ENV_NAMES, LLM_SOURCE_PROMPT, LLM_SOURCE_SCOPE_NOTE, LlmSource, MASKED_API_KEY_PREFIX, MASKED_API_KEY_VISIBLE_CHARS, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, StackCheckVerdict, StackClaimVerdict, StackLeaseEndReason, StackMismatchKind, StackPortAction, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyLlmSourceSelection, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildLlmSourcePlan, buildOnboardingPlan, buildToolInputJsonSchema, calculateFileChecksum, checkServiceStack, claimServiceStack, compareQueuePlaces, completeOnboarding, createApiKeyWithToken, createChildLogger, decideStackClaim, decideStackReap, decideStackRelease, decideStackRunEnd, decideStackRunStart, deleteApiKeyData, deleteCredentials, describeLlmSourceStatus, describeStackMismatch, e2e_exports as e2e, evaluateCheckoutFreshness, findVacatedNeeds, finishStackRun, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir2 as getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLlmSourceOption, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, isValidLocalBaseUrl, loadApiKeyData, loadCredentials, local_exports as localQa, lookUpCheckoutPullRequest, markOnboardingCompleted, maskLlmApiKey, mcp_exports as mcp, needsConflict, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, portOfUrl, e2e_exports as qa, readPreferencesMetadata, readRunView, readServiceStackStatus, reapServiceStack, reconcileProjectPreferences, recordOnboardingSkip, releaseServiceStack, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveElectronAppResourcesDir, resolveLlmSourceStatus, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, startStackRun, stopVacatedServices, toDisplayRef, toolRequiresAuth, validatePreference, verifyFileChecksum, writeLlmEnvBlock, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-SMUHQITB.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muggleai/works",
|
|
3
3
|
"mcpName": "io.github.multiplex-ai/muggle",
|
|
4
|
-
"version": "5.34.0-staging.
|
|
4
|
+
"version": "5.34.0-staging.310",
|
|
5
5
|
"description": "13 years of Microsoft hyperscale engineering, packaged as a harness for your AI coding agent.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
4
|
-
"version": "5.34.0-staging.
|
|
4
|
+
"version": "5.34.0-staging.310",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
7
7
|
"email": "support@muggle-ai.com"
|
package/plugin/.codex-mcp.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
|
-
"version": "5.34.0-staging.
|
|
3
|
+
"version": "5.34.0-staging.310",
|
|
4
4
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
5
|
-
"version": "5.34.0-staging.
|
|
5
|
+
"version": "5.34.0-staging.310",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
package/plugin/.mcp.json
CHANGED
|
@@ -15,7 +15,7 @@ For an older test case with no stored flag, pass `freshSession: true` when it ne
|
|
|
15
15
|
|
|
16
16
|
## Replay
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
A replay's account and session are the ones the script was recorded with, never the test case's current ones. Copy `pinnedAccount` and `freshSession` from the `actionParams` of the `muggle-remote-action-script-get` result onto `muggle-local-execute-replay` when present. A recording that carries neither may predate run identities, so decide its `freshSession` by the list above, as before.
|
|
19
19
|
|
|
20
20
|
## Changing the stored value
|
|
21
21
|
|
|
@@ -49,7 +49,8 @@ Per test case, or per record when it has [records](#records), branch on `mode`:
|
|
|
49
49
|
**Replay**
|
|
50
50
|
1. `muggle-remote-test-script-get` (the record's `testScriptId`; with no records, the latest replayable script — the lane-scoped one the caller resolved during classification per [`../failure-mode-handling.md`](../failure-mode-handling.md) §A) → note `actionScriptId`.
|
|
51
51
|
2. `muggle-remote-action-script-get` with that id → full `actionScript` (see [`action-script.md`](action-script.md)), plus the `pinnedAccount` and `freshSession` its `actionParams` recorded.
|
|
52
|
-
3. `muggle-
|
|
52
|
+
3. `muggle-remote-test-case-get` for the script's `testCaseId` → its current `description`, which holds the run's [limits](../test-case-design.md#limits).
|
|
53
|
+
4. `muggle-local-execute-replay` with `testScript`, `actionScript`, `testCaseDescription` (that `description`), `localUrl`, `cwd`, `showUi`, `pinnedAccount` and `freshSession` (each copied from the recording's `actionParams` when present; see [`fresh-session.md`](fresh-session.md)), `timeoutMs` (see [`timeouts.md`](timeouts.md)).
|
|
53
54
|
|
|
54
55
|
**Regen**
|
|
55
56
|
1. `muggle-remote-test-case-get` → full test case object.
|
|
@@ -10,3 +10,11 @@ Every test case verifies exactly **one** user-observable behavior. Never bundle
|
|
|
10
10
|
**Never bake bootstrap into a test case description.** Signup, login, seed data, prerequisite navigation, tear-down — none of these belong inside the test case body. Write only the verification itself. Setup arrives as its own prerequisite case: the chain runs ahead of the target, and the session it leaves behind is what the target starts from. Nothing is spliced into the case body.
|
|
11
11
|
|
|
12
12
|
**Never consolidate the generator's output.** When `muggle-remote-test-case-generate-from-prompt` returns N micro-tests from a single prompt, that decomposition is the authoritative one. Do not "merge them into 1 for simplicity," do not "rewrite them to share bootstrap," do not "collapse them to match a 4 UC / 4 TC plan." Accept what the generator gave you.
|
|
13
|
+
|
|
14
|
+
## Limits
|
|
15
|
+
|
|
16
|
+
Anything a test must or must not touch, including which target and which path, goes in the test case's stored `description` before the run. A limit stated only in chat with the coding agent does not reach the run.
|
|
17
|
+
|
|
18
|
+
- Store it with `muggle-remote-test-case-create`, or with `muggle-remote-test-case-update` on an existing case, keeping the stored text and adding to it. When a generator wrote the draft, check that the limit survived into its `description`.
|
|
19
|
+
- Every run reads the stored text: local and cloud, generation, regeneration and replay. Text given for one run adds to it and never replaces it.
|
|
20
|
+
- A use case edit that really changes `title`, `description` or `url`, and every `muggle-remote-use-case-update-from-prompt` call, replaces the use case's test cases and drops their limits. Store them again afterwards.
|
|
@@ -122,7 +122,7 @@ Create what the scope planned, before any run:
|
|
|
122
122
|
|
|
123
123
|
1. **New use cases** — one `muggle-remote-use-case-create-from-prompts` call with every `newUseCases` instruction in its `instructions` array. Map each created use case back to its key.
|
|
124
124
|
2. **New test cases** — one `muggle-remote-test-case-generate-from-prompt` per `newTestCases` entry, all in one message, with `projectId`, the resolved `useCaseId`, and the entry's `instruction`.
|
|
125
|
-
3. **Create every generated case** — `muggle-remote-test-case-create` for each, in parallel. Accept the generator's decomposition as-is ([`../_shared/test-case-design.md`](../_shared/test-case-design.md)): N micro-tests from one instruction are N test cases. Record each `testCaseId` against its key; the report and a Stage 7.5 re-run name new cases by id.
|
|
125
|
+
3. **Create every generated case** — `muggle-remote-test-case-create` for each, in parallel. Accept the generator's decomposition as-is ([`../_shared/test-case-design.md`](../_shared/test-case-design.md)): N micro-tests from one instruction are N test cases. Anything the request says a case must or must not touch goes in that case's `description` ([limits](../_shared/test-case-design.md#limits)); add it if the generator's draft dropped it. Record each `testCaseId` against its key; the report and a Stage 7.5 re-run name new cases by id.
|
|
126
126
|
|
|
127
127
|
A failed create leaves its entry `INCONCLUSIVE` with reason `case creation failed: <error>`; it stays in the report.
|
|
128
128
|
|
|
@@ -108,6 +108,8 @@ Do not proceed further.
|
|
|
108
108
|
|
|
109
109
|
2. Load and call `muggle-remote-action-script-get` with `actionScriptId`.
|
|
110
110
|
|
|
111
|
+
3. Load and call `muggle-remote-test-case-get` with the test case ID from Step 4. Keep its `description`.
|
|
112
|
+
|
|
111
113
|
Tell the user: `Executing task...`
|
|
112
114
|
|
|
113
115
|
## Step 7 — Execute locally
|
|
@@ -115,6 +117,7 @@ Tell the user: `Executing task...`
|
|
|
115
117
|
Load and call `muggle-local-execute-replay` with:
|
|
116
118
|
- `testScript`: the full object from Step 6 (from `muggle-remote-test-script-get`)
|
|
117
119
|
- `actionScript`: the content from Step 6 (from `muggle-remote-action-script-get`)
|
|
120
|
+
- `testCaseDescription`: the `description` from Step 6 (from `muggle-remote-test-case-get`)
|
|
118
121
|
- `localUrl`: from Step 1
|
|
119
122
|
- `mutations`: the `mutations[]` array from Step 1 (omit if empty)
|
|
120
123
|
|
|
@@ -42,7 +42,7 @@ Reach for these when the user is weighing Muggle Test against hand-written specs
|
|
|
42
42
|
|
|
43
43
|
## Test Case Design: One Atomic Behavior Per Test Case
|
|
44
44
|
|
|
45
|
-
Every test case verifies exactly **one** user-observable behavior, carries no signup, login, navigation, or seed-data steps, and the generator's decomposition is kept as-is. The full rule, with examples: [`_shared/test-case-design.md`](../_shared/test-case-design.md).
|
|
45
|
+
Every test case verifies exactly **one** user-observable behavior, carries no signup, login, navigation, or seed-data steps, and the generator's decomposition is kept as-is. The full rule, with examples: [`_shared/test-case-design.md`](../_shared/test-case-design.md). Anything the user said a test must or must not touch, including which target and which path, goes in its stored `description` before the run ([limits](../_shared/test-case-design.md#limits)); stated only in this chat, it does not reach the run.
|
|
46
46
|
|
|
47
47
|
**Never skip the generate→review cycle.** Even when you are 100% confident about the right shape, always present the generated test cases to the user before calling `muggle-remote-test-case-create`. "I'll skip the generate→review cycle and create directly" is a sign you're about to get it wrong.
|
|
48
48
|
|
|
@@ -25,7 +25,7 @@ Branch each test case on its `mode`, then issue **all** workflow-start calls in
|
|
|
25
25
|
- `url`: The preview/staging URL
|
|
26
26
|
- `goal`: From the test case
|
|
27
27
|
- `precondition`: From the test case (use `"None"` if empty)
|
|
28
|
-
- `instructions`:
|
|
28
|
+
- `instructions`: The test case's `description`, plus anything specific to this run. The stored `description` always reaches the run, so a limit belongs there ([limits](../_shared/test-case-design.md#limits)).
|
|
29
29
|
- `expectedResult`: From the test case
|
|
30
30
|
|
|
31
31
|
**Replay-mode test case** — `muggle-remote-workflow-start-test-script-replay` against the latest replayable script for that test case (resolve via `muggle-remote-test-script-list` with `runEnvironmentType: "remote"` if not already in hand from the classification step). Tag results with `mode: "replay"` so the router routes failures correctly.
|
|
@@ -109,6 +109,7 @@ Prompt for projects: "Pick the project to group this test into:"
|
|
|
109
109
|
- **Test case — Create new test case** (requires a chosen `useCaseId`): User provides an instruction describing what to test.
|
|
110
110
|
1. `muggle-remote-test-case-generate-from-prompt` with `projectId`, `useCaseId`, `instruction` — **preview only** (server test-case prompt preview); show the returned draft(s); get confirmation via `AskUserQuestion`.
|
|
111
111
|
2. Persist the accepted draft with `muggle-remote-test-case-create`, mapping preview fields into the required properties (`title`, `description`, `goal`, `expectedResult`, `url`, etc.). Then continue from **section 5** with that `testCaseId`.
|
|
112
|
+
- **Limits:** anything the user said the test must or must not touch, including which target and which path, goes in the chosen test case's stored `description` before the run, on a new case or an existing one ([limits](../_shared/test-case-design.md#limits)). Stated only in this chat, it does not reach the run.
|
|
112
113
|
|
|
113
114
|
### 3. Ensure Local Services Are Ready
|
|
114
115
|
|
|
@@ -343,6 +343,8 @@ For each use case, run a bulk-preview job to generate its test cases.
|
|
|
343
343
|
url: <from testCase.url>
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
+
Anything the source says a test must or must not touch stays in `description`; add it if the preview dropped it ([limits](../_shared/test-case-design.md#limits)).
|
|
347
|
+
|
|
346
348
|
Print progress: `Creating test cases for "User Authentication"... (1/3)`
|
|
347
349
|
|
|
348
350
|
It is safe to create test cases for different use cases in parallel once their bulk-preview
|
|
@@ -146,7 +146,7 @@ Send a single bulk request instead of dispatching one workflow per test case:
|
|
|
146
146
|
- `projectId` — from Step 2
|
|
147
147
|
- `name` — `"muggle-test-regenerate-missing: bulk ({count} test cases)"` where `{count}` is the number of selected test cases
|
|
148
148
|
- `testCaseIds` — array of all selected test case IDs from Step 5
|
|
149
|
-
2. The backend handles looking up full test case details (goal, precondition,
|
|
149
|
+
2. The backend handles looking up full test case details (goal, precondition, description, expectedResult, url), so there is no need to call `muggle-remote-test-case-get` per test case.
|
|
150
150
|
3. Parse the response to get the `items` array with per-test-case status. Each item contains the test case ID, dispatch status, and (when successful) the workflow runtime ID.
|
|
151
151
|
|
|
152
152
|
**Failure handling:** the bulk API returns per-item status in the response `items` array. Individual test cases may fail (validation error, missing field, etc.) while others succeed. Surface failures in the Step 7 report — partial progress beats no progress.
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -36,8 +36,8 @@ import { clearUpgradeNoticeCache } from "./upgrade-notice-cache.mjs";
|
|
|
36
36
|
import { listRunningInstallDirectoryNames, normalizeInstallDirectoryName } from "./running-studio-installs.mjs";
|
|
37
37
|
import {
|
|
38
38
|
SIGNATURE_BUNDLE_SUFFIX,
|
|
39
|
+
enforceReleaseSignature,
|
|
39
40
|
resolveIntegrityPolicy,
|
|
40
|
-
verifyReleaseSignature,
|
|
41
41
|
} from "./release-integrity/index.mjs";
|
|
42
42
|
import { buildPostInstallGuide, showPostInstallGuide } from "./post-install-guide/index.mjs";
|
|
43
43
|
|
|
@@ -814,20 +814,19 @@ async function downloadElectronApp() {
|
|
|
814
814
|
}
|
|
815
815
|
|
|
816
816
|
if (integrityPolicy.requiresSignature) {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
817
|
+
try {
|
|
818
|
+
await enforceReleaseSignature({
|
|
819
|
+
artifactPath: tempFile,
|
|
820
|
+
bundleUrl: downloadUrl + SIGNATURE_BUNDLE_SUFFIX,
|
|
821
|
+
signerIdentityUri: config.signerIdentityUri || "",
|
|
822
|
+
expectedChecksum: expectedChecksum,
|
|
823
|
+
logInfo: log,
|
|
824
|
+
logWarning: log,
|
|
825
|
+
});
|
|
826
|
+
} catch (error) {
|
|
824
827
|
rmSync(versionDir, { recursive: true, force: true });
|
|
825
|
-
throw
|
|
826
|
-
"Signature verification failed, refusing to install: " + signatureResult.reason,
|
|
827
|
-
);
|
|
828
|
+
throw error;
|
|
828
829
|
}
|
|
829
|
-
|
|
830
|
-
log("Signature verified successfully.");
|
|
831
830
|
}
|
|
832
831
|
|
|
833
832
|
// Verify checksum
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TUFError } from "sigstore";
|
|
2
|
+
import {
|
|
3
|
+
FETCH_TIMEOUT_ERROR_NAME,
|
|
4
|
+
FLATTENED_TRUST_ROOT_TIMEOUT_PATTERN,
|
|
5
|
+
HOST_UNREACHABLE_ERROR_CODES,
|
|
6
|
+
MAX_ERROR_CAUSE_DEPTH,
|
|
7
|
+
TRUST_ROOT_FETCH_ERROR_CODES,
|
|
8
|
+
} from "./constants.mjs";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* List an error and its causes, outermost first.
|
|
12
|
+
*
|
|
13
|
+
* @param {unknown} error - The outermost error.
|
|
14
|
+
* @returns {Array<{name?: string, code?: unknown, message?: string, cause?: unknown}>} The chain, cut off at the depth limit.
|
|
15
|
+
*/
|
|
16
|
+
function listErrorChain(error) {
|
|
17
|
+
const chain = [];
|
|
18
|
+
let current = error;
|
|
19
|
+
|
|
20
|
+
while (current && chain.length < MAX_ERROR_CAUSE_DEPTH) {
|
|
21
|
+
chain.push(current);
|
|
22
|
+
current = current.cause;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return chain;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Decide whether a failed trust-root load means the host could not be reached.
|
|
30
|
+
*
|
|
31
|
+
* Only pass an error from loading the trust root: that step never reads the bundle,
|
|
32
|
+
* so nothing a bundle contains can reach this decision. Anything not positively
|
|
33
|
+
* recognised as a network failure is false, which refuses the install. TLS failures,
|
|
34
|
+
* HTTP statuses, invalid TUF metadata and file system errors are all false, because
|
|
35
|
+
* in each the host answered or the failure is local.
|
|
36
|
+
*
|
|
37
|
+
* @param {unknown} trustRootError - What loading the trust root rejected with.
|
|
38
|
+
* @returns {boolean} True only for a recognised network failure reaching the host.
|
|
39
|
+
*/
|
|
40
|
+
export function isTrustRootUnreachable(trustRootError) {
|
|
41
|
+
if (!(trustRootError instanceof TUFError) || !TRUST_ROOT_FETCH_ERROR_CODES.has(trustRootError.code)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return listErrorChain(trustRootError.cause).some(
|
|
46
|
+
(chainedError) =>
|
|
47
|
+
chainedError.name === FETCH_TIMEOUT_ERROR_NAME ||
|
|
48
|
+
HOST_UNREACHABLE_ERROR_CODES.has(chainedError.code) ||
|
|
49
|
+
FLATTENED_TRUST_ROOT_TIMEOUT_PATTERN.test(chainedError.message ?? ""),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Render an error and its causes as one line, since the outermost TUF message alone
|
|
55
|
+
* never says what went wrong.
|
|
56
|
+
*
|
|
57
|
+
* @param {unknown} error - The outermost error.
|
|
58
|
+
* @returns {string} Every message in the chain, outermost first.
|
|
59
|
+
*
|
|
60
|
+
* Output shape: `"error refreshing TUF metadata: fetch failed: getaddrinfo ENOTFOUND tuf-repo-cdn.sigstore.dev"`
|
|
61
|
+
*/
|
|
62
|
+
export function describeErrorChain(error) {
|
|
63
|
+
return listErrorChain(error)
|
|
64
|
+
.map((chainedError) => chainedError.message)
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join(": ");
|
|
67
|
+
}
|
|
@@ -6,3 +6,58 @@ export const SIGNER_CERTIFICATE_ISSUER = "https://token.actions.githubuserconten
|
|
|
6
6
|
|
|
7
7
|
/** Abort budget for fetching a signature bundle. */
|
|
8
8
|
export const SIGNATURE_FETCH_TIMEOUT_MS = 30_000;
|
|
9
|
+
|
|
10
|
+
/** Host every signature check reads the Sigstore trust root from. */
|
|
11
|
+
export const SIGNATURE_TRUST_ROOT_HOST = "tuf-repo-cdn.sigstore.dev";
|
|
12
|
+
|
|
13
|
+
/** Printed once a download's signature has been proven. */
|
|
14
|
+
export const SIGNATURE_VERIFIED_MESSAGE = "Signature verified successfully.";
|
|
15
|
+
|
|
16
|
+
/** Opens every signature refusal, ahead of the cause. */
|
|
17
|
+
export const SIGNATURE_REFUSAL_PREFIX = "Signature verification failed, refusing to install: ";
|
|
18
|
+
|
|
19
|
+
/** Digest algorithm release bundles record, as the bundle spells it. */
|
|
20
|
+
export const BUNDLE_DIGEST_ALGORITHM = "SHA2_256";
|
|
21
|
+
|
|
22
|
+
/** The same digest algorithm, as node:crypto spells it. */
|
|
23
|
+
export const BUNDLE_HASH_ALGORITHM = "sha256";
|
|
24
|
+
|
|
25
|
+
/** Prefix an X.509 subject alternative name carries when it holds a URI. */
|
|
26
|
+
export const CERTIFICATE_URI_SAN_PREFIX = "URI:";
|
|
27
|
+
|
|
28
|
+
/** Separator between the entries of a certificate's subject alternative name. */
|
|
29
|
+
export const CERTIFICATE_SAN_SEPARATOR = ", ";
|
|
30
|
+
|
|
31
|
+
/** TUF client failures that mean a fetch went wrong, not that a file on disk did. */
|
|
32
|
+
export const TRUST_ROOT_FETCH_ERROR_CODES = new Set([
|
|
33
|
+
"TUF_REFRESH_METADATA_ERROR",
|
|
34
|
+
"TUF_DOWNLOAD_TARGET_ERROR",
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
/** Socket and resolver failures that show no HTTP exchange with the host ever happened. */
|
|
38
|
+
export const HOST_UNREACHABLE_ERROR_CODES = new Set([
|
|
39
|
+
"ENOTFOUND",
|
|
40
|
+
"EAI_AGAIN",
|
|
41
|
+
"ECONNREFUSED",
|
|
42
|
+
"ECONNRESET",
|
|
43
|
+
"ETIMEDOUT",
|
|
44
|
+
"ENETUNREACH",
|
|
45
|
+
"EHOSTUNREACH",
|
|
46
|
+
"ENETDOWN",
|
|
47
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
48
|
+
"UND_ERR_SOCKET",
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
/** Name of the error an elapsed abort signal rejects a fetch with. */
|
|
52
|
+
export const FETCH_TIMEOUT_ERROR_NAME = "TimeoutError";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Whole message of a timeout the TUF client caught mid-refresh and flattened to text,
|
|
56
|
+
* leaving no type to read. `fetch failed` flattens the same way, but is left out on
|
|
57
|
+
* purpose: as text it cannot be told from a TLS failure.
|
|
58
|
+
*/
|
|
59
|
+
export const FLATTENED_TRUST_ROOT_TIMEOUT_PATTERN =
|
|
60
|
+
/^Unable to load (?:snapshot metadata|targets) error TimeoutError: The operation was aborted due to timeout$/;
|
|
61
|
+
|
|
62
|
+
/** Links followed through an error's causes; a cycle must not hang an install. */
|
|
63
|
+
export const MAX_ERROR_CAUSE_DEPTH = 5;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SIGNATURE_REFUSAL_PREFIX,
|
|
3
|
+
SIGNATURE_TRUST_ROOT_HOST,
|
|
4
|
+
SIGNATURE_VERIFIED_MESSAGE,
|
|
5
|
+
} from "./constants.mjs";
|
|
6
|
+
import { hasExpectedChecksum } from "./resolveIntegrityPolicy.mjs";
|
|
7
|
+
import { verifyReleaseSignature } from "./verifyReleaseSignature.mjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Hold a download to its signature, the same way on every install path.
|
|
11
|
+
*
|
|
12
|
+
* A signature that fails refuses. The one exception is a trust root the network kept
|
|
13
|
+
* out of reach: then nothing was proven either way, so the caller warns and the
|
|
14
|
+
* checksum decides. That needs a checksum to exist, so with none the download refuses.
|
|
15
|
+
* Callers must treat a checksum mismatch as fatal whenever `isSignatureVerified` is false.
|
|
16
|
+
*
|
|
17
|
+
* @param {object} params - Enforcement inputs.
|
|
18
|
+
* @param {string} params.artifactPath - Path to the downloaded asset.
|
|
19
|
+
* @param {string} params.bundleUrl - URL of the asset's Sigstore bundle.
|
|
20
|
+
* @param {string} params.signerIdentityUri - Certificate subject the signer must carry.
|
|
21
|
+
* @param {string} params.expectedChecksum - SHA256 the fallback would check, empty when none.
|
|
22
|
+
* @param {(message: string) => void} params.logInfo - Writes a progress line.
|
|
23
|
+
* @param {(message: string) => void} params.logWarning - Writes a warning.
|
|
24
|
+
* @returns {Promise<{isSignatureVerified: boolean}>} Whether the signature was proven.
|
|
25
|
+
* @throws {Error} When the download must not be installed.
|
|
26
|
+
*/
|
|
27
|
+
export async function enforceReleaseSignature({
|
|
28
|
+
artifactPath,
|
|
29
|
+
bundleUrl,
|
|
30
|
+
signerIdentityUri,
|
|
31
|
+
expectedChecksum,
|
|
32
|
+
logInfo,
|
|
33
|
+
logWarning,
|
|
34
|
+
}) {
|
|
35
|
+
const signatureOutcome = await verifyReleaseSignature({
|
|
36
|
+
artifactPath: artifactPath,
|
|
37
|
+
bundleUrl: bundleUrl,
|
|
38
|
+
signerIdentityUri: signerIdentityUri,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (signatureOutcome.valid) {
|
|
42
|
+
logInfo(SIGNATURE_VERIFIED_MESSAGE);
|
|
43
|
+
return { isSignatureVerified: true };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!signatureOutcome.isTrustRootUnreachable) {
|
|
47
|
+
throw new Error(SIGNATURE_REFUSAL_PREFIX + signatureOutcome.reason);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const networkFailure =
|
|
51
|
+
`a network failure kept ${SIGNATURE_TRUST_ROOT_HOST} out of reach (${signatureOutcome.reason})`;
|
|
52
|
+
|
|
53
|
+
if (!hasExpectedChecksum(expectedChecksum)) {
|
|
54
|
+
throw new Error(`${SIGNATURE_REFUSAL_PREFIX}${networkFailure}, and no checksum is available to check instead.`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
logWarning(
|
|
58
|
+
`WARNING: The signature was NOT verified: ${networkFailure}. ` +
|
|
59
|
+
`Falling back to the checksum check only.`,
|
|
60
|
+
);
|
|
61
|
+
return { isSignatureVerified: false };
|
|
62
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { X509Certificate, createHash, verify as verifyMessageSignature } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
BUNDLE_DIGEST_ALGORITHM,
|
|
4
|
+
BUNDLE_HASH_ALGORITHM,
|
|
5
|
+
CERTIFICATE_SAN_SEPARATOR,
|
|
6
|
+
CERTIFICATE_URI_SAN_PREFIX,
|
|
7
|
+
} from "./constants.mjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check a bundle against a download without the trust root.
|
|
11
|
+
*
|
|
12
|
+
* This proves nothing about who signed: with no trust root the certificate chain
|
|
13
|
+
* cannot be checked. It only catches a bundle that shows on its own that it is not
|
|
14
|
+
* what was signed, so a blocked host cannot wave those through to the checksum.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} params - Check inputs.
|
|
17
|
+
* @param {object} params.bundle - Parsed Sigstore bundle.
|
|
18
|
+
* @param {Buffer} params.artifactBytes - The downloaded asset.
|
|
19
|
+
* @param {string} params.signerIdentityUri - Certificate subject the signer must carry.
|
|
20
|
+
* @returns {string} Why the bundle cannot be for this download, empty when nothing shows that.
|
|
21
|
+
*/
|
|
22
|
+
export function findBundleMismatch({ bundle, artifactBytes, signerIdentityUri }) {
|
|
23
|
+
const messageSignature = bundle?.messageSignature;
|
|
24
|
+
const messageDigest = messageSignature?.messageDigest;
|
|
25
|
+
const certificateRawBytes = bundle?.verificationMaterial?.certificate?.rawBytes;
|
|
26
|
+
|
|
27
|
+
if (!messageDigest?.digest || !messageSignature?.signature || !certificateRawBytes) {
|
|
28
|
+
return "the signature bundle is missing its digest, signature or signing certificate";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (messageDigest.algorithm !== BUNDLE_DIGEST_ALGORITHM) {
|
|
32
|
+
return `the signature bundle uses an unexpected digest algorithm: ${messageDigest.algorithm}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const artifactDigest = createHash(BUNDLE_HASH_ALGORITHM).update(artifactBytes).digest();
|
|
36
|
+
if (!artifactDigest.equals(Buffer.from(messageDigest.digest, "base64"))) {
|
|
37
|
+
return "the download does not match the digest recorded in its signature bundle";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const signingCertificate = new X509Certificate(Buffer.from(certificateRawBytes, "base64"));
|
|
42
|
+
const certificateNames = (signingCertificate.subjectAltName ?? "").split(CERTIFICATE_SAN_SEPARATOR);
|
|
43
|
+
|
|
44
|
+
if (!certificateNames.includes(`${CERTIFICATE_URI_SAN_PREFIX}${signerIdentityUri}`)) {
|
|
45
|
+
return `the signing certificate was not issued to ${signerIdentityUri}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const isSignatureMatching = verifyMessageSignature(
|
|
49
|
+
BUNDLE_HASH_ALGORITHM,
|
|
50
|
+
artifactBytes,
|
|
51
|
+
signingCertificate.publicKey,
|
|
52
|
+
Buffer.from(messageSignature.signature, "base64"),
|
|
53
|
+
);
|
|
54
|
+
return isSignatureMatching ? "" : "the signature in the bundle does not match the download";
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return `the signature bundle could not be read: ${error.message}`;
|
|
57
|
+
}
|
|
58
|
+
}
|