Reserve the _SAGE_* env namespace as cloud-managed and read-only#261
Open
cvince wants to merge 1 commit into
Open
Reserve the _SAGE_* env namespace as cloud-managed and read-only#261cvince wants to merge 1 commit into
cvince wants to merge 1 commit into
Conversation
Variables prefixed `_SAGE_` are managed by a Capy cloud runtime, and the cloud copy is authoritative. The CLI now treats the whole namespace as read-only locally, enforced through one shared predicate (`isReservedNamespace`) so every surface behaves the same way: - `capy run` never injects these into the spawned child process, nor into the Next.js build-time env module — they are the runtime's own tooling, not the application's secrets. - sync never reconciles them: no push, pull, conflict, or local-delete propagation. The cloud value always wins, so a stale local copy can never overwrite it or surface a spurious conflict. - `capy edit` never lists them, so they cannot be edited locally. Tests: unit coverage for the sync exclusion (no reserved var ever lands in any reconciliation bucket, and a previously-synced reserved var is not treated as a local deletion), plus end-to-end coverage for the `capy run` exclusion in both local and deployed modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Introduces a reserved environment-variable namespace: any variable whose name begins with
_SAGE_is managed by a Capy cloud runtime, and the cloud copy is authoritative. The CLI now treats the entire namespace as read-only on the local machine.The rule lives in one place —
isReservedNamespace()insrc/core/reservedNamespace.ts— and every surface enforces it the same way:capy run.capy/next-env.jsbuild-time module. They are the runtime's own tooling, not the application's secrets.capysynccapy editWhy
These variables are written and owned by a cloud-side runtime. Letting the local CLI push, conflict-resolve, or hand-edit them would let a stale workstation overwrite authoritative cloud state. Excluding them from
capy runinjection also keeps that tooling out of application processes that have no business seeing it.Tests
tests/sync/syncEngine.test.ts): no reserved var ever lands in any reconciliation bucket (push/pull/conflict/unchanged/delete), and a previously-synced reserved var is not treated as a local deletion.tests/commands/runCommand.test.ts): thecapy runexclusion in both local-.envand deployed (SECRETS_BLOB) modes — app vars pass through, reserved vars do not, andnext-env.jsomits them.Full CLI suite green (
bash tests/run-tests.sh).