Skip to content

feat(desktop): isolate declared secrets during app builds - #9225

Merged
morluto merged 749 commits into
morluto:mainfrom
earakely-scale:feat/desktop-build-secrets
Nov 9, 2026
Merged

morluto merged 749 commits into
morluto:mainfrom
earakely-scale:feat/desktop-build-secrets

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

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:fast and git diff --check passed. This includes the updated parent stack and main through 25d3c7237f. 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.

node node_modules/vitest/vitest.mjs run src/application/desktop/DesktopBuildSecrets.test.ts src/application/desktop/DesktopExportWithheld.test.ts src/domain/desktop/buildSecrets.test.ts src/domain/desktop/appWithheld.test.ts src/domain/desktop/appTaskChecks.test.ts tests/boundary/mcp/buildSecretsMcp.test.ts tests/boundary/mcp/buildWithheldMcp.test.ts tests/boundary/mcp/buildCaptureMcp.test.ts src/application/desktop/DesktopTaskDraftNotes.test.ts src/domain/desktop/stateRoles.test.ts src/desktop/BuildSecretFiles.cleanup.test.ts src/desktop/BuildSecretFiles.concurrent.test.ts src/desktop/BuildSecretFiles.test.ts

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:check and git diff --check passed. This includes the updated parent stack and main through 25d3c7237f. 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.

node node_modules/vitest/vitest.mjs run src/application/desktop/DesktopBuildSecrets.test.ts src/application/desktop/DesktopExportWithheld.test.ts src/domain/desktop/buildSecrets.test.ts src/domain/desktop/appWithheld.test.ts src/domain/desktop/appTaskChecks.test.ts tests/boundary/mcp/buildSecretsMcp.test.ts tests/boundary/mcp/buildWithheldMcp.test.ts tests/boundary/mcp/buildCaptureMcp.test.ts src/domain/desktop/appBuild.test.ts src/application/desktop/DesktopTaskExport.test.ts src/desktop/DesktopBuildDoctorFacts.test.ts src/application/DesktopBuildDoctor.test.ts src/application/desktop/DesktopTaskDraftNotes.test.ts src/domain/desktop/stateRoles.test.ts src/desktop/BuildSecretFiles.cleanup.test.ts src/desktop/BuildSecretFiles.concurrent.test.ts src/desktop/BuildSecretFiles.test.ts

Author readiness

Human owner: @earakely-scale

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T02:42:36.608983Z
We couldn’t complete this review. Comment @codex review to try again.
92085f6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 1/5 Tier: plus

[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

  1. P1 Security Escaped Unicode passwords ship ▶
  2. P1 Security Unread handles bypass secret checks ▶
  3. P2 Failures hide saved outputs ▶
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.

Summary

The PR adds declared secret handles and caller-selected withholding to desktop builds.

  • Desktop builds use declared secret handles without returning their values.
  • Exports can leave selected sign-in files out for the receiving computer.
  • Automatic task drafts stop after a server uses a declared secret.
  • Desktop captures accept named state paths and wait for app files to settle.
  • Task drafts show changed values, suggested checks, and notes about limits.
  • Setup and doctor commands prepare and diagnose desktop build computers.

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]
Loading

Reviews (12) · Last reviewed commit: "Merge remote-tracking branch 'live-5600/..." · Reviewed by Greptile

Comment thread src/server/registerDesktopBuildTools.ts Resolved
Comment thread src/domain/desktop/derPrivateKeys.ts Resolved
Comment thread src/domain/desktop/derPrivateKeys.ts Resolved
Comment thread src/desktop/BuildSecretFiles.ts Resolved
@morluto

morluto commented Nov 7, 2026

Copy link
Copy Markdown
Owner

The current credentialPatterns.ts classifies and redacts arbitrary result strings and JSON member names solely by token-shaped text, and the export can reject files on the same basis. This conflicts with AGENTS.md: preserve caller-selected output and do not infer secrecy from names or text patterns. A token-shaped example or ordinary JWT-shaped fixture can therefore be changed or rejected without the caller marking it sensitive. The earlier #8874 capture scope does not establish authority for this separate behavior. Please resolve the contract and scope with a maintainer before integration; explicitly supplied secret handles and transport credentials can be handled according to their declared provenance. The outstanding cleanup and partial-result review threads also remain open.

# 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
@morluto
morluto merged commit 387bcb7 into morluto:main Nov 9, 2026
4 checks passed
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants