Skip to content

docs(spec): NIW2-313 file-read leaks, state caching and locking in @laqi/core - #87

Closed
csdev19 wants to merge 1 commit into
mainfrom
feature/niw2-313-fix-file-read-leaks-state-caching-and-file-locking-in
Closed

csdev19 wants to merge 1 commit into
mainfrom
feature/niw2-313-fix-file-read-leaks-state-caching-and-file-locking-in

Conversation

@csdev19

@csdev19 csdev19 commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Refs NIW2-313. Spec: design/core-hardening.md. ADRs: 0020 (cross-process file lock), 0021 (mock files are never read through symlinks).

Decisions

  • The loader never follows symlinks inside the mocks area.
  • Excerpts come only from regular files, are clipped, and files over 10 MB are refused.
  • resolveSourcePath returns the real path. It denies dot-segments and node_modules.
  • Source-read errors use fixed phrases and never quote JSON.parse.
  • StateStore serves state from memory, revalidated by a stat fingerprint and written through.
  • The O_EXCL lock gets a guarded reclaim and an async wait. No new dependency.
  • Write failures surface: a 503 from the control plane, isError over MCP.
  • Project does its state read-modify-write inside the lock.
  • findKeyLine becomes a single pass over the file.

The spec also found that main does state read-modify-write outside the lock, and that the watcher ignores .laqi/, so the server does not see MCP's state writes.

Open questions

  1. Are there user layouts that symlink individual mock files?
  2. Should NIW2-315 narrow the default schemaSources.root, or is the deny list enough?
  3. Keep one 5 s lock timeout for both surfaces, or use a shorter one for the control plane?
  4. Should this ticket add a state-changed event, so the panel sees MCP's flips?
  5. Is a small 'unavailable' change in NIW2-309's control-plane-app.ts acceptable here?

Status

This PR contains only the design spec and ADR drafts. It is opened as a draft so the design is not lost. The implementation will land on this same branch after the open questions are answered. Everything is "proposed, not implemented".

Part of the 2026-10-12 audit, umbrella NIW2-302. Specs were written by Fable agents against a read-only export of main at ee34302. The ADR numbers (0014–0026) are assigned across all eight audit PRs. decisions/index.md is not edited in these PRs, to avoid eight-way conflicts; add the index rows when each PR is promoted.

🤖 Generated with Claude Code

Spec and ADR drafts for NIW2-313, from the 2026-10-12 security, quality and
scalability audit (umbrella NIW2-302). Status: proposed, not implemented.

Refs: NIW2-313

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@csdev19 csdev19 closed this Oct 12, 2026
@csdev19
csdev19 deleted the feature/niw2-313-fix-file-read-leaks-state-caching-and-file-locking-in branch October 12, 2026 17:13
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