Skip to content

Remove .statespace/state.json from deploy#145

Merged
antidmg merged 1 commit intomainfrom
remove-deploy-state
Mar 12, 2026
Merged

Remove .statespace/state.json from deploy#145
antidmg merged 1 commit intomainfrom
remove-deploy-state

Conversation

@antidmg
Copy link
Copy Markdown
Contributor

@antidmg antidmg commented Mar 12, 2026

Remove the hidden .statespace/state.json that the CLI wrote into project directories on every deploy.

This was a legacy artifact from when we planned incremental file uploads via checksums. In practice, the checksum cache was never used to skip individual files — it only skipped the entire deploy when nothing changed. Not worth a hidden dotfile for that.

The cached app name was also error-prone: if state.json pointed at a stale or wrong app (shared fixture, different environment), deploy would silently target the wrong app or fail with a confusing "name already taken" error — because resolve_target chose DeployMode::Create vs DeployMode::Upsert based on whether the cached name matched --name.

New behavior:

  • deploy <path> --name <name> — always upserts (creates or updates)
  • deploy <path> (no --name) — creates with a random name

Summary by CodeRabbit

  • Changes

    • Streamlined deployment workflow: apps created without a name receive auto-generated identifiers; apps with a specified name are updated directly.
    • Eliminated local state file tracking to simplify deployment operations.
  • Documentation

    • Updated CLI reference documentation to clarify deployment naming behavior and creation versus update workflows.

Remove the hidden .statespace/state.json that the CLI wrote into project
directories on every deploy. This was a legacy artifact from when we
planned to support incremental file uploads via checksums — but the
checksum cache was never actually used to skip individual files. The only
thing it did was skip the entire deploy when nothing changed, which isn't
worth a hidden dotfile.

More importantly, the cached app name was error-prone: if the state.json
pointed at a different app than the one you intended (stale state, shared
fixture, different environment), deploy would silently target the wrong
app or fail with a confusing 'name already taken' error because
resolve_target chose Create vs Upsert based on whether the cached name
matched --name.

Now the behavior is simple and explicit:
- `deploy <path> --name <name>` — always upserts (creates or updates)
- `deploy <path>` (no --name) — creates with a random name

Amp-Thread-ID: https://ampcode.com/threads/T-019ce34b-7d1d-76a8-b515-6ba697e09885
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 12, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR removes the local deploy state persistence mechanism and simplifies the deployment flow by eliminating multi-entity deployment modeling. Name resolution is now inlined; when names are omitted, random names are generated. The state module is deleted, and documentation is updated to reflect the new behavior.

Changes

Cohort / File(s) Summary
Documentation & CLI Arguments
binaries/statespace-cli/src/args.rs, docs/pages/reference/cli.md
Updated documentation for the --name/-n option to reflect new behavior: omitting the name generates a random app name, and providing --name updates an existing app. Removed references to state file-based defaults.
Deploy Command Refactoring
binaries/statespace-cli/src/commands/deploy.rs
Removed DeployMode, DeployTarget, DeployOutcome enums/structs and resolve_target function. Simplified deploy flow by inlining name handling and upsert/create logic. Removed state caching and checksum-based change detection. Updated tests to verify explicit-name upserts, random-name generation, and correct file upload handling.
State Management Removal
binaries/statespace-cli/src/main.rs, binaries/statespace-cli/src/state.rs
Deleted entire state.rs module containing DeployState struct, load/save state functions, and .gitignore generation logic. Removed mod state; declaration from main.rs. Eliminated local .statespace/state.json persistence for deployment metadata.
Gateway Updates
binaries/statespace-cli/src/gateway/applications.rs, binaries/statespace-cli/src/gateway/client.rs
Added #[allow(dead_code)] attribute to UpsertResult struct. Renamed and extended test to verify .git directory is ignored in file scanning.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides context and rationale but lacks the required Testing and Checklist sections from the template. Add the Testing section with checkboxes for cargo fmt, clippy, and test commands, plus the Checklist section for documentation updates.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing .statespace/state.json from the deploy functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-deploy-state
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@antidmg antidmg merged commit 2b97a49 into main Mar 12, 2026
5 of 6 checks passed
@antidmg antidmg deleted the remove-deploy-state branch March 12, 2026 19:36
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.

1 participant