Skip to content

REVIEW-ONLY: Increment A code as shipped to prod (life v2026.06.20.1) — do not merge - #82

Open
cryptolir wants to merge 1 commit into
review/increment-a-basefrom
review/increment-a-code
Open

cryptolir wants to merge 1 commit into
review/increment-a-basefrom
review/increment-a-code

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

⚠️ REVIEW-ONLY — DO NOT MERGE. This PR re-surfaces, for adversarial code review, the exact diff that already merged as #80 (squash 7a071aa382) and is live in prod on the life gateway v2026.06.20.1. Base = #80's pre-merge parent (80e54c12ad); head = the merged commit. Merging this would only affect the throwaway review/increment-a-base branch, never main.

Why this PR

#80 shipped on a "finalize on test evidence" call — tsgo + oxlint + 22 unit tests + a healthy boot, but no adversarial code review. This surfaces the live code so Codex can hunt what tests don't.

What the diff does (all gated to :app: sessions → Telegram/owner byte-identical)

  • New "app" PromptMode (system-prompt.ts): drops CLI-ref/self-update/model-aliases/docs/silent-replies/heartbeats/owner-identity; keeps reply-tags/messaging/voice.
  • App-only bootstrap shaping (workspace.ts applyAppBootstrapVariants, called in bootstrap-files.ts when isAppUserSession): excludes TOOLS/MEMORY/HEARTBEAT/IDENTITY/USER; prefers lean <name>.app.md content.
  • Per-agent appSkills allowlist: types.agents.ts + types.agent-defaults.ts + zod-schema.* + resolveAppSkillsAllowlist (agent-scope.ts, defaults-fallback); limitAppSkills takes the caller-resolved allowlist.
  • Shared resolveAppPromptContext helper (app-prompt-context.ts) consumed by attempt.ts + compact.ts.

Please focus review on (what the unit tests do NOT cover)

  1. Gate correctness / no-op safety — isAppUserSession /(?:^|:)app:/ vs real keys app:<ns>:<userId>:<conv>; any way an app session is missed (→ silent no-op) or a non-app session is wrongly matched (→ behavior change).
  2. .app.md content swap — malformed/partial variant files, mtime/TOCTOU races, symlink/path issues in applyAppBootstrapVariants; failure modes (does a bad variant degrade gracefully to the full file, or throw the turn?).
  3. Privacy — dropping owner-identity / ## User Identity for app sessions: anything still leaking owner/Telegram context into an app prompt? Any excluded file whose loss changes safety behavior?
  4. Run/compaction parity — attempt.ts vs compact.ts both routing through resolveAppPromptContext; any divergence under compaction or odd session keys.
  5. Schema — appSkills on both strict schemas; any validation-rejection or merge-precedence edge case (entry.appSkills ?? defaults.appSkills).

Companion design plan for the next phase (caching) is the separate review-only PR #81.

… scoping (#80)

Reduce per-turn latency + tokens for Havaya app-user sessions while keeping
Telegram/owner prompts byte-identical (all changes flow through app-only code paths):

- New "app" PromptMode: drops CLI quick-ref / self-update / model-aliases / docs /
  silent-replies / heartbeats / owner-identity (privacy) but KEEPS Reply-Tags/
  Messaging/Voice (unlike "minimal"). Telegram/owner stay on "full".
- App-only bootstrap shaping (resolveBootstrapFilesForRun → applyAppBootstrapVariants):
  excludes boilerplate (TOOLS/MEMORY/HEARTBEAT/IDENTITY/USER) and prefers lean
  <name>.app.md variants when present (AGENTS.app.md/SOUL.app.md). Originals untouched.
- Per-agent appSkills allowlist: new field on BOTH agent-defaults and agent-entry
  schemas + resolveAppSkillsAllowlist(cfg, agentId) = entry.appSkills ??
  agents.defaults.appSkills (defaults-fallback precedent; works for life's defaults-only
  config). limitAppSkills takes the caller-resolved allowlist → never global.
- Shared resolveAppPromptContext helper consumed by BOTH attempt.ts and compact.ts so
  the run + compaction paths can't drift (app user id, "app" mode, scoped skills);
  agent id resolved up front, before skill filtering.

Implements PR #77 plan (rev4). APP_PROFILE render-slot + bootstrap memoization deferred
to the caching increment (no token/latency payoff until Venice caching lands).

Tests: app PromptMode drop/keep + full byte-identical control; resolveAppSkillsAllowlist
defaults-only + per-agent isolation; applyAppBootstrapVariants exclude/swap; limitAppSkills
allowlist. tsgo + oxlint clean.

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

@codex review — review-only re-surface of already-merged, deployed code (#80, live on life v2026.06.20.1); focus on correctness/edge cases, not merge-readiness (see PR body's 5 focus areas).

@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.

Review for Claude on cryptolir/openclaw#82 at 7a071aa.

Findings:

  • [P1] applyAppBootstrapVariants treats every .app.md read failure as “variant absent” and falls back to the full canonical bootstrap file. Missing variants may be a valid fallback, but EACCES, EISDIR, ELOOP, symlink/TOCTOU failures, or a broken deploy mean the app-safe variant exists but is unusable; silently serving full AGENTS.md / SOUL.md to app sessions can re-expand or disclose prompt context in prod with no signal. Please only fall back on true absence (ENOENT/ENOTDIR) and fail closed or warn/throw for other errors, with tests for unreadable/directory/symlink-loop variants.

Everything else I checked looks sound: the :app: gate matches the intended app key shapes, resolveAppPromptContext keeps run/compact parity, and appSkills is resolved per session agent instead of globally.

Comment thread src/agents/workspace.ts
const variantName = file.name.replace(/\.md$/i, ".app.md");
if (variantName !== file.name) {
try {
const content = await fs.readFile(path.join(resolvedDir, variantName), "utf8");

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] This catch treats every read failure as “no variant” and then falls back to the full canonical bootstrap file. That is fine for a genuinely absent .app.md, but if AGENTS.app.md / SOUL.app.md exists and is unreadable, a directory, a symlink loop, or hits a TOCTOU error, app sessions silently receive the full non-app file. Please distinguish ENOENT/ENOTDIR from other errors and fail closed or surface the problem instead of leaking/re-expanding the prod prompt.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a071aa382

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// App-user sessions only: drop boilerplate files and prefer lean `<name>.app.md` variants.
// Telegram/owner sessions skip this entirely → their assembled prompt is byte-identical.
if (isAppUserSession(sessionKey)) {
bootstrapFiles = await applyAppBootstrapVariants(bootstrapFiles, params.workspaceDir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reapply app bootstrap filtering after hooks

When an app session has the bundled bootstrap-extra-files hook enabled, applying applyAppBootstrapVariants here is not enough because applyBootstrapHookOverrides runs afterwards; that hook appends recognized files and only re-applies filterBootstrapFilesForSession, so configured extras such as IDENTITY.md, USER.md, TOOLS.md, or MEMORY.md are injected back into app prompts after this app-only exclusion. This breaks the privacy/no-op guarantee for app sessions in deployments that use bootstrap extras; enforce the app exclusions/.app.md swap on the post-hook file list as well.

Useful? React with 👍 / 👎.

@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.

Follow-up review for Claude on cryptolir/openclaw#82 at 7a071aa.

Confirming the automated Codex P2 as real:

  • [P2] App bootstrap shaping currently runs before applyBootstrapHookOverrides, and the hook-returned file list then flows straight into APP_PROFILE/build-context assembly. That means any bootstrap hook that appends canonical TOOLS.md, MEMORY.md, USER.md, IDENTITY.md, or full AGENTS.md/SOUL.md can bypass the app-only exclusions and .app.md swap. Please re-apply app bootstrap shaping, or a stricter post-hook app sanitizer, after hooks for app sessions; add a regression test with a hook that injects one excluded file and one file with an .app.md variant.

cryptolir added a commit that referenced this pull request Jun 20, 2026
…on unreadable .app.md (#83)

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

Copy link
Copy Markdown
Owner Author

Both findings fixed in #83 (squash → main ce76e5e202), built as gateway:v2026.06.20.2 and rolled to life (healthy; rollback v2026.06.20.1). [P1] only ENOENT/ENOTDIR falls back silently; other errors warn loudly. [P2] app bootstrap shaping now runs AFTER applyBootstrapHookOverrides so hooks can't re-inject excluded files. Tests: EISDIR-variant fallback+warn, ENOENT no-warn, and an e2e regression (hook injects an excluded file + a variant-backed file → sanitized post-hook). This review-only PR can be closed.

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]>

This branch has not been deployed

No deployments
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