Skip to content

docs(plan): life per-user profile (name + running summary) - #64

Open
cryptolir wants to merge 3 commits into
mainfrom
docs/peruser-profile-plan
Open

cryptolir wants to merge 3 commits into
mainfrom
docs/peruser-profile-plan

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Plan / RFC for review — no code changes. Adds docs/experiments/plans/life-per-user-profile.md.

What this is

A design doc for a per-user app_profile section in users/<clerkId>.md that:

  • is seeded from Clerk on first contact (never empty) and enriched by the agent as a running summary,
  • is auto-injected into the agent context every app turn (fixes the "user has to remind the agent of their name" problem),
  • drives the home greeting (name read from the file, not Clerk) and shows in the admin editor.

Why

Captures the verified current-state: BOOTSTRAP.md is the agent self-summary (no user info); the per-user file is display-only (User_D_Prompt/app_note allowlist); per-user info is pull-only via Graphiti and never auto-injected. All three owner observations converge on this one missing capability.

Decisions baked in

  • Population: seed-from-Clerk + agent enriches (file is source of truth, never empty).
  • Scope: rich profile / running summary (kept concise; deep history stays in Graphiti).

Spans

openclaw (writer allowlist + life-profile-context hook + agent prose), openclaw-dashboard (reader allowlist + section-write endpoint), app.havaya (seed + greeting), live life host.

Reviewer asks (codex)

See §9 of the doc — focus on the context-injection hook mechanism (host hook vs. first-class in-gateway per-user bootstrap), allowlist symmetry, seed auth surface, the app_profile format, and cross-user privacy under life-access-scope.

🤖 Generated with Claude Code

…en + in-context

Design doc / RFC for review (no code). Adds a per-user `app_profile` section to
users/<clerkId>.md that is seeded from Clerk, enriched by the agent as a running
summary, auto-injected into the agent context every app turn, and read by the
Havaya home greeting + admin editor.

Captures verified current-state findings (BOOTSTRAP is the agent self-summary,
the user file is display-only, context is pull-only via Graphiti), the agreed
decisions (seed-from-Clerk + rich running summary), per-repo changes, deploy
sequence, phased build order, risks, and reviewer questions for codex.

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

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

Plan review before implementation starts:

  1. [P1] Seed writes can wipe the agent's running summary.
    The plan describes a single-section PUT plus app-side seeding of name:. If the app sends only name: into app_profile, it can replace the whole section and delete summary: / call_them: written by the agent. Please make the dashboard write path either seedAppProfileNameIfMissing(userId, name) or a field-level patch with CAS/etag semantics, not a raw "replace app_profile" endpoint for seeding.

  2. [P1] Prefer first-class gateway injection over a life-only host hook.
    Current openclaw already has an agent:bootstrap hook context with sessionKey, sessionId, and agentId, so a host hook is possible. But this feature is generic app-user context, not Graphiti/life-specific plumbing. I would implement it first-class in gateway bootstrap assembly: when appUserId exists and an allowlisted profile section exists, append a synthetic context file like APP_PROFILE.md. That keeps parsing, tests, context reporting, and future agents in one place.

  3. [P2] Add marker-injection protection for section content.
    app_profile will be agent-writable, and existing section extraction fails closed on duplicate markers. If the agent writes text containing <!-- app:app_profile:start --> or another marker string inside the summary, the user file can become unreadable through the section API. Add validation in save_user_section and the new dashboard section endpoint to reject content containing <!-- app: markers.

  4. [P2] Tighten the privacy contract around PUBLIC_SECTIONS.life.
    Adding app_profile to the public section allowlist means any server holding the app read key can request any userId profile. That matches the existing trust model, but this section is more sensitive than User_D_Prompt. Please state explicitly that app.havaya must only read/write app_profile for the authenticated Clerk user, and prefer a server-side Havaya helper over any route/UI path that accepts arbitrary userId input.

  5. [P3] Enforce a hard profile size cap, not only an agent instruction.
    The soft ~600-char budget is good prose guidance, but this is injected every turn. Enforce a profile-specific max in the writer/tool or injection path, with clear failure or defensive truncation. Ideally both: reject overlarge writes, and truncate defensively on injection.

Answers to the reviewer asks:

  • Hook vs gateway: gateway feature, with agent:bootstrap as the integration point if that is the least invasive path.
  • Allowlist symmetry: readable + agent-writable is reasonable, but only with marker validation and size caps.
  • Seed mechanism: dedicated seed/patch endpoint, not raw section replacement.
  • Format: YAML-ish is fine for humans; add a shared parser and tests. Fenced JSON is safer but less agent-friendly.
  • Privacy: cross-user leakage is mainly guarded by appUserId; make Havaya's read/write helpers current-user-only so the app key cannot become an accidental profile oracle.

Overall: strong plan. The biggest practical footgun to fix before coding is the seed path replacing the whole profile.

Fold in all five review points before implementation:
- P1 seed: seedAppProfileNameIfMissing() — non-destructive name-only merge
  under CAS/etag, never a raw section replace (preserves agent summary).
- P1 injection: first-class gateway bootstrap assembly (synthetic
  APP_PROFILE.md via agent:bootstrap context), not a life-only host hook.
- P2 marker-injection guard: reject "<!-- app:" in writer + dashboard endpoint.
- P2 privacy: app_profile reads/writes are current-Clerk-user only via a
  server-side helper; no arbitrary-userId route/UI.
- P3 size cap: hard cap in the writer + defensive truncation on injection.
Adds shared parser + tests; new §10 maps each point to its resolution.

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

Copy link
Copy Markdown
Owner Author

Thanks — all five points folded into the plan in b5397dd66 (v2). Mapping:

  • [P1] Seed wipes summary → seeding is now seedAppProfileNameIfMissing(userId, name): non-destructive, name-only field merge under CAS/etag, never a raw section replace. Agent stays the sole writer of summary: / call_them:. (§3.1, §5b)
  • [P1] First-class gateway injection → adopted. Injection moves into gateway bootstrap assembly as a synthetic APP_PROFILE.md, using the existing agent:bootstrap context (sessionKey / sessionId / agentId) as the integration point; host hook demoted to a documented fallback. Resolves the prior Phase-1 open item. (§5a)
  • [P2] Marker-injection guard → reject any content containing <!-- app: in both save_user_section and the dashboard endpoint; shared validator + tests. (§5a, §5b)
  • [P2] Privacy / profile-oracle → explicit contract: app.havaya reads/writes app_profile for the authenticated Clerk user only, via a server-side helper; no arbitrary-userId route/UI; keys stay server-only. (§5c)
  • [P3] Hard size cap → enforced in the writer (reject overlarge) and defensive truncation on injection, on top of the soft prose budget. (§5a)

Format kept YAML-ish with a shared parser + tests as the single source of truth (§4). New §10 records the point-by-point resolution. Phase 1 (plumbing + hardening) is ready to start on your go-ahead.

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

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