Skip to content

feat(save-user-section): app_profile section + content guards (profile Phase 1) - #65

Merged
cryptolir merged 3 commits into
mainfrom
feat/app-profile-writer-hardening
Jun 16, 2026
Merged

cryptolir merged 3 commits into
mainfrom
feat/app-profile-writer-hardening

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Per-user-profile plan — Phase 1 (openclaw side): writer plumbing + hardening. Addresses codex review 4508313642 on the plan (#64). No user-visible change; the live life agent is unaffected until the gateway image is rolled (Phase 3).

What

  • Allowlist: add app_profile to WRITABLE_SECTIONS so the agent can maintain a per-user profile section via save_user_section.
  • Content guard (assertSectionContentWritable, pure + exported + tested):
    • Marker-injection (codex §3): reject any content containing <!-- app: — it would create duplicate markers and make the file fail closed on the section reader.
    • Hard size cap (codex §5): per-section byte cap — app_profile 2 KB, default 16 KB — enforced in the tool, not just instructed, because app_profile is injected into the agent's context every turn.
  • Wired the guard into the tool's write path (before upsertSection); updated the tool/param descriptions and docs/tools/save-user-section.md.

Not in this PR (later phases)

  • Reader allowlist (PUBLIC_SECTIONS.life) + canonical format parser — paired openclaw-dashboard Phase-1 PR.
  • Non-destructive name seed seedAppProfileNameIfMissing (Phase 2, dashboard).
  • First-class gateway bootstrap injection of APP_PROFILE.md (Phase 3).
  • Agent prose to maintain the running summary (Phase 3, host).

Gate

  • vitest run src/agents/tools/save-user-section.test.ts → 13/13 passing (adds marker-guard + size-cap tests).
  • Touched files are type-clean; full-project tsgo shows only pre-existing/unrelated errors.

🤖 Generated with Claude Code

…ase 1)

Per-user-profile plan Phase 1 (plumbing + hardening), addressing codex
review 4508313642:
- Add app_profile to WRITABLE_SECTIONS (writer allowlist).
- assertSectionContentWritable: reject nested app markers ("<!-- app:") and
  enforce a per-section byte cap (app_profile 2KB, default 16KB), wired into
  the tool write path. app_profile is injected into the prompt every turn, so
  size is enforced, not just instructed.
- Tests + docs/tools/save-user-section.md updated.

Gate: vitest save-user-section 13/13; touched files type-clean (full-project
tsgo shows only pre-existing/unrelated errors).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cryptolir

Copy link
Copy Markdown
Owner Author

@codex review

Phase 1 (openclaw side) of the per-user-profile plan (#64, see its §10), resolving your review 4508313642. Please confirm this correctly lands the Phase-1 items and flag any issues:

  • Marker guard (your §3): assertSectionContentWritable rejects any content containing the substring <!-- app:. Is rejecting on substring (rather than only exact :start/:end markers) the right call? Any bypass that could still create duplicate markers and brick the section reader?
  • Hard size cap (your §5): per-section byte cap (app_profile 2 KB, default 16 KB) enforced in the writer before upsertSection. Cap values + placement sensible? Should the gateway injection path (Phase 3) also truncate defensively (planned)?
  • Allowlist: app_profile added to WRITABLE_SECTIONS; paired reader-side add is in dashboard PR #121.
  • Scope check: this is writer plumbing only — the non-destructive seed (Phase 2) and first-class gateway bootstrap injection of APP_PROFILE.md (Phase 3) are intentionally not here. The live life agent is unaffected until the gateway image is rolled in Phase 3.

Gate: vitest run src/agents/tools/save-user-section.test.ts → 13/13; touched files type-clean (full-project tsgo shows only pre-existing/unrelated errors).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 20c621cfa2

ℹ️ 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".

@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 on the Phase 1 writer PR:

No major blocker in this PR. The substring marker guard is intentionally conservative, the 2 KB app_profile cap is reasonable, and enforcing before upsertSection is the right placement.

One cross-repo note for Claude: the marker guard is now a contract shared with dashboard #121 (content.includes("<!-- app:")). Please keep the writer and dashboard seed/read helpers aligned if this rule changes later. Also, Phase 3 gateway injection should still enforce/truncate defensively before injecting app_profile, because dashboard/admin-written files may not have gone through this writer path.

…follow-up)

Per codex review 4508761684 on #65: document that the marker guard rule
(content.includes("<!-- app:")) in assertSectionContentWritable must stay
equivalent to containsAppMarker in openclaw-dashboard; change both together.
Comment-only; vitest 13/13.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
cryptolir pushed a commit that referenced this pull request Jun 16, 2026
…on clamp

Addresses codex follow-ups 4508761517 (#121) and 4508761684 (#65):
- §5a: Phase-3 injection MUST clamp app_profile to 2KB (clampAppProfile)
  regardless of write path — admin/raw-edited files bypass the writer cap.
- §11: new follow-up-resolution section (parser fix, read cap, cross-repo
  marker contract).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Thanks — addressed in 17cd4c4. assertSectionContentWritable now documents the cross-repo contract: the content.includes("<!-- app:") marker rule must stay equivalent to containsAppMarker in openclaw-dashboard, changed on both sides together. The paired note is on dashboard #121 (9778510).

On the Phase-3 point: the plan §5a now explicitly requires the gateway injection path to clamp app_profile to the 2 KB cap (clampAppProfile) before injecting, regardless of write path — because admin/raw-edited files bypass this writer. The dashboard side already added that shared clampAppProfile helper and wired it into its read path. Comment-only change here; vitest still 13/13.

Make this branch oxfmt-clean (table padding, emphasis style, line-wrap).
The remaining check/check-docs reds are PRE-EXISTING oxfmt drift in unrelated
files on main (e.g. system-prompt.ts), not from this PR. No behavior change;
vitest 13/13.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cryptolir
cryptolir merged commit 7808c59 into main Jun 16, 2026
7 of 10 checks passed
@cryptolir
cryptolir deleted the feat/app-profile-writer-hardening branch June 16, 2026 17:58
cryptolir added a commit that referenced this pull request Jun 18, 2026
…oad_skill #74) (#75)

Record the load_skill roll: #74 merged, gateway v2026.06.18.1 (sourceSha
09a99e4) pinned to life only — ships the full per-user stack to prod (writer
#65/#66 + injection #68 + first-turn #71 + load_skill #74). Bump the
INFRASTRUCTURE life-ahead tag to v2026.06.18.1 and note the US-host disk cleanup
(97% to 67%, removed 8 unused/unreferenced gateway tags).

Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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