Skip to content

fix(life/app): enforce app bootstrap shaping after hooks + fail loud on unreadable .app.md (#82 review) - #83

Merged
cryptolir merged 1 commit into
mainfrom
fix/app-bootstrap-hook-order-and-variant-failures
Jun 20, 2026
Merged

cryptolir merged 1 commit into
mainfrom
fix/app-bootstrap-hook-order-and-variant-failures

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Fixes the two findings from the Codex review of #82 (the shipped Increment A code, live on life v2026.06.20.1).

  • [P1] applyAppBootstrapVariants treated every .app.md read failure as "variant absent" → an existing-but-unusable variant (EACCES/EISDIR/ELOOP/TOCTOU/broken deploy) silently served the full AGENTS.md/SOUL.md to app sessions. Now only ENOENT/ENOTDIR (true absence) falls back silently; any other error warns loudly (a warn callback is threaded through resolveBootstrapFilesForRun).
  • [P2] App bootstrap shaping ran before applyBootstrapHookOverrides, so a bootstrap hook (e.g. the bundled bootstrap-extra-files) could re-inject excluded files or full AGENTS/SOUL into an app prompt, bypassing the privacy/slimming guarantee. Shaping now runs after hooks.

Tests: unreadable (EISDIR) → fallback + warn; absent (ENOENT) → fallback no warn; e2e regression — a hook injecting an excluded file + a variant-backed file is sanitized post-hook for an app session. tsgo + oxlint clean; Telegram/owner still byte-identical (app-gated).

🤖 Generated with Claude Code

…on unreadable .app.md

Codex review of #82 (the shipped Increment A code) found two real prod bugs:

[P1] applyAppBootstrapVariants treated EVERY .app.md read failure as 'variant
absent' and fell back to the full canonical file — so an existing-but-unusable
variant (EACCES/EISDIR/ELOOP/TOCTOU/broken deploy) silently served the full
AGENTS.md/SOUL.md to app sessions. Now only ENOENT/ENOTDIR (true absence) falls
back silently; any other error warns loudly (thread a warn callback through
resolveBootstrapFilesForRun).

[P2] App bootstrap shaping ran BEFORE applyBootstrapHookOverrides, so a bootstrap
hook (e.g. the bundled bootstrap-extra-files) could re-inject excluded files
(TOOLS/MEMORY/USER/IDENTITY/HEARTBEAT) or full AGENTS/SOUL into an app prompt,
bypassing the privacy/slimming guarantee. App shaping now runs AFTER hooks.

Tests: unreadable (EISDIR) variant → fallback + warn; absent (ENOENT) → fallback
no warn; e2e regression — a hook injecting an excluded file + a variant-backed
file is sanitized post-hook for an app session. tsgo + oxlint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cryptolir pushed a commit that referenced this pull request Jun 20, 2026
…ith #83

[P2] Phase 0 reads the NESTED cached-token field (usage.prompt_tokens_details
.cached_tokens / usage.input_tokens_details.cached_tokens), not the nonexistent
top-level usage.cached_tokens. [P2] Memo key covers all canonical bootstrap
inputs (BOOTSTRAP/AGENTS/SOUL mtimes/hashes + sessionKey + promptMode + config
version), not just .app.md variants. Memo span narrowed to load→filter only;
applyAppBootstrapVariants now runs post-hook + un-memoized (matching shipped
#83), so variant edits reflect automatically. Added an edit-canonical-file
invalidation test. Still review-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cryptolir
cryptolir merged commit ce76e5e into main Jun 20, 2026
16 of 20 checks passed
@cryptolir
cryptolir deleted the fix/app-bootstrap-hook-order-and-variant-failures branch June 20, 2026 11:58

@cryptolir cryptolir left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-merge review for Claude on cryptolir/openclaw#83 at 0e61a07.

Findings:

  • [P1] The bad-variant path still serves the full canonical bootstrap file to app sessions. The PR now warns on non-ENOENT/ENOTDIR errors, but it then falls through and pushes the original AGENTS.md / SOUL.md content into the prompt for that same turn. That preserves the privacy/slimming failure from #82 whenever the app-safe variant exists but is unusable (EACCES, EISDIR, ELOOP, broken deploy, TOCTOU). Please fail closed for those errors: drop the canonical file, return a missing/empty safe placeholder, or throw/abort the turn. Update the EISDIR test to assert that FULL AGENTS is not included, not just that a warning was emitted.

The P2 hook-order fix looks good: hooks now run before app shaping, and the e2e test covers an excluded hook-injected file plus a variant-backed canonical file.

Comment thread src/agents/workspace.ts
`falling back to full ${file.name} for this app session — fix the deploy`,
);
}
// fall through → keep the canonical file

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Warning is not enough here because the function still falls through to result.push(file) below, so the app user gets the full canonical bootstrap content on the bad-variant turn. For non-absence errors (EACCES/EISDIR/ELOOP/TOCTOU), fail closed by omitting/replacing the canonical file or aborting the turn, and make the EISDIR test assert that FULL AGENTS never enters the returned files.

cryptolir added a commit that referenced this pull request Jun 20, 2026
… full canonical) (#84)

Codex post-merge review of #83 (4537421648): the prior fix warned but still fell
through to result.push(file), so an app session still received the FULL
AGENTS.md/SOUL.md on a bad-variant turn — preserving the #82 privacy/slimming
regression. Now a non-ENOENT/ENOTDIR variant read failure DROPS the file for that
app session (fail-closed) instead of serving the canonical full file; warning
still surfaces the broken deploy. ENOENT/ENOTDIR (genuinely absent) still falls
back to canonical (correct for files with no variant). EISDIR test now asserts
FULL AGENTS never enters the returned files. Also fixes a latent tsgo error in
the #80 system-prompt.app-mode.test.ts (readonly as-const ownerNumbers).

Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Fixed in #84 (squash → main 3d30049e21), built as gateway:v2026.06.20.3 and rolled to life (healthy; rollback v2026.06.20.2). The bad-variant path now fails closed: a non-ENOENT/ENOTDIR .app.md read failure drops the file for that app session instead of falling through to the full canonical content; the warning still surfaces the broken deploy. EISDIR test now asserts FULL AGENTS never enters the returned files (+ an unrelated no-variant file still passes through). Also fixed a latent tsgo error in #80's app-mode test.

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