Skip to content

fix(starlark): standalone scripts behave like real CLIs - #3276

Merged
Andriy Knysh (aknysh) merged 7 commits into
osterman/starlark-literal-scriptfrom
osterman/starlark-interpreter-fixes
Oct 14, 2026
Merged

Andriy Knysh (aknysh) merged 7 commits into
osterman/starlark-literal-scriptfrom
osterman/starlark-interpreter-fixes

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

what

  • Forward the script and its arguments through ATMOS_USE_VERSION, version.use, and --profile re-execution.
  • Accept Atmos global flags before the script path, such as atmos --chdir=dir tool.star. Extensionless paths run as scripts when they have an Atmos shebang.
  • Treat a top-level None output as no output, so --help no longer prints null.
  • Parse env-bound lists like command-line values. Reject flag and argument names that differ only in case, parse integers as base 10, and fail with a hint when true or false follows a boolean flag.
  • Report user input mistakes as usage errors: exit 2, the usage line, a --help hint, and the missing argument named. Help marks required flags, choices, and env bindings. Tracebacks use relative paths.
  • Document that the .star extension is optional when a script runs by path, and how to set editor file-type hints for Vim, Emacs, GitHub Linguist, and VS Code.

why

A field test of interpreter mode found that re-execution dropped the script, parsing quirks silently produced wrong values, and user mistakes looked like Starlark crashes. Details are in docs/fixes/2026-10-04-standalone-script-cli-behavior.md.

references

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Standalone scripts now handle leading Atmos flags, --chdir, and version-pinned reruns while forwarding script arguments correctly.
    • Standalone CLI inputs support CSV-formatted string lists, base-10 integers, and environment values parsed like command-line values. Help output includes required fields, valid choices, and environment bindings.
    • Assigning None to top-level output produces no standalone output; None inside lists or dictionaries remains JSON null.
  • Bug Fixes
    • Invalid standalone CLI input now produces clearer usage errors, without a Starlark traceback.
    • Script selection distinguishes missing .star paths from other paths and directories.
  • Documentation
    • Expanded guidance for standalone CLI inputs, flags, help, errors, and output.

@atmos-pro

atmos-pro Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@github-actions github-actions Bot added the size/l Large size PR label Oct 5, 2026
@mergify mergify Bot added the stacked Stacked label Oct 5, 2026
@osterman

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: cloudposse/atmos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0520e6c-c624-4847-91ca-f7fd47fd77de
📥 Commits

Reviewing files that changed from the base of the PR and between c772881 and 4ba7332.

📒 Files selected for processing: 5
  • agent-skills/skills/atmos-starlark/references/standalone-scripts.md
  • cmd/standalone_command.go
  • cmd/standalone_command_test.go
  • pkg/script/starlark/stdlib/cli/module.go
  • pkg/script/starlark/stdlib/cli/module_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Walkthrough

Standalone script handling now separates Atmos flags from script arguments and preserves those arguments during re-execution. The CLI applies consistent input parsing and usage errors. Starlark output handling treats top-level None as no output and preserves JSON nulls inside containers.

Changes: Standalone Starlark CLI

Layer / File(s) Summary
Script detection and global-flag handling
cmd/standalone_script.go, pkg/script/file.go, cmd/standalone_prepare_test.go, pkg/script/file_test.go, cmd/standalone_script_test.go, website/docs/automation/standalone-cli-apps.mdx, website/docs/functions/automation/ctx.args.mdx, agent-skills/skills/atmos-starlark/references/standalone-scripts.md
Detection separates leading global flags from script arguments, applies early --chdir, and distinguishes script paths from inputs handled by normal command processing. Script execution records the invoked path and project root.
Re-execution argument preservation
pkg/reexec/args.go, pkg/auth/profile_fallback.go, pkg/version/reexec.go, cmd/standalone_prepare_test.go, pkg/version/reexec_script_test.go, pkg/reexec/args_test.go, agent-skills/skills/atmos-starlark/references/standalone-scripts.md
The original command line and trailing script-argument count are recorded. Version and profile re-execution remove Atmos flags before the script while retaining the script path and its arguments.
CLI parsing and input validation
pkg/script/standalone/*, cmd/standalone_command.go, cmd/standalone_command_test.go, cmd/standalone_input_test.go, pkg/script/starlark/stdlib/cli/*, website/docs/functions/automation/cli.*.mdx, website/docs/automation/standalone-cli-apps.mdx, agent-skills/skills/atmos-starlark/references/standalone-scripts.md, docs/fixes/2026-10-04-standalone-script-cli-behavior.md
Standalone inputs use decimal integer parsing and CSV list parsing for command-line and environment values. Name checks are case-insensitive. Positional and flag errors use usage errors, and help output includes declared flag details.
Starlark output and error handling
pkg/script/starlark/engine.go, pkg/script/starlark/errors.go, pkg/script/starlark/*_test.go, website/docs/functions/automation/output.mdx, website/docs/functions/automation/cli.command.mdx, website/docs/automation/standalone-cli-apps.mdx, pkg/script/README.md
Top-level None and unset output produce no output; None inside containers remains JSON null. Host usage errors retain usage presentation, while script failures retain Starlark traceback presentation.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant prepareStandaloneScript
  participant parseStandaloneCommand
  participant collectStandaloneInput
  participant StarlarkCommand
  prepareStandaloneScript->>parseStandaloneCommand: Pass the invoked script name and arguments
  parseStandaloneCommand->>collectStandaloneInput: Parse flags and collect positional values
  collectStandaloneInput->>StarlarkCommand: Return validated command input or a usage error
Loading
Merge Risk: ⚪ Minimal · up to 4ba73

This change makes standalone script behavior more consistent, with clearer usage errors and decimal integer parsing. No actionable merge-blocking risk remains in the supplied changes.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d99ac

The reviewed command-line flow preserves script arguments without treating them as host options. No introduced security issue was established. Privileged-wrapper policies and concurrent or reusable embedded invocation remain unassessed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A selected script can exercise the invoking process’s accessible filesystem, inherited environment, subprocess privileges, and configured tool resources. Newly effective leading directory and configuration selectors can change that execution context. Exposure through a privileged wrapper depends on its argument policy, which was not available; no remote or cross-tenant attack path was established.

Trust Boundaries and Controls

  • observed — Host preprocessing receives only the leading global options after successful standalone preparation. Script command inputs pass positional and flag-registry validation; parser failure or help returns before the command’s validation and run callbacks. This callback gate is not a sandbox for arbitrary script top-level code.

Resilience and Maintainability Implications

  • inferred — Invocation restoration assumes serialized, ordered use: mutex protection does not prevent out-of-order restore closures from overwriting another invocation, and failed detection after chdir restores argv but not cwd. Successful preparation installs deferred restoration. The documented production path invokes Execute once and exits after errors or terminating signals, limiting these state-lifecycle weaknesses in ordinary CLI operation; isolation for concurrent or reusable embedding is not established.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 100 functions across 25 files. (1 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: standalone Starlark scripts now behave more like standard command-line tools. It is concise and directly related to the changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 100 functions across 25 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@osterman

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

CI timing summary

Latest completed GitHub Actions runs for 4ba73323f7a9.

  • PR wall-clock time: 13h 56m 21s
  • Aggregate runner time: 10h 28m 26s
  • Included: 19 workflows, 123 jobs (including matrix jobs)

Wall-clock time spans the earliest included workflow creation through the latest completion. Aggregate runner time adds each job's execution time, so concurrent jobs are counted separately.

Workflow Elapsed Runner time Jobs
✅ Tests 1h 03m 44s 9h 09m 18s 98
✅ Benchmarks 30m 54s 29m 23s 1
✅ Website Preview Build 15m 36s 14m 46s 1
✅ CodeQL 8m 45s 15m 56s 6
✅ Version Tracker 6m 40s 5m 44s 1
✅ atmos.ci 4m 52s 3m 56s 1
✅ Dependency Review 4m 26s 3m 35s 1
✅ Pre-commit 3m 02s 2m 02s 1
✅ Link Check 2m 00s 43s 1
✅ vhs 1m 51s 23s 3
✅ TruffleHog secret scan 1m 40s 39s 1
✅ Validate Codeowners 1m 36s 20s 1
✅ Validate Agent Skills 1m 22s 19s 1
✅ Release Documentation Check 1m 16s 24s 1
✅ Verify Repository Symlinks 1m 15s 24s 1
✅ autofix.ci 1m 14s 11s 1
✅ PR Size Labeler 23s 19s 1
⏭️ Feature release 8s 0s 1
✅ Quality Gate Signal 7s 4s 1
Longest jobs (top 10)
Job Workflow Duration Conclusion
benchmark Benchmarks 29m 23s ✅ success
[race] non-acceptance test suite (shard 4/4) Tests 16m 56s ✅ success
Acceptance Tests (windows, shard 6/10) Tests 16m 41s ✅ success
Acceptance Tests (windows, shard 3/10) Tests 15m 45s ✅ success
[race] non-acceptance test suite (shard 3/4) Tests 15m 42s ✅ success
[floci] go e2e Tests 15m 17s ✅ success
website-deploy-preview Website Preview Build 14m 46s ✅ success
Acceptance Tests (windows, shard 2/10) Tests 14m 41s ✅ success
Acceptance Tests (macos, shard 3/10) Tests 14m 01s ✅ success
Acceptance Tests (windows, shard 7/10) Tests 13m 21s ✅ success

Updated automatically when a PR workflow finishes.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 5, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 6, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 6, 2026

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 10, 2026

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 11, 2026

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 12, 2026
@osterman

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@atmos-pro

atmos-pro Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@atmos-pro

atmos-pro Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.233.0-rc.0.

This branch was successfully deployed

1 active deployment
preview — 4ba73323 Deployed Oct 13, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants