Repository navigation
refactor(file): name the write surface mode, user and group; floor the encryption mode - #514
Merged
Merged
Conversation
added 3 commits
August 17, 2026 19:46
WriteTrace linked latest.yaml and then appended the index entry, so any link failure discarded the index entry for a trace already durable on disk -- silently, because all nine callers warn rather than fail. That ordering is wrong on every platform. Windows is only where it fires for ordinary users, who lack both Developer Mode and SeCreateSymbolicLinkPrivilege and so cannot create a symlink at all. The regression test forces a link failure portably by occupying latest.yaml with a non-empty directory, then asserts the trace is both on disk and in the index. Advances #438; the symlink disposition and the privilege-denying Windows proof remain open.
chmod is a verb -- you pass a mode, not a chmod -- and the Dockerfile-style chown string made every caller assemble a value the callee immediately took apart with strings.Cut. Python decides it, because Python is the surface Starlark projects into: os.chmod(path, mode), os.mkdir(path, mode=...), pathlib.Path.chmod(mode), shutil.chown(path, user=..., group=...). Go is not self-consistent here -- perm when creating, mode in os.Chmod -- so there was no single convention to defer to. applyChown/parseChown become applyOwnership/resolveOwnership taking the two sides directly. os/user is aliased osuser, because the parameter now legitimately owns the name user. Touches 46 .star fixtures, the +devlore:defaults directives and the generated announce lists. No .star file ever passed chown, so that side was a pure rename. One test changed meaning rather than shape: with two parameters there is no malformed spec left to reject, so RejectsMalformedChown became RejectsUnresolvableUser -- the failure mode that remains. Also corrects a stale doc comment in default_func.go, which listed the deferred-default functions as (umask, chmod, env); the registry has had "mode" all along.
The encryption actions hardcoded 0o600, the only writes in the catalog not taking a mode. The parameter is floored on decrypt: encrypting a file IS the declaration that its contents are sensitive, so a free parameter would reopen that decision to a caller who can get it wrong -- and a world-readable secret fails silently, since the file is written and the run succeeds. enforceSecretFloor refuses any mode granting group or other access, BEFORE decrypting, so a rejected call never materializes plaintext. Encrypt is deliberately not floored: ciphertext is safe at rest by construction, and lands in a repository that stores it 0o644 regardless. Both default to 0o600, so behavior is unchanged unless asked.
There was a problem hiding this comment.
Pull request overview
This pull request refactors the file write surface to use clearer parameter names (mode, user, group), improves trace-index durability by reordering operations in WriteTrace, and updates encryption actions to accept a mode argument with a safety floor applied on decrypt.
Changes:
- Reorders
WriteTraceto append the index entry before attempting the best-effortlatest.yamllink, and adds a regression test for link-failure scenarios. - Renames file-provider write parameters from
chmod/chowntomode/user/group, updating generators, planners, and Starlark fixtures accordingly. - Adds a
modeparameter to encryption actions, enforcing a “no group/other bits” floor for decrypted plaintext.
Reviewed changes
Copilot reviewed 71 out of 71 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| star/extensions/com.noblefactor.devlore.Actions/commands/generate.star | Updates generator writes to mode= |
| pkg/op/provider/plan/provider_units_test.go | Updates planned kwargs to mode/user/group |
| pkg/op/provider/plan/provider_test.go | Updates helper planning kwargs |
| pkg/op/provider/plan/lifecycle_starlark_test.go | Updates Starlark lifecycle script kwargs |
| pkg/op/provider/plan/lifecycle_e2e_test.go | Updates Starlark lifecycle script kwargs |
| pkg/op/provider/plan/lifecycle_api_test.go | Updates public API tests to new kwargs |
| pkg/op/provider/plan/gather_api_test.go | Updates write planning to mode |
| pkg/op/provider/plan/deferred_default_test.go | Updates docs/comments around defaults |
| pkg/op/provider/file/provider.go | Refactors provider signatures to mode/user/group |
| pkg/op/provider/file/provider_unix_test.go | Updates ownership test to new signature |
| pkg/op/provider/file/provider_test.go | Updates file provider tests to new signature |
| pkg/op/provider/file/helpers.go | Refactors ownership parsing/apply helpers |
| pkg/op/provider/file/helpers_test.go | Updates ownership helper tests |
| pkg/op/provider/file/gen/provider.gen.go | Updates generated parameter lists |
| pkg/op/provider/encryption/provider.go | Adds mode params + decrypt floor helper |
| pkg/op/provider/encryption/provider_test.go | Adds/updates tests for mode floor + signatures |
| pkg/op/provider/encryption/gen/provider.gen.go | Updates generated parameter lists |
| pkg/op/provider/archive/provider.go | Updates mkdir call signature |
| pkg/op/default_func.go | Updates docs to refer to mode |
| cmd/writ/writ/migrate/register.go | Updates planning kwargs |
| cmd/writ/writ/migrate/receipt_integration_test.go | Updates planning kwargs |
| cmd/writ/writ/migrate/plan_builder.go | Updates planning kwargs |
| cmd/writ/writ/deploy/plan.go | Updates planning kwargs |
| cmd/writ/writ/adopt/plan.go | Updates planning kwargs |
| cmd/internal/cli/store.go | Reorders index append vs symlink creation |
| cmd/internal/cli/store_test.go | Adds regression test for link failure ordering |
| cmd/devlore-test/devloretest/data/test_write_text.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_write_bytes.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_write_and_read.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_type_mismatch.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_subgraph.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_precedence.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_origin_namespace.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_origin_full.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_writ_adopt_missing_required.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_walk_tree.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_walk_tree_gitignore.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_walk_tree_closure.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_wait_until.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_round_trip_writ_adopt.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_promise_type_mismatch.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_orphan_unattached.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_move.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_mkdir_and_remove_all.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_link.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_is_file.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_is_dir.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_imm_file.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_gather_projection.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_gather_projection_missing_field.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_gather_concurrency.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_gather_basic.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_gather_advanced.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_flow_fatal_template.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_flow_fatal_recovery.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_flow_degraded_template.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_file_unlink.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_file_lifecycle.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_file_glob.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_file_find.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_copy.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_compensation.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_unchosen_branch.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_predicates.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_not_exists.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_literals.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_lambdas.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_in_gather.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_choose_exists.star | Renames chmod → mode |
| cmd/devlore-test/devloretest/data/test_backup.star | Renames chmod → mode |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
39
to
41
| script := fmt.Sprintf(` | ||
| node = plan.file.mkdir(path = %q, chmod = 0o755, chown = "") | ||
| node = plan.file.mkdir(path = %q, mode = 0o755, chown = "") | ||
| graph = plan.assemble_definition([node]) |
Comment on lines
+209
to
+210
| a = plan.file.mkdir(path = %q, mode = 0o755, chown = "") | ||
| b = plan.file.mkdir(path = %q, mode = 0o755, chown = "") |
Comment on lines
+44
to
45
| // mode and chown deliberately omitted: mode carries the deferred {{ umask 0o666 }} default, chown a | ||
| // literal "". |
Comment on lines
+70
to
+76
| func TestResolveOwnership_LooksUpNamedUser(t *testing.T) { | ||
|
|
||
| // Looking up the current user by name should always succeed and return the same uid as os.Getuid. | ||
| currentUID := os.Getuid() | ||
| currentName := strconv.Itoa(currentUID) | ||
|
|
||
| gotUID, gotGID, err := parseChown(currentName) | ||
| gotUID, gotGID, err := resolveOwnership(currentName, "") |
Comment on lines
+225
to
+229
| if beyondOwner := mode.Perm() & 0o077; beyondOwner != 0 { | ||
| return fmt.Errorf( | ||
| "encryption: mode %04o would leave decrypted plaintext readable beyond its owner (offending bits %04o); "+ | ||
| "a decrypted secret must not grant group or other access", mode.Perm(), beyondOwner) | ||
| } |
David-Noble-at-work
added a commit
that referenced
this pull request
Aug 18, 2026
The burn-down describes its chown cluster as TestApplyChown_* / TestParseChown_*. PR #514 renamed those to TestApplyOwnership_* / TestResolveOwnership_*, so the wildcards match nothing. Same tests, same failures -- the windows leg held at 28 through that PR, and the only delta against develop was those two names appearing under their new ones. Recorded so the next name-for-name comparison does not read a rename as one regression and one fix. Co-authored-by: David Noble <[email protected]>
David-Noble-at-work
added a commit
that referenced
this pull request
Aug 18, 2026
Three things were stale. The exit gate still described a defect that PR #514 fixed: appendIndexEntry sat after the latest link, so any link failure discarded the index entry for a trace already on disk. The plan now records that half as met, and says which five of the six exit criteria remain. It cited step numbers where issues now exist -- step 58 is #392, step 60 is #438 -- and step 54, which is complete and has no issue, is cited by document filename instead. No step-number citation remains. And it named none of its own tracked work: phases 3.4, 4, 5 and LAST are #433, #434, #435 and #436, so a reader could not get from the plan to the issues that track it. Co-authored-by: David Noble <[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.
Summary
Three commits on the file and encryption write surface.
Closes #512
Closes #513
1. Append the run index before the
latestlinkWriteTracelinkedlatest.yamland then appended the index entry, so any link failure discarded theindex entry for a trace already durable on disk — silently, because all nine callers warn rather than
fail.
That ordering is wrong on every platform. Windows is only where it fires for ordinary users, who have
neither Developer Mode nor
SeCreateSymbolicLinkPrivilegeand so cannot create a symlink at all.The regression test forces a link failure portably — occupy
latest.yamlwith a non-empty directory, so thebest-effort
Removecannot unlink it — then asserts the trace is both on disk and in the index.This advances #438 by one of its six exit criteria and does not close it. The
latestdisposition stillneeds its ruling (and the fact that nothing reads it reframes the question), and the Windows proof must
deny the privilege rather than run where it happens to be granted.
2.
mode,user,groupchmodis a verb. The Dockerfile-stylechownstring made every caller assemble a value the calleeimmediately took apart with
strings.Cut.Python decides it, because Python is the surface Starlark projects into —
os.chmod(path, mode),os.mkdir(path, mode=…),pathlib.Path.chmod(mode),shutil.chown(path, user=…, group=…). Go is notself-consistent here (
permwhen creating,modeinos.Chmod), so there was no single stdlib conventionto defer to.
applyChown/parseChown→applyOwnership/resolveOwnership, taking the two sides directly.os/useraliasedosuser, because the parameter now legitimately owns the nameuser..starfixtures, the+devlore:defaultsdirectives, and the generated announce lists all move.No
.starfile ever passedchown, so that side was a pure rename.so
RejectsMalformedChownbecameRejectsUnresolvableUser.default_func.golisted the deferred-default functions as(umask, chmod, env); theregistry has had
"mode"all along.3. A floored
modeon the encryption actionsThey hardcoded
0o600— the only writes in the catalog not taking a mode.The parameter is floored on decrypt. Encrypting a file is the declaration that its contents are
sensitive, and
tree/builder.goalready derives0o600from the pipeline containingencryption.decrypt.A free parameter would reopen that decision to a caller who can get it wrong, and a world-readable secret
fails silently.
enforceSecretFloorrefuses group or other access before decrypting, so a rejected callnever materializes plaintext — asserted by the test.
Encrypt is deliberately not floored: ciphertext is safe at rest and lands in a repository that stores it
0o644regardless. Both default to0o600, so behavior is unchanged unless asked.Note on the codegen
AnnounceProviderpanics at init when a generated parameter list disagrees with its signature, so thegenerator could not run to fix its own output. The announce lists in the two
gen/provider.gen.gofiles werecorrected by hand to break that cycle, then regenerated — the committed files are generator output.
Verified
make checkandmake lint-allboth exit 0.