Skip to content

test(write): set umask to 0o022 for deterministic file permissions#1

Open
HaleTom wants to merge 5 commits into
devfrom
write-test-umask
Open

test(write): set umask to 0o022 for deterministic file permissions#1
HaleTom wants to merge 5 commits into
devfrom
write-test-umask

Conversation

@HaleTom
Copy link
Copy Markdown
Owner

@HaleTom HaleTom commented Apr 5, 2026

Issue for this PR

Closes anomalyco#18987

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The write tool test sets file permissions when writing sensitive data fails on systems with a non-default umask (e.g. 0027). The test hardcoded 0o644 as the expected permission, but Filesystem.write() respects the system umask when no explicit mode is set.

Fixed by setting process.umask(0o022) before the test and restoring it in a finally block, ensuring deterministic permissions regardless of the host environment.

How did you verify your code works?

  • Ran bun test test/tool/write.test.ts — all 13 tests pass
  • Ran bun typecheck — no errors

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI review requested due to automatic review settings April 5, 2026 07:12
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Apr 5, 2026

Review changes with  SemanticDiff

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bumps the repo to v1.3.15 and includes multiple functional changes across tests, server/API, SDK generation, and the CLI TUI—most notably making a tool.write permission test deterministic under non-default umasks and adding experimental “Console org” switching support end-to-end.

Changes:

  • Make tool.write permission assertions deterministic by setting/restoring process.umask(0o022) during the sensitive write test.
  • Add experimental Console endpoints (/experimental/console, /experimental/console/orgs, /experimental/console/switch) and wire them through OpenAPI + generated JS SDK + TUI org switching UI.
  • Migrate ReadTool to an Effect-based tool definition and refactor its test suite accordingly; adjust session token accounting to separate reasoning tokens from output.

Reviewed changes

Copilot reviewed 46 out of 47 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
sdks/vscode/package.json Bump VS Code extension version to 1.3.15.
packages/web/src/content/docs/zen.mdx Remove MiMo “Free” model references from Zen docs/pricing.
packages/web/package.json Bump web package version to 1.3.15.
packages/util/package.json Bump util package version to 1.3.15.
packages/ui/package.json Bump UI package version to 1.3.15.
packages/slack/package.json Bump Slack package version to 1.3.15.
packages/sdk/openapi.json Add experimental Console endpoints to OpenAPI spec.
packages/sdk/js/src/v2/gen/types.gen.ts Add generated types for experimental Console endpoints.
packages/sdk/js/src/v2/gen/sdk.gen.ts Add generated client methods for experimental Console endpoints; reorganize Tool/Console clients.
packages/sdk/js/package.json Bump SDK package version to 1.3.15.
packages/plugin/package.json Bump plugin package version to 1.3.15.
packages/opencode/test/tool/write.test.ts Set/restore umask to stabilize permission assertions.
packages/opencode/test/tool/read.test.ts Refactor ReadTool tests to Effect-based harness and instance providers.
packages/opencode/test/session/compaction.test.ts Expand usage tests to validate reasoning vs output token separation and cost accounting.
packages/opencode/test/config/config.test.ts Update Account service mock to include activeOrg() and add active-org fixture data.
packages/opencode/src/tool/registry.ts Extend ToolRegistry layer requirements/provisioning to include services needed by effectified tools.
packages/opencode/src/tool/read.ts Convert ReadTool to Tool.defineEffect, using AppFileSystem/LSP/FileTime/Instruction services.
packages/opencode/src/tool/external-directory.ts Add Effect wrapper assertExternalDirectoryEffect and migrate path normalization helpers to AppFileSystem.
packages/opencode/src/session/index.ts Change token accounting to subtract reasoning tokens from output token count.
packages/opencode/src/server/routes/experimental.ts Add experimental Console routes for metadata/org listing/org switching.
packages/opencode/src/npm/index.ts Set Arborist ignoreScripts: true for dependency operations.
packages/opencode/src/filesystem/index.ts Improve Windows path normalization and add normalizePathPattern.
packages/opencode/src/config/console-state.ts Introduce ConsoleState schema + empty default state.
packages/opencode/src/config/config.ts Track consoleState in Config state and expose getConsoleState().
packages/opencode/src/cli/cmd/tui/util/provider-origin.ts Add helpers/icons to label Console-managed providers in the UI.
packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx Add categoryView to render richer category headers.
packages/opencode/src/cli/cmd/tui/context/sync.tsx Fetch and store console state from experimental console endpoint during sync.
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Show active Console org label in the prompt and trigger org switch command when applicable.
packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx Mark Console-managed providers and prevent selecting them for local auth setup.
packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx Display Console-managed provider label in model selection UI.
packages/opencode/src/cli/cmd/tui/component/dialog-console-org.tsx New dialog to list and switch Console orgs via experimental endpoints.
packages/opencode/src/cli/cmd/tui/app.tsx Add “Switch org” command when multiple orgs are available.
packages/opencode/src/account/index.ts Add activeOrg() helper and adjust orgsByAccount() error handling.
packages/opencode/specs/effect-migration.md Document transitional patterns for effectified tools; mark read.ts as migrated.
packages/opencode/script/build.ts Mark node-gyp as external for build.
packages/opencode/package.json Bump opencode package version to 1.3.15.
packages/function/package.json Bump function package version to 1.3.15.
packages/extensions/zed/extension.toml Bump Zed extension version and release asset URLs to 1.3.15.
packages/enterprise/package.json Bump enterprise package version to 1.3.15.
packages/desktop/package.json Bump desktop package version to 1.3.15.
packages/desktop-electron/package.json Bump desktop-electron package version to 1.3.15.
packages/console/mail/package.json Bump console-mail package version to 1.3.15.
packages/console/function/package.json Bump console-function package version to 1.3.15.
packages/console/core/package.json Bump console-core package version to 1.3.15.
packages/console/app/package.json Bump console-app package version to 1.3.15.
packages/app/package.json Bump app package version to 1.3.15.
bun.lock Update workspace package versions to 1.3.15.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode/test/tool/write.test.ts Outdated
Comment thread packages/sdk/js/src/v2/gen/sdk.gen.ts Outdated
Comment thread packages/sdk/openapi.json
Comment thread packages/opencode/src/session/index.ts Outdated
Comment thread packages/opencode/src/tool/read.ts Outdated
Comment thread packages/opencode/src/npm/index.ts Outdated
Comment thread packages/opencode/src/npm/index.ts Outdated
Comment thread packages/opencode/src/account/index.ts Outdated
Comment thread packages/opencode/src/cli/cmd/tui/component/dialog-console-org.tsx
@HaleTom HaleTom force-pushed the write-test-umask branch 3 times, most recently from 9719a21 to 3fcdc4a Compare April 9, 2026 09:25
@HaleTom HaleTom force-pushed the write-test-umask branch from 3fcdc4a to 90f7ec2 Compare April 9, 2026 14:51
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom commands are not working (can't see them)

2 participants