Repository navigation
feat(core,dg): environments lite — encrypted per-environment config with dg env - #397
Merged
Merged
Conversation
Kind-8 packManifest snapshots of one environment (mixed-visibility
design §4.5, D9, D24): canonical JSON padded to 512-byte buckets,
Members under the members key (DFPK 0x01), Maintainers to the current
maintainers (DFPK 0x02). Readers count a snapshot only when its owner
is a current maintainer, check the owner-signed packHash before opening
and take the sender key from that owner only; forks fail closed.
forge-core env::{format,codec,chain,service}, forge-web lib/env, and
20 env_snapshot__* vectors from a sibling generator
(tools/private-repos-vectors/env.py) run by both harnesses.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…story Environments lite in dg (mixed-visibility design §4.5): maintainers-only writes, each change one snapshot (set with several names, import and edit included), Maintainers by default for production/prod*/staging/ release*, Members otherwise with the Members sentence. run injects the values into the child only; export -o writes 0600, adds the file to .git/info/exclude and verifies it with git check-ignore, and refuses a tracked file; without -o it prints .env text for piping. A fork fails closed naming both versions; --keep resolves it with a snapshot that supersedes every head. dg collab remove now lists the environments and current value names the removed member could read. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Members writes now report E312 (members-only content not turned on) and E311 (no key shared yet) from the lane stream; dg collab remove passes the lane's keyed flag to the removal checklist. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
docs/guides/environments.md: audiences, commands, conflicts, removal, what is public, limits. e2e scenario 39: import, run (exit code passes through), export -o (0600, info/exclude, git check-ignore, clean git status), and a non-maintainer refused. dg env help and messages follow the style guide (short imperative abouts, no semicolons or (s) plurals). A debug-build-only DASH_FORGE_TEST_ENV_ANY_WRITER lets live QA post a writer's snapshot that readers must ignore. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A conflict lists both versions in one cause line (an error has one cause); a non-maintainer is told Maintainers environments go only to maintainers; the unreadable-latest-change fix depends on the role; a Members write in a repo without members-only content offers --audience maintainers. dg env ls counts changes by people who are not maintainers now, and history carries each change's packHash. A debug-build-only DASH_FORGE_TEST_ENV_SUPERSEDES adds heads to a new snapshot, so live QA can post a writer's snapshot naming the head. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (61)
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. Comment |
Lead decision: an environment never falls back silently to older values (they may hold a rotated credential). Consensus cannot tell a removed maintainer's kind-8 snapshot from a writer's (both r 1; the maintainer document is deleted), so readers use evidence that its owner was a maintainer: they own a config or repoKey document (maintainer-only, undeletable), or a current maintainer's snapshot lists them in its new `maintainers` field. Such a snapshot joins the chain unopened; as an environment's newest it makes the environment stale: run/get/export refuse it (E609), ls says it needs saving again, and `dg env resave` shows who saved it and when, then saves the same values as the current maintainer. A writer's snapshot without evidence stays ignored. dg collab remove of a maintainer now saves again, after the rotation, every environment whose latest change they made (one snapshot each, cost in the prompt), before printing the checklist; it reads them with the removed maintainer as known former maintainer. Snapshots record the maintainers when saved (sorted; the writer must be listed). Environment conflicts get their own code (E608). Vectors: head_by_removed_maintainer, removed_maintainer_mid_chain (was removed_maintainer_skipped), former_maintainers; unauthorized_writer_ignored kept. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… with the last readable version Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # crates/forge-core/src/keyring.rs
… block Lead review of #397 (the former-maintainer evidence, E609 and dg env resave were gameable by a demoted maintainer or any writer reusing a packHash), reversed for a rule writers cannot game: - only a current maintainer's snapshot counts; no other manifest's values or links are used. Links count only between counted snapshots and strictly back in block height; order is by block height. The snapshot `maintainers` field, the former-maintainer evidence, E609 and dg env resave are gone. - writers name every counted snapshot of the environment (newest first, up to 32) in supersedes, so removing a maintainer who wrote a change in the middle of a chain splits nothing. - an ignored manifest naming an environment's head from a higher block is reported (ignoredNewer): ls, get, run and export print one warning line and keep using the counted head. - dg collab remove of a maintainer pins each environment head they wrote, shows its per-entry diff against the previous version by someone else (values hidden) with the cost, and after the rotation saves it again only if the pinned head is still there and nothing newer was counted. The checklist notes environments the remover cannot read. - export -o adds the exclude entry and checks git check-ignore before writing, refuses a path git would not ignore, and --force replaces a symlink instead of following it; .env output is quoted so sourcing it runs nothing; run refuses PATH, LD_PRELOAD, LD_LIBRARY_PATH, DYLD_*, BASH_ENV, ENV, NODE_OPTIONS without --allow-env-override; edit keeps Ctrl-C for the editor and removes its file on hangup or termination. - test hooks are compiled only into debug builds; env.py matches names with fullmatch. Vectors: writer_reuses_pack_hash, post_demotion_snapshot_ignored, self-links and same-block links in chain_cycle, and decode cases for a duplicate key, uppercase \u, raw U+2028 and astral characters, -0 and 1e3. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # forge-web/lib/rules/conformance.test.ts
…anges, conflict copy, run and export guards - Promotion: before granting maintainer, dg collab add dry-runs the resolution with the new member counted and first saves the current values of every environment their dormant snapshots would change, naming those snapshots as replaced - Removal: the dry run without the member drives the re-save, including environments in conflict where they wrote a head; --no-resave and a separate confirmation for the saves; history shows saved again for <member> - supersedes window: current heads, each author's newest, then the newest (max 32); savedFor field in the snapshot format; vectors for the window, a long run by a removed maintainer and promotion - E608 lists every head with author and time and points to dg env history; a split has its own wording; resolving needs more than one head; a no-op change saves nothing - run refuses entries shadowing a parent variable or changing program start-up without --allow-env-override; export fails closed when git can't run in a work tree, uses literal pathspecs for ls-files and refuses a case-only collision with a tracked file - editor exit restores Ctrl-C/Ctrl-\ handling; ignored-change warnings name author, time and id, and history lists ignored changes; fetch failures report E503 - web refuses removing, demoting or making a maintainer of a repo with environments - Members snapshots follow the late-content rule; removal does not count conflicted environments as unreadable Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # crates/dg/Cargo.toml
…with its shared history The re-save named only the removed maintainer's own (now ignored) snapshot and predicted heads it had named, so it started a separate history (seen live on sakura: staging read as 2 separate histories). It now also names the snapshots that still count which that version descends from. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…change Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # crates/forge-core/src/pack.rs # crates/forge-core/src/pack/manifest.rs # e2e/cli/run.sh
- forge-core: Book::manifest is public (manifest_of removed) and Book::window_over replaces dg's copy of the SnapshotRef mapping; Book::base builds its Base in one place; one chain_order key for the manifest sorts; seal drops a sort/dedup recipients() already does; chain::window partitions once with one comparator. - dg: one environments(session) constructor; fold_case shared by the env-override guard; count() for entry plurals; one history arm for readable changes; unused member parameters dropped from explain_pins, Removal::explain and finish_removal; Default for empty Removal/Promotion plans; set reuses its early maintainer check instead of repeating it before the read. - conformance harness, TS and Python: shared helpers, no unused parameters, no nested ternaries, no pass-through open_case. Vectors regenerate byte for byte. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta
added a commit
that referenced
this pull request
Oct 7, 2026
Resolve docs/errors.md and docs/guides/collaborating.md in master's new structure (#407 "What to do" entries, #404 "say who enforces a rule"): E306, E311, E312 and E313 keep this PR's content under "What to do", E311 leads with "You're a member, but no key has been shared with you yet" and points at Repair or `dg repo keys repair`. #397 is merged, so the PENDING #397 markers go; PENDING #400 and 1D notes stay. audiences.md's error entries use "What to do" and name Forge apps rather than clients. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta
added a commit
that referenced
this pull request
Oct 7, 2026
…ue shown, stored-bytes hash - addPrivateMember/removePrivateMember refuse a maintainer change in a repo with environments first, before the consent check and any paid re-anchor (private repos had no guard since #397) - values hide synchronously on pagehide/visibilitychange; showing a value hides any other - removal checklist says a member who stays a maintainer keeps access instead of asking to rotate - stored artifact loads hash a single copy's Platform chunks against packHash and stay out of the content-check ledger - environment maintainers come from maintainer documents only - no unlock prompt for outsiders Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
Environments lite (mixed-visibility DESIGN stream 1I: §4.5, D9, D23, D24, §10; security review H5/M2, product review H7/M4): per-environment configuration and secrets kept outside git, encrypted for Maintainers or Members, changed only by maintainers, injected with
dg env run.Builds on #392 (crypto) and #395 (lane), both merged; the diff against master is env only (61 files, roughly half of it vectors and tests).
forge-core
env/format: the artifact is canonical JSON{"audience","env","generatedAt","savedFor"?,"to"?,"v":1,"vars":{NAME:{"note"?,"type","value"}}}(savedFor: the removed maintainer whose values a re-save carries) padded with spaces to 512-byte buckets (max 12,288 B, so always one Platform chunk). A reader takes only the exact canonical bytes (parse, check, re-encode, compare), so Rust, TS and Python agree on duplicate keys, escapes, numbers, U+2028, astral characters and lone surrogates..envparse/render: values are bare, single-quoted or double-quoted with\,",$and backticks escaped, sosource .envnever runs anything inside a value.codec: Members = DFPK 0x01 under the members key at the write epoch; Maintainers = DFPK 0x02 to the current maintainers' highest usable ENCRYPTION keys, the writer first. Open in D24's order: the bytes must hash to the owner-signed manifest'spackHashbefore anything is decrypted, then the envelope (0x02's sender key taken from that manifest's$ownerIdonly), then the content must agree with its envelope (audience matches the version byte;tolists the owner first and has one entry per slot).chain: strict D24. Only a current maintainer's snapshot counts. Every other manifest is ignored, and neither its values nor its links are used. Links count only between counted snapshots, strictly back in$createdAtBlockHeight, and within one environment, so there are no self-links, forward links or cycles. Order is by block height.supersedeswindow (max 32): the current heads, then the newest snapshot by each other author, then the newest of the rest.chain::window/supersedesWindow, with a vector for a run of 32+ by one maintainer.chain::changed(before, after): which environments' heads change, vanish or appear between two resolutions, the dry run behind removal and promotion.ignoredNewer). It is never used and never offered to be saved.service: read every snapshot of a repo and save one (prepare = maintainer check + seal; store = one chunk + one kind-8packManifest).pack/manifest.rs:KIND_ENV_SNAPSHOT = 8,for_env_snapshot,plan_supersedesnever plans for kind 8.repo.rs:store_env_snapshot.env::MAINTAINERS_BY_DEFAULT = ["production", "prod*", "staging", "release*"]. Runners are not lane members (the lane's rule); they get environments only as Specific people in phase 2.dg
dg env ls [--env] | get | set NAME[=value]… [--secret] | unset | edit | import .env | run -- cmd | export [-o .env] | history, with--audienceand--keep <id>(resolve a fork). Only maintainers can write.lsmasks values and shows who saved the version in use and when.ls,get,runandexportprint one warning line when an ignored change names the head, with its author, time and id: "production has a newer change by at 2026-10-05 14:55 UTC (7JLyoZc2GU), who isn't a maintainer now; it was ignored. Ask a maintainer to check production's values."historylists ignored changes and marks re-savessaved again for <member>.set/editthat changes nothing (and resolves nothing) saves nothing.set: with no value it prompts (hidden) or reads one value from stdin. Several names,importandeditare one snapshot each.run: injects into the child only and passes its exit code through. Without--allow-env-overrideit refuses any entry that shadows a variable the parent already has, and always PATH, HOME, XDG_CONFIG_HOME, BASH_ENV, ENV, ZDOTDIR, SHELLOPTS, PS4, SHELL, NODE_OPTIONS, NODE_PATH, PYTHONPATH, PYTHONHOME, PERL5OPT, PERL5LIB, RUBYOPT, RUBYLIB, JAVA_TOOL_OPTIONS, JAVA_OPTIONS, JDK_JAVA_OPTIONS, RUSTC_WRAPPER and the prefixes LD, DYLD_, GIT_, npm_config_ (case-insensitive on Windows).export -o: before writing, adds/<path>to.git/info/exclude(pattern characters escaped), checksgit check-ignore(which works on a path that doesn't exist yet), and refuses a tracked file (also a letter-case-only match) or a path git would not ignore. Inside a work tree where git can't run it fails closed (E206).ls-filesruns with--literal-pathspecs(check-ignoretakes plain paths and refuses that option). It then writes 0600.--forcereplaces a symlink via a temp file and rename instead of following it. Without-oit prints.envtext for piping.edit: while the editor runs, Ctrl-C and Ctrl-\ go to the editor anddgignores them (tokio signals; no unsafe code); default handling is restored when it exits. The temporary file is removed after a hangup or termination too. The docs mention editor swap and backup copies.run/get/exportclosed with E608, listing every head (id, author, time) and pointing todg env history, without pre-filling a--keepid; heads with no shared earlier version are reported as separate histories. A fetch failure is E503, not a key error.dg collab removeprints the removal checklist: environments and current value names the member could read, plus a note on how many environments the remover can't read. For a maintainer it dry-runs the resolution without them and compares it per environment:savedFor), superseding the predicted heads; in a conflict, each head of theirs is saved again linked to the counted versions it came from, so it stays one of the versions without starting a separate history. The confirmation shows each, values hidden, with the cost;--no-resaveskips them and still names the environments that change;dg collab add --role maintainerdry-runs the resolution with the new maintainer counted. If their earlier (ignored) snapshots would change any environment, it first saves the current values again as the promoter, naming the current heads and the predicted heads (their dormant snapshots) as replaced, and lists those environments with the cost in the confirmation. Their environments nobody could use before are listed as appearing.forge-web membership guard
lib/repo/writes.ts: removing, demoting or making a maintainer of a repo that has a kind-8 manifest is refused before anything is written ("This repo has environments. Remove or demote maintainers with dg for now." / "Make maintainers with dg for now."), with one cheap newest-manifest-of-kind query.PACK_KIND.ENV_SNAPSHOT = 8. Test:lib/repo/environments-guard.test.ts.forge-web
lib/env/(codec only, no UI)encodeSnapshot/decodeSnapshot,openSnapshot(same D24 order),sealMembersSnapshot/sealMaintainersSnapshot,resolveSnapshots(strict, withignoredNewer),supersedesWindow,changedEnvironments,exposureOf,defaultAudience, the two sentences. The web UI stream builds Settings → Environments on it. It still needs a loader (kind-8 manifests, maintainers, owner keys, artifact fetch); the web refuses maintainer changes in repos with environments until it plans and saves likedg.Vectors
26
env_snapshot__*from a sibling generator,tools/private-repos-vectors/env.py(reuses gen.py's crypto; owns onlyenv_snapshot__*.json; names checked withre.fullmatch):padding,decode_refused(now with a duplicate key, uppercase\u, escaped astral, raw U+2028 and astral accepted,-0,1e3, a trailing-newline name),members,maintainers_named,sender_not_owner,pack_hash_mismatch,audience_mismatch,chain_{linear,fork,two_roots,resolved,cycle}(cycle: self-link, forward link, same-block links),unauthorized_writer_ignored,post_demotion_snapshot_ignored,writer_reuses_pack_hash,removed_maintainer_mid_chain,unreadable_head,hidden_environment,duplicate_copy,cross_environment_link_dropped,window,long_run_by_removed_maintainer,promotion_unprotected,promotion_protected,removal_checklist,default_audience;paddinganddecode_refusedcoversavedFor. Rust (env::conformance) and TS (lib/env/conformance.test.ts) reproduce every one byte for byte; both rules harnesses skip the prefix.Docs and e2e
docs/guides/environments.md(audiences, commands, the ignored-change warning, conflicts, removal, what is public, limits) for the docs stream to link.docs/errors.md: E608. e2e scenario 40 (renumbered: master took 39) (import → run → export -o → git check-ignore, non-maintainer refused).Review round (the lead's findings)
maintainersfield, E609,dg env resaveand all link-following through ignored manifests. A demoted maintainer who is still a writer could block every environment with one manifest and get maintainers to re-sign their values. Any writer could end a fork by reusing a packHash, since the unique index is per owner. None of that works now: a writer's manifest is never a link.DASH_FORGE_TEST_ENV_ANY_WRITERandDASH_FORGE_TEST_ENV_SUPERSEDESare now#[cfg(debug_assertions)]items, absent from release builds, and used by live QA only.Review round 2 (13 items, all fixed)
promotion_*. 2. Window split and removal by dry run (above), vectorlong_run_by_removed_maintainer. 3. E608 wording. 4. Resolving = more than one head; no-op saves nothing. 5. Web guard. 6.--no-resave, separate confirmation,saved again for. 7.runshadowing and start-up variables. 8.exportfail-closed, literal pathspecs, case collisions. 9. Signal handling restored after the editor. 10. Warning author/time/id; ignored changes inhistory. 11. E503 for fetch failures. 12. Members snapshots follow the late-content rule (manifest_standing). 13. Conflicted environments not counted as unreadable.Live QA found one more bug, now fixed: a removed maintainer's version in a conflict was saved again without its counted ancestors, so the environment read as separate histories. A unit test builds the book and checks the post-removal resolution for that case and the current-head case.
How tested
Gates at 31906a2 (origin/master a7d6438 merged, which includes #395 and #398; then the lead's simplification pass 5d425fe and the
collab addprompt stating the pre-save before its question, checked live inr4/90-promote-prompt-order.txt), under the cargo lock, staleness touch, no debuginfo:cargo fmt --all -- --checkok;cargo clippy --workspace --all-targets -- -D warningsok.cargo test --workspace: 1,849 passed, 0 failed.tsc --noEmitok,npm run lintok,npm run lint:copyclean,vitest run383 files / 6,219 passed. (An earlier full run had one timeout inlib/auth/key-safety.test.ts, a file this branch doesn't touch; it passes alone and in the final run.)env.py --write-vectorsandgen.py --write-vectorsreproduce the committed vectors (0 changed files);forge-contracts/schema/vectors.py --checkok.Live QA on devnet sakura (identities maint1, maint2, writer, reader, outsider; fake values only):
…/mv1-env-qa-0831,dash-forge-qa/evidence/mv1/env/README.md, transcripts 01-97):runinjects;export -ogives 0600, the exclude entry andgit check-ignore;--keepresolves it;devreadable by a reader added after it was saved;import,edit, e2e scenario 39 (PASS), and the removal checklists.…/mv1-env-qa3-1327,evidence/mv1/env/r3/README.md):ls/get/run/exportwarn while values stay at the counted head;runrefuses PATH/NODE_OPTIONS without--allow-env-override;exportrefuses a path a.gitignoreun-ignores, and--forcereplaces a symlink without touching its target;dg collab removeof maint2 shows "Their change: + NEW_FLAG, ~ STRIPE_KEY. Values are not shown." with the cost, then saves production again with maint2's values after the rotation.…/mv1-env-qa4-1454,evidence/mv1/env/r4/README.md):historylists it;--yesproduction is saved first and staysv1after the role lands;history;saved again for; this run exposed the conflict-lineage bug, fixed and rechecked on preview (a conflict that stays one history) andops(an environment only the removed maintainer had saved);--no-resave: names the environment that changes, no second prompt, the checklist ends "Not saved again: preview.", and preview returns to the earlier version;evidence/mv1/env/r2/) tested the reversed design and is historical only.Limits and notes for the lead
audience,toandvbeyond DESIGN's{env, vars, generatedAt}:torenders "Who can read this" as names after posting (DFPK 0x02 has no recipient list), andaudiencemust match the envelope.dg env grant|revoke, the kind-9 registry, CIenvironment:, Settings → Environments UI.🤖 Generated with Claude Code