Skip to content

Embedded follow-ups: driftPolicy + writer threat-model docs - #21

Merged
DanMat merged 1 commit into
mainfrom
feat/embedded-followups
Jul 26, 2026
Merged

Embedded follow-ups: driftPolicy + writer threat-model docs#21
DanMat merged 1 commit into
mainfrom
feat/embedded-followups

Conversation

@DanMat

@DanMat DanMat commented Jul 26, 2026

Copy link
Copy Markdown
Owner

The two non-blocking items deferred from the 3.0 review, now that the structural refactors are in.

driftPolicy for createProjectFromDefinition

createProjectFromDefinition(definition, { driftPolicy: 'error' });

When a file the host originally added now collides with one the current Packkit generates, replay reports an error-severity diagnostic and uses the stored copy. That's the right default ('report') — a definition is a reproducibility contract. But a consumer treating any severity: 'error' as a hard failure would misread it, so 'error' makes throwing opt-in. Version drift alone (a warning) never throws — only the unreconciled add-collision does.

Writer threat model

EMBEDDING.md now says plainly what the writer does and doesn't guarantee:

  • Safe against hostile file maps and pre-existing symlinks (absolute/../null-byte paths, and any path resolving through an existing symlink — including the destination and final component — are rejected before writing).
  • Not race-proof against a concurrent process mutating the destination between the preflight and the write (a TOCTOU window). The intended use is a private temp workspace your app controls.

Better to state the boundary than imply protection we don't provide.

89 tests pass (2 new), lint clean.

🤖 Generated with Claude Code

The two non-blocking follow-ups deferred from the 3.0 review.

driftPolicy: createProjectFromDefinition(def, { driftPolicy }) — default
'report' keeps today's behavior (return the project with an error-severity
diagnostic when a stored `add` now collides with generated output);
'error' throws instead, for callers that want an unreconciled definition
to fail loudly. Version drift alone (a warning) never throws.

Threat model: EMBEDDING.md now states plainly that the writer is safe
against hostile file maps and pre-existing symlinks but is not race-proof
against a concurrent process mutating the destination (the TOCTOU window
between preflight and write), and that the intended use is a private temp
workspace — rather than implying protection we don't provide.

89 tests pass (2 new), lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DanMat
DanMat merged commit 8421432 into main Jul 26, 2026
5 checks passed
@DanMat
DanMat deleted the feat/embedded-followups branch July 26, 2026 19:15
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