Repository navigation
fix(storage): verify run write roots like reads; make Flutter init the default - #91
Merged
Merged
Conversation
…e default Run storage writes now go through the same lstat/realpath trust boundary the run catalog applies on read (#54). `ensureVerifiedRunsRoot` creates each directory between the trusted ancestor (project dir, Pickforge home, or custom base) and the runs root one level at a time with a plain mkdir and verifies it is a real directory resolving exactly where the ancestor says it should. A committed `.picklab` symlink, a symlinked `runs`, a symlinked `projects/<id>`, a dangling link, or a regular file in the way raises `RunStorageAccessError` before anything is created. Run handles carry the directory identity and re-verify it before every manifest write; evidence runs adopt and finalize through the same bound handles. Nothing on disk is migrated, replaced, or deleted. Remove the `--mobile-integration-alpha` flag and its prerelease-only default: `pickforge init` always plans the Flutter pack, stable and prerelease alike, and the receipt remediation names plain `pickforge init`. Legacy `PICKLAB_*` compatibility is untouched. Refactor `beginEvidenceRun`, `finalizeActiveEvidenceRun`, and `validate_receipt` into named steps to clear the complexity gate. Closes #54 Refs #89
Re-checking a pathname before writing to it cannot stop an ancestor from being swapped in between, so manifests, journals, pointers, and screenshots could still be redirected out of the runs root after verification passed. Every sensitive run-storage write now goes through a directory descriptor: the directory is opened once with `O_DIRECTORY|O_NOFOLLOW`, verified through that descriptor (its real path is read back from `/proc/self/fd/<fd>`), and the writes of the operation are issued through the same descriptor. The runs root itself is built descriptor by descriptor from the trusted ancestor, so a symlinked `.picklab`, `runs`, or project-id component is refused rather than followed, and no lookup re-traverses an ancestor that could have changed. Screenshots and other producer-written artifacts are captured into a process-private staging directory while the run directory's descriptor is held, then published through it, since an external tool cannot be handed a descriptor. Run adoption stays internal: `openRun` is no longer exported, and the one adoption helper requires a single-component run id naming a real directory directly under the verified root plus a manifest that describes that run, so a traversing id like `../../../outside` is refused instead of adopted. The mechanism is Linux-only, like the lab; elsewhere run-storage writes fail closed instead of falling back to redirectable pathname writes. Reads and retention pruning keep the existing lstat/realpath boundary, and the docs now say so instead of claiming more. Refs #54
56 of 58 tasks
This was referenced Sep 5, 2026
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
Phase 1 of #89 (storage/product normalization): fixes #54 and removes the
mobileIntegrationAlphaflag so Flutter integration is the normalpickforge initpath.#54: project-local writes share the read trust boundary
packages/core/src/run-root.tsholds one trust-boundary implementation for both directions. The catalog's read-sideverifiedRootnow delegates to it.ensureVerifiedRunsRootmaterializes<trusted>/…/runsone level at a time with a plain (non-recursive)mkdir, thenlstat+realpatheach level against the trusted ancestor's real path. Trusted ancestors: the project directory (project-local), the Pickforge home (home), the custom base (custom). A symlinked.picklab,.picklab/runs,projects/<id>, a dangling link, a regular file in the way, or a missing project directory raisesRunStorageAccessErrorbefore anything is created.createRunbinds the run directory identity (dev/ino + real path) and re-verifies it before every manifest write;openRundoes the same for adopted runs.beginEvidenceRunandfinalizeActiveEvidenceRunuse the bound handles.docs/releases/UNRELEASED.md(reset to an alpha.2 draft since alpha.1 is published).Flag removal
--mobile-integration-alphaandMOBILE_INTEGRATION_ALPHA_DEFAULTremoved from the Rust CLI;InitRequest::newdefaults toIntegrationPack::flutter().IntegrationPack::base()stays as the receipt-only pack for tests.PICKLAB_*compatibility untouched.Complexity gate
beginEvidenceRun(complexity 29, depth 6, 165 lines),finalizeActiveEvidenceRun(complexity 19) andvalidate_receipt(complexity 16, bool_ops 5) were touched, so they were split into named steps;complexity-gate check --changedis clean and the legacyeslint-disablemarkers on those two functions are gone.Test evidence
packages/core/test/run-root.test.ts: 16 adversarial cases (committed.picklabsymlink outside/inside the project, dangling link, regular file, missing project, symlinked project path accepted, root swapped for a symlink between verification andmkdir, run dir swapped for a symlink or replaced before a manifest write, adopted handle binding, evidence run routing, homeprojects/<id>symlink, symlinked home accepted, customrunssymlink, custom base creation). 11 of them fail against the previousrun.ts; all pass now.bun run typecheck,bun run lint: pass.bun run test: 94 files, 1186 passed, 4 skipped.bun run test:coverage: thresholds pass (82.69% lines overall).bun run build: pass.cargo fmt --check,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo test --workspace --locked: pass (86 tests).complexity-gate check --changed: pass.Limitations
mkdir, so a swap between verifying one level and creating the next is detected after the fact (identity/realpath re-check) rather than prevented. No manifest, journal, or artifact is written through a redirected path; an empty stray directory can remain and is reported, not removed.resolveActivePointer/clearActivePointerstill read and unlink the pointer file via the unverified resolver path.wxcreate, atomic rename, andunlinkdo not follow a final-component symlink, so they cannot be redirected, but their reads are not identity-bound. Out of scope for Verify write-path symlinks before creating run directories #54.PICKFORGE_LIVE_FLUTTER=1) was not run.Closes #54
Refs #89