Skip to content

feat(system): directory/process primitives (chdir, cwd, mkdtemp, remove-all)#129

Merged
jig merged 1 commit into
developfrom
feat/system-dir-primitives
Jul 23, 2026
Merged

feat(system): directory/process primitives (chdir, cwd, mkdtemp, remove-all)#129
jig merged 1 commit into
developfrom
feat/system-dir-primitives

Conversation

@jig

@jig jig commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Adds four primitives to the system library so lisp code can drive filesystem/process state — the immediate need being an in-process integration test that runs the staging→custodian flow against a temporary git repo instead of the real one.

Builtin Behaviour
(chdir path) changes the process-global working directory (os.Chdir); nil on success
(cwd) the working directory as an absolute path string
(mkdtemp & [prefix]) a fresh, uniquely-named temp directory (os.MkdirTemp), returns its path
(remove-all path) recursive delete (os.RemoveAll); no error if the path is absent

Placed in system (the host-OS library): chdir/cwd are process-global state like the existing getenv/setenv, and mkdtemp/remove-all are OS operations.

Verified end to end: mkdtemp + git-init + chdir + state-save (which creates the first commit on an unborn branch) + state-load, all without --integrity, then cleanup with chdir back + remove-all.

Notes from the spec review

  • The Go func is remove_all (snake_case) so the derived lisp name is remove-allremoveAll would have become removeall (the name derivation is lowercase + _-, no camelCase split).
  • The chdir Go test restores cwd (its cleanup is registered after t.TempDir(), so it runs first) to avoid polluting other tests in the package.

Test plan

  • lib/system/system_test.go: chdir+cwd round-trip and failure-leaves-cwd, mkdtemp uniqueness/prefix/type-error, remove-all recursive + absent-path.
  • docs_test.go extended to cover the new builtins; LANGUAGE.md regenerated. Full suite green.

🤖 Generated with Claude Code

…ve-all)

Adds to the system library:
- (chdir path)      -> nil; os.Chdir, process-global working directory.
- (cwd)             -> the working directory as an absolute path.
- (mkdtemp & [pfx]) -> a fresh unique temp directory (os.MkdirTemp).
- (remove-all path) -> nil; os.RemoveAll, recursive, no error if absent.

These let in-process tests drive state-save/state-load against a
temporary git repo (mkdtemp + git-init + chdir) instead of the real one,
verified end to end: state-save creates the first commit on an unborn
branch and state-load reads it back, both without --integrity.

The Go func is remove_all (snake_case) so the lisp name is remove-all;
the chdir test restores cwd (registered after t.TempDir so it runs
first) to avoid polluting other tests in the package.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jig
jig merged commit 10dd4f7 into develop Jul 23, 2026
14 checks passed
@jig
jig deleted the feat/system-dir-primitives branch July 23, 2026 13:46
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