Repository navigation
feat(workspace): add opt-in workspace foundation - #36
Conversation
Signed-off-by: Simon <simon@inkie.ink>
Signed-off-by: Simon <simon@inkie.ink>
Signed-off-by: Simon <simon@inkie.ink>
Signed-off-by: Simon <simon@inkie.ink>
| if (!inside(root,path,true)) fail('PATH_ESCAPES_ROOT','declared path escapes root'); | ||
| if (seen.has(path)) fail('PATH_DUPLICATE','declared paths share a canonical target'); | ||
| seen.add(path); if ((WORKSPACE_PATH_NAMES as readonly string[]).includes(name)) paths[name as WorkspacePathName] = path; |
There was a problem hiding this comment.
🔴 Authored state overwritten by overlapping roots
loadWorkspace accepts silos inside local/brain/state/silos, allowing derived paths to equal authored memory paths. A refreshDerivedMemoryState call then overwrites authored state instead of creating a disposable copy.
Learn more
Canonical root equality checks do not establish separation between authored and disposable storage. With paths.local = "device" and paths.silos = "device/brain/state/silos", both roots are distinct and pass validation. For memory under device/brain/state/silos/finch/memory, derivedMemoryPaths returns that same memory directory for disposable leaves. The refresh consequently replaces authored state with its computed runtime view.
Example: An authored live-state file contains only {"hotReflectionCount":4}. Refreshing live state writes defaults, runtime fields, and the configured-hot receipt into that authored file rather than a separate local copy.
Recommended fix: Validate canonical separation between authored roots and the disposable localBrain subtree before accepting a workspace, and preserve that separation during identity revalidation. Add a regression for nested roots that verifies refusal before any authored bytes change.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const current = entryExists(target) ? lstatSync(target) : undefined; | ||
| if (before ? !current || !sameIdentity(before, current) : current !== undefined) | ||
| fail('WORKSPACE_IDENTITY_CHANGED', 'derived target changed before replacement'); | ||
| if (bytes === null) unlinkSync(`/proc/self/fd/${parentFd}/${leaf}`); |
There was a problem hiding this comment.
🟡 Derived deletion leaves dangling symlinks
For symlink-backed era or provenance files, atomicDerivedSync deletes the target but leaves a dangling link. Subsequent refreshDerivedMemoryState operations reject that link with PATH_DANGLING, blocking refresh and rendering.
Learn more
Final-file symlinks to confined regular files are accepted for derived operations. Deletion uses the canonical target's parent and leaf, so it removes the target without removing the original symlink. canonicalLoose then rejects the remaining entry as dangling. Refresh always removes existing provenance before replacing an era generation, so a valid symlink-backed receipt can make the operation invalidate its own future path checks.
Example: A derived provenance entry points to a valid JSON file under local/brain/cache. After authored era input changes, refresh deletes that cache file but leaves the provenance symlink. Publishing the replacement receipt fails with PATH_DANGLING, and later memory reads fail on the same entry.
Recommended fix: Give derived deletion explicit final-symlink semantics that leave the requested entry absent, not dangling. Retain and validate the requested entry's parent and identity before unlinking it. Add refresh regressions for symlink-backed provenance and deletion of symlink-backed era files, including successful subsequent reads.
Was this helpful? React with 👍 or 👎 to provide feedback.
| # Workspace foundation | ||
|
|
||
| Issue: #19 |
There was a problem hiding this comment.
🟡 Workspace handover outside required SPEC layout
The new handover uses a flat file instead of the per-issue folder required by the SPEC rules.
Learn more
The repository requires non-trivial changes to keep their SPEC in an issue-and-branch-named directory, with the document named SPEC.md. The current flat document does not follow that layout.
Example: A contributor looking for .specs/19-workspace-foundation/SPEC.md cannot find the workspace handover there.
Recommended fix: Move the document into the required per-issue directory and update references to its previous location.
Was this helpful? React with 👍 or 👎 to provide feedback.
Adds an opt-in workspace foundation with versioned roots, confined paths, authored and derived memory separation, validated provenance, and read-only context helpers. The build produces standalone workspace bundles; runtime integration follows separately. Existing legacy behaviour and public fixes are preserved.
Era level and coverage now follow the selected validated generation, including observer-first recovery after missing metadata or authored changes. Read-only access preserves persisted files and counters.
Validation: 550 tests passed, one platform skip across 43 files; build and authoritative typecheck passed. Independent source review and committed verification passed, with 184 additional API assertions and meaningful parent/removal controls. The corrective CodeRabbit review completed with zero findings. Privacy, licence and boundary checks passed.
Linux evidence is qualified by the documented filesystem and serial-refresh limits. Native macOS and Docker acceptance are pending CI; synthetic platform checks do not replace them. No migration or runtime cutover is included.
Refs #19.