Repository navigation
feat(desktop): isolate declared secrets during app builds - #9225
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[High impact] The PR changes secret-handling and export paths across desktop build and witness workflows. Do not merge until declared-secret checks cover JSON Unicode escapes and refuse unreadable handles, and failed host exports retain their saved output receipts. Findings
Fix with agent prompt### Issue 1
src/domain/desktop/buildSecrets.ts:63
If an app saves JSON using ASCII escapes, a declared Unicode password can escape the bundle check. `jsonEscaped` uses `JSON.stringify`, which leaves non-ASCII letters unchanged. For example, `e-Clé-Ünïcode-Fake-9` can be stored as `e-Cl\u00e9-\u00dcn\u00efcode-Fake-9`. None of the generated spellings matches those bytes, so `secretsIn` lets the file ship despite knowing the complete password.
Read JSON escapes at the format-owning boundary before comparing known values, rather than relying only on one encoder's output.
**How this was verified:** The bundle guard passes file bytes to `secretsIn`, whose JSON spellings do not cover Unicode escapes.
### Issue 2
src/application/desktop/DesktopBuildSecrets.ts:189-192
`all()` silently drops declared handle files that it cannot read. On a normal non-root host, a listed file with mode `000` makes `readBuildSecretFile` return a refusal. This filter removes that result, so export continues without checking its value. Other file-open refusals follow the same path.
These are explicitly declared handles, not unknown app-generated secrets. Refuse export when a listed handle cannot be checked, and preserve the safe reason.
**How this was verified:** File-open failures become refused results, and `all()` excludes every refused result from the secrets supplied to the bundle guard.
### Issue 3
src/application/desktop/DesktopBuildExport.ts:366-370
`writeBundle` has published the host bundle before `keepWithheld` starts. If saving a later withheld file fails, the catch returns only that error. It loses the bundle receipt and the handle mappings already chosen for earlier files, including collision suffixes such as `-2`. Retrying into the same directory then fails because it is occupied.
Retain each completed output before awaiting the next file and attach those facts to the error. The repository requires code to “Preserve partial facts and meaningful failure reasons.” This requirement must be satisfied before merging.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR adds declared secret handles and caller-selected withholding to desktop builds.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
H[Host secret files] --> S[Shared known values]
S --> T[Type by handle]
S --> R[Redact results and records]
S --> D[Withhold automatic drafts]
C[Captured app state] --> E[Guest export]
M[Manual task and consent] --> E
E --> G[Host bundle scan]
S --> G
G --> B[Publish host bundle]
B --> K[Save withheld files by handle]
Reviews (12) · Last reviewed commit: "Merge remote-tracking branch 'live-5600/..." · Reviewed by Greptile |
|
The current |
# Conflicts: # src/domain/desktop/appTaskDraftNoise.test.ts
# Conflicts: # src/application/desktop/DesktopApplicationExport.ts # src/application/desktop/DesktopBuildComputers.ts # src/desktop/AgentEnvComputer.ts # src/domain/desktop/stateRoles.ts
# Conflicts: # docs/desktop-application-tasks.md # docs/desktop-build-witness.md # docs/specs/desktop-app-environments/build-witness/spec.md # src/domain/desktop/appTaskDraftNamed.ts # src/domain/desktop/appTaskDraftNoise.ts # src/domain/desktop/appTaskDraftValues.test.ts
# Conflicts: # src/domain/desktop/appTaskDraftNamed.ts # src/domain/desktop/appTaskDraftNoise.ts
# Conflicts: # src/application/desktop/DesktopApplicationExport.ts
# Conflicts: # src/application/Setup.ts # src/composition/capabilityServices.ts # src/doctorRuntime.ts
# Conflicts: # .agents/skills/reverse-engineer-anything/references/desktop-build.md # docs/desktop-application-capture.md # docs/desktop-application-export.md # docs/desktop-application-state.md # docs/desktop-application-tasks.md # docs/desktop-build-computer.md # docs/desktop-build-witness.md # docs/specs/desktop-app-environments/build-witness/spec.md # docs/specs/desktop-app-environments/build-witness/verification.md # src/application/desktop/DesktopApplicationCapture.ts # src/application/desktop/DesktopApplicationExport.test.ts # src/application/desktop/DesktopApplicationExport.ts # src/application/desktop/DesktopBuildBundle.ts # src/application/desktop/DesktopBuildCapture.ts # src/application/desktop/DesktopBuildCaptureFailure.ts # src/application/desktop/DesktopBuildComputers.ts # src/application/desktop/DesktopBuildExport.ts # src/application/desktop/DesktopBuildOutputRead.test.ts # src/application/desktop/DesktopBuildSummary.ts # src/application/desktop/DesktopBuildWitness.test.ts # src/application/desktop/DesktopBuildWitness.ts # src/application/desktop/DesktopBuildWitnessRecord.ts # src/application/desktop/DesktopExportFiles.ts # src/application/desktop/DesktopExportLaunch.ts # src/application/desktop/DesktopGzipDocument.test.ts # src/application/desktop/DesktopTaskDraft.ts # src/application/desktop/DesktopTaskDraftNotes.test.ts # src/application/desktop/DesktopTaskExport.test.ts # src/application/desktop/DesktopTaskExport.ts # src/composition/capabilityServices.ts # src/contracts/desktopBuildToolContracts.ts # src/desktop/DesktopApplicationSession.test.ts # src/domain/desktop/appExport.test.ts # src/domain/desktop/appExport.ts # src/domain/desktop/appExportPython.ts # src/domain/desktop/appExportUnowned.test.ts # src/domain/desktop/appExportUnowned.ts # src/domain/desktop/appTaskChecks.fixture.ts # src/domain/desktop/appTaskChecks.ts # src/domain/desktop/appTaskDraft.fixture.ts # src/domain/desktop/appTaskDraft.ts # src/domain/desktop/appTaskDraftAdded.test.ts # src/domain/desktop/appTaskDraftAdded.ts # src/domain/desktop/appTaskDraftFileNotes.test.ts # src/domain/desktop/appTaskDraftFileNotes.ts # src/domain/desktop/appTaskDraftGuards.test.ts # src/domain/desktop/appTaskDraftGuards.ts # src/domain/desktop/appTaskDraftLineGuards.ts # src/domain/desktop/appTaskDraftNamed.ts # src/domain/desktop/appTaskDraftNoise.test.ts # src/domain/desktop/appTaskDraftNoise.ts # src/domain/desktop/appTaskDraftNotes.ts # src/domain/desktop/appTaskDraftPositional.test.ts # src/domain/desktop/appTaskDraftScalars.ts # src/domain/desktop/appTaskDraftText.ts # src/domain/desktop/appTaskDraftTextAdded.test.ts # src/domain/desktop/appTaskDraftValues.test.ts # src/domain/desktop/appTaskDraftValues.ts # src/domain/desktop/appTaskPython.ts # src/domain/desktop/attributeRank.ts # src/domain/desktop/desktopCapture.test.ts # src/domain/desktop/desktopCapture.ts # src/domain/desktop/positionalKeys.ts # src/domain/desktop/runtimeFiles.ts # src/domain/desktop/seedDocument.test.ts # src/domain/desktop/seedScrub.ts # src/domain/desktop/selectorCandidates.ts # src/domain/desktop/stateChanges.ts # src/domain/desktop/stateFormats.ts # src/domain/desktop/stateRoles.test.ts # src/domain/desktop/stateRoles.ts # src/domain/desktop/viewPointer.test.ts # src/domain/desktop/viewPointer.ts # tests/boundary/mcp/buildCaptureDraftMcp.test.ts # tests/boundary/mcp/buildCaptureRetryMcp.test.ts # tests/boundary/mcp/buildComputerMcp.test.ts # tests/boundary/providers/desktopExportPython.test.ts # tests/fixtures/buildCaptureFakes.ts # tests/fixtures/buildComputerMcp.ts # tests/fixtures/fakeBuildComputerRea.ts
# Conflicts: # .agents/skills/reverse-engineer-anything/references/desktop-build.md # docs/desktop-application-export.md # docs/desktop-application-tasks.md # docs/desktop-build-computer.md # docs/specs/desktop-app-environments/README.md # src/application/DesktopBuildDoctor.test.ts # src/application/Setup.desktopBuild.test.ts # src/application/Setup.recovery.test.ts # src/application/Setup.ts # src/application/desktop/DesktopApplicationExport.ts # src/application/desktop/DesktopBuildCapture.ts # src/application/desktop/DesktopBuildComputers.ts # src/application/desktop/DesktopBuildExport.ts # src/application/desktop/DesktopBuildOutputRead.test.ts # src/application/desktop/DesktopBuildWitness.test.ts # src/application/desktop/DesktopBuildWitness.ts # src/application/desktop/DesktopExportFiles.ts # src/application/desktop/DesktopExportInstall.ts # src/application/desktop/DesktopTaskDraft.ts # src/application/desktop/DesktopTaskExport.test.ts # src/application/desktop/DesktopTaskExport.ts # src/cli/desktopCaptureCommands.ts # src/contracts/desktopBuildToolContracts.ts # src/desktop/BuildComputerEnvironment.ts # src/desktop/DesktopBuildDoctorFacts.test.ts # src/desktop/DesktopBuildSetupHost.test.ts # src/domain/desktop/appBuild.test.ts # src/domain/desktop/appBuild.ts # src/domain/desktop/appExport.ts # src/domain/desktop/appExportInstall.ts # src/domain/desktop/appExportPython.ts # src/domain/desktop/appTask.ts # src/domain/desktop/appTaskChecks.fixture.ts # src/domain/desktop/appTaskChecks.test.ts # src/domain/desktop/appTaskChecks.ts # src/domain/desktop/appTaskDraft.fixture.ts # src/domain/desktop/appTaskDraftLineGuards.test.ts # src/domain/desktop/appTaskDraftLineGuards.ts # src/domain/desktop/appTaskDraftModel.test.ts # src/domain/desktop/appTaskDraftValues.ts # src/domain/desktop/appTaskPython.ts # src/domain/desktop/appTaskPythonPointer.ts # tests/boundary/mcp/buildCaptureRetryMcp.test.ts # tests/fixtures/buildCaptureFakes.ts # tests/fixtures/buildComputerMcp.ts
Desktop builds can use explicitly supplied secret handles and withhold caller-selected sign-in state from exported bundles. REA types a handle's value without forwarding it in tool results, checks bundle files for known handle values, and supports consented seeding and receiver-supplied settings. Values are not classified as secret from their names or token-shaped text.
After this server uses or keeps a declared secret, automatic task drafting is withheld because the guest may shorten values before the host can redact them. The capture remains available for a manually written task and export. The guard covers cached results and concurrent shared-secret changes. Check descriptions redact complete known values before shortening. Temporary secret cleanup remains owned and retryable; failures after publication retain the published handle.
Screenshots, derived values and unknown app-generated secrets are outside the known-value guarantee. Earlier real-provider observations and pattern-scanning measurements in the discussion describe previous revisions and do not validate this revised behavior.
Validation and integration
Temporary secret-file cleanup remains owned and retryable, with published_handle retained after publication failures. Arbitrary token-shape and key-name classification was removed. After declared-secret use/retention, automatic drafts are withheld at dispatch and publication, including cached results and a concurrent shared-secret change; capture/manual task/export remain available. Check descriptions redact complete known values before truncation. The focused concurrency ordering uses a controlled output gate and real shared secret owner; it does not qualify real GUI/provider behavior. Screenshots, derived values and unknown app-generated secrets remain outside the known-value guarantee. Additional checks passed:
npm run docs:check.At head
b39cf5463b, the affected tests below completed with 161 passed (161);npm run check:fastandgit diff --checkpassed. This includes the updated parent stack and main through25d3c7237f. Checks use source/domain and controlled boundary fixtures; no real desktop provider qualification was performed. Current-head CI and review remain required before auto-merge.Maintainer follow-up
Temporary secret-file cleanup remains owned and retryable, with published_handle retained after publication failures. Arbitrary token-shape and key-name classification was removed. After declared-secret use/retention, automatic drafts are withheld at dispatch and publication, including cached results and a concurrent shared-secret change; capture/manual task/export remain available. Check descriptions redact complete known values before truncation. The focused concurrency ordering uses a controlled output gate and real shared secret owner; it does not qualify real GUI/provider behavior. Screenshots, derived values and unknown app-generated secrets remain outside the known-value guarantee. Receiver-supplied settings cannot override host build-control variables, and generated withheld-file commands quote shell paths. The credential-pattern performance finding is obsolete because that heuristic was removed. Unknown pre-existing dconf secrets remain outside the explicit-known-value guarantee; shape-based classification would conflict with the repository secret policy, so the title/body and product limitations state this boundary. Known declared values also cover form-encoded spellings at the shared scan/redaction owner. Additional checks passed:
npm run docs:check.At head
b31f699d08, the affected tests below completed with 225 passed (225);npm run check:fast,npm run format:checkandgit diff --checkpassed. This includes the updated parent stack and main through25d3c7237f. Checks use source/domain and controlled boundary fixtures; no real desktop provider qualification was performed. Current-head CI and review remain required before auto-merge.Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.