Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
docs(profile): document the cross-project profile and the new precedence
AkitaOnRailse00488325133
diff --git a/AGENTS.md b/AGENTS.mdindex d65698ff..2ae06d6e 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -81,9 +81,9 @@ session start and reaches Claude Code only if the agent opens the file.If the rule is a standing *user/team* preference that should apply toevery project (tech choices, code style, personal conventions), save it-to ai-memory's reserved global scope instead — the durable-pages skill-covers how. Default memory reads surface global-scope pages in every-project automatically.+to ai-memory's cross-project profile instead (`scope: "profile"`) — the+durable-pages skill covers how. Every project receives the profile as+defaults at session start, below its own rules file.### Refreshing this snippetdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 980ec21a..044706cf 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Added+- Added the cross-project profile (`docs/cross-project-profile.md`, design in+ `docs/design-cross-project-profile.md`): a small set of `profile/` pages+ recording how the user usually works, delivered to every project and every+ harness at session start as a fenced, byte-budgeted digest of defaults that+ rank below the user's instructions, the repository's rules file and the+ project's own memory. It is on by default for a single-operator server,+ shared across every workspace, and off on a multi-user server until+ `[profile] enabled = true`, which gives each operator a private, restricted+ profile; `share = "global"` or `"workspace"` makes a team profile that is+ read-open and write-gated like `_global`. The digest filters entries by the+ stack the project's activity shows, stays byte-identical between sessions,+ and gives a project with no memory yet a larger baseline. `memory_write_page`+ and `memory_delete_page` accept `scope: "profile"`, `memory_query` returns+ profile entries in `global_scope_hits`, a marker's `[profile] contribute` /+ `consume` keys opt a project out of contributing or receiving, and+ `ai-memory profile status | list | show | forget` inspects and curates it.+ (cross-project profile)- Added `ai-memory resume --search` with immediate type-to-filter name search,and `resume --all`, which keeps the previous cross-checkout picker: everylinked checkout, the current one first, each listed with its own fully@@ -193,6 +210,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0keeps the name it would otherwise get. The default stays `host_path`. (#1033)### Changed+- Changed the documented precedence between rules and memory: the user's+ instructions, then the repository's rules file, then the project's memory,+ then the cross-project profile. Where no hard rule exists, agents now use+ what memory already knows instead of asking again; the routing snippet,+ MCP instructions and durable-pages skill send standing cross-project+ preferences to the profile (`scope: "profile"`). (cross-project profile)- Scoped `ai-memory resume` to the current checkout by default instead of everylinked project (`--all` restores the old view) and removed its default resultcutoff with bounded server pagination, preserving Left/Right harnessdiff --git a/README.md b/README.mdindex af43853e..91d7950a 100644--- a/README.md+++ b/README.md@@ -30,6 +30,13 @@ ai-memory is what's on the other side of those walls.off, what failed, what's still open. Handoffs are a protocol here, not aconvention — typed, owned, claimed exactly once.+- **It follows you across projects.** A small profile of how you usually+ work — your package manager, test layout, architecture habits — reaches+ every new repository at session start, so you stop re-explaining yourself.+ It is a default below each repository's rules file, on by default for a+ single user and opt-in, private per person, on a shared server.+ See [`docs/cross-project-profile.md`](docs/cross-project-profile.md).+- **It follows you across machines.** Memory lives in a server you run —on the same laptop, a homelab box, or wherever — so the project you lefton the desktop is the project you resume on the laptop. Same knowledge,@@ -558,7 +565,8 @@ diagram, crate breakdown, schema notes, and invariants.|---|---|| [`docs/cookbook.md`](docs/cookbook.md) | **Task-oriented cheat sheet.** "I want to do X" → how: recall prior work, keep a project rule, import an existing knowledge base, get two agents/repos working together. Start here. || [`docs/install.md`](docs/install.md) | **Installation cookbook.** Every agent CLI, every alternative (curl, source build, no-docker, no-auth), and the server-on-a-different-machine walkthrough. |-| [`docs/usage.md`](docs/usage.md) | Handoffs, proactive memory queries, slim routing snippet + managed Agent Skills, web UI, raw-wiki inspection, and rules-vs-facts workflow. |+| [`docs/usage.md`](docs/usage.md) | Handoffs, proactive memory queries, slim routing snippet + managed Agent Skills, web UI, raw-wiki inspection, and the rules, memory and profile precedence. |+| [`docs/cross-project-profile.md`](docs/cross-project-profile.md) | **The cross-project profile.** Your usual choices delivered to every project as defaults: defaults per deployment, every setting, per-project opt-outs, multi-user opt-in and privacy, CLI. || [`docs/managed-workstreams.md`](docs/managed-workstreams.md) | Optional `ai-memory run` continuity across harnesses: auto harness selection, native resume, argument forwarding, ledger search, privacy, and recovery. || [`docs/agent-messaging.md`](docs/agent-messaging.md) | Cross-project agent-to-agent messaging: a directed, claim-once inbox/queue plus the on-start "you have mail" notice. || [`docs/marker-file.md`](docs/marker-file.md) | `.ai-memory.toml` workspace/project routing for multi-client trees, mono-repos, worktrees, and work/personal separation, plus per-repository server profiles. |diff --git a/crates/ai-memory-core/src/routing_skills/ai-memory-durable-pages/SKILL.md b/crates/ai-memory-core/src/routing_skills/ai-memory-durable-pages/SKILL.mdindex 10727549..f4f94f15 100644--- a/crates/ai-memory-core/src/routing_skills/ai-memory-durable-pages/SKILL.md+++ b/crates/ai-memory-core/src/routing_skills/ai-memory-durable-pages/SKILL.md@@ -76,6 +76,6 @@ Rejected alternatives and WHY, so future sessions don't re-propose them.Pinned pages are exempt from retention decay and curation, and the auto-improvement path refuses to rewrite them — the record stays immutable unless a human unpins it. To supersede a decision, write a NEW page and set the old page's status line to `superseded by [[decisions/<new>]]`; never edit the old decision's substance. Note: ai-memory never touches files in the project repository — a `docs/adr/` directory managed there (by hand or by another tool) is outside ai-memory entirely; these wiki ADRs complement it for cross-session retrieval.-## Standing user/team preferences go to the global scope+## Standing user/team preferences go to the cross-project profile-When the fact is a standing preference that should apply to EVERY project — technology choices ("always use pnpm workspaces"), code style ("prefer composition over inheritance"), personal conventions ("never `--force` without asking") — call `memory_write_page` with `scope: "global"` instead of the current project. The page lands in the reserved `_global` scope, and default memory reads surface it in every project as `global_scope_hits`. `scope: "global"` cannot be combined with workspace/project arguments. Use it only for genuinely cross-project preferences; project-specific rules stay in the project (or its instruction file, per the section above).+When the fact is a standing preference that should apply to EVERY project — technology choices ("always use pnpm workspaces"), code style ("prefer composition over inheritance"), personal conventions ("never `--force` without asking") — call `memory_write_page` with `scope: "profile"` instead of the current project. The page joins the cross-project profile under `profile/` (pass a path like `tools/pnpm.md`; it is stored as `profile/tools/pnpm.md`), every project's session start lists it as a default, and default memory reads surface it as `global_scope_hits`. Start the body with a `# Title` and one imperative line; optional frontmatter `applies_to` (e.g. `rust`) scopes it to projects on that stack. Remove one with `memory_delete_page` and `scope: "profile"`. `scope: "global"` still writes the shared `_global` scope directly. Neither scope can be combined with workspace/project arguments. Use it only for genuinely cross-project preferences; project-specific rules stay in the project (or its instruction file, per the section above). A rules file always wins over the profile: the profile is the default for what the repository does not say.diff --git a/crates/ai-memory-core/src/routing_snippet.rs b/crates/ai-memory-core/src/routing_snippet.rsindex 55061952..291e6ae2 100644--- a/crates/ai-memory-core/src/routing_snippet.rs+++ b/crates/ai-memory-core/src/routing_snippet.rs@@ -109,9 +109,9 @@ session start and reaches Claude Code only if the agent opens the file.If the rule is a standing *user/team* preference that should apply toevery project (tech choices, code style, personal conventions), save it-to ai-memory's reserved global scope instead — the durable-pages skill-covers how. Default memory reads surface global-scope pages in every-project automatically.+to ai-memory's cross-project profile instead (`scope: "profile"`) — the+durable-pages skill covers how. Every project receives the profile as+defaults at session start, below its own rules file.### Refreshing this snippet@@ -173,7 +173,7 @@ The reserved `_prompts/consolidation.md` page may provide bounded advisory prefeWrite durable project rules such as “always X” or “never Y” to the project's canonical agent instruction file, using the filename and discovery mechanism appropriate to that harness. Do not duplicate a project rule into ai-memory merely to make it persistent.-Standing user or team preferences that genuinely apply across projects belong in ai-memory's reserved global scope. Default memory retrieval surfaces global-scope entries alongside project results.+Standing user or team preferences that genuinely apply across projects belong in ai-memory's cross-project profile (`scope: "profile"`). Every project receives it as defaults at session start, below its own rules file.### Refreshing this managed blockdiff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rsindex 0cd7a830..d02581dd 100644--- a/crates/ai-memory-mcp/src/server.rs+++ b/crates/ai-memory-mcp/src/server.rs@@ -192,7 +192,10 @@ knowledge may live elsewhere, broaden deliberately with named `scopes` or \`global=true`; never broaden a write. If a SessionStart handoff block is already in \context, answer from it instead of claiming another handoff. Maintained pages \(`_rules/`, `gotchas/`, `procedures/`, `decisions/`) are higher-value evidence, not \-authority: read them in full, then check them against the current request.\n\+authority: read them in full, then check them against the current request. A \+profile digest lists the user's usual choices from other projects: when the user \+and the repository's rules say nothing, apply them as defaults instead of asking \+again, and say which you applied.\n\\n\--- Detailed tool routing follows. ---\n\\n\@@ -326,8 +329,10 @@ should be proposed from a completed session, or at explicit wrap-up \passing `title` is a known JSON-escape footgun (issue #67). When the \fact is a standing user/team preference that should apply to EVERY \project ('always use pnpm', 'never force-push', code style rules), \- pass `scope: \"global\"` so it lands in the reserved `_global` scope \- instead of the current project. When the user explicitly wants a \+ pass `scope: \"profile\"` so it joins the cross-project profile \+ (stored under `profile/`, delivered to every project as a default); \+ `scope: \"global\"` writes the shared `_global` scope directly. When \+ the user explicitly wants a \time-bounded note, pass `expires_at` as RFC3339 or `YYYY-MM-DD`; the \TTL hides the page after expiry and outranks `pinned`. Optional `kind`, \`entities`, `abstract`, and `relations` carry bounded metadata; writes \@@ -1617,10 +1622,11 @@ struct WritePageArgs {/// both when `scope: "global"`.#[serde(default)]workspace: Option<String>,- /// Set to `"global"` to write into the reserved `_global` preferences- /// scope — standing user/team context (tech preferences, code style,- /// durable decisions) that default `memory_query` reads union into- /// every project. Cannot be combined with `workspace`/`project`.+ /// Set to `"profile"` to add a standing preference to the cross-project+ /// profile (the path is placed under `profile/`; every project receives+ /// it as a default), or to `"global"` to write the reserved `_global`+ /// preferences scope directly. Both are unioned into default+ /// `memory_query` reads. Cannot be combined with `workspace`/`project`.#[serde(default)]scope: Option<String>,/// Optional TTL: RFC3339 instant (`2026-09-01T12:00:00Z`) or bare@@ -4141,8 +4147,11 @@ impl AiMemoryServer {to `semantic`; set `pinned=true` for facts that should never decay. \For standing user/team preferences that apply to EVERY project \(tech choices, code style, durable personal rules), pass \- `scope: \"global\"` — the page lands in the reserved `_global` \- scope and default memory_query calls surface it in every project. \+ `scope: \"profile\"` — the page joins the cross-project profile \+ under `profile/` (its path gains that prefix), reaches every \+ project's session start as a default, and default memory_query \+ calls surface it. `scope: \"global\"` writes the reserved \+ `_global` scope directly. \\Optional `kind`, `entities`, `abstract`, and `relations` carry bounded \metadata. This replaces the whole page; omitted metadata is cleared. \diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 59768649..d9cafedc 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -182,6 +182,12 @@ from hook paths.backup API so the source stays writable; `ai-memory restore`reverses. Or: `git push` the wiki dir + `rsync` the data dir.+**Cross-project profile:** after the project brief, SessionStart appends a+fenced, byte-budgeted, byte-stable digest of the user's usual choices from other+projects (`docs/cross-project-profile.md`), filtered by the stack the project's+activity shows, with a larger baseline for a project that has no pages yet. It+is on by default for a single-operator server and off for a multi-user one.+**Optional managed-workstream loop:** `ai-memory run` opens a lease for thecurrent repository/worktree workstream, resolves an explicit harness or thenewest usable local/linked harness, creates or resumes that harness's native@@ -345,7 +351,7 @@ prunable rather than only after it ages in place.| Table | What ||---|---|-| `workspaces`, `projects` | Top of the 3-tuple identity coordinate. `projects.identity` / `identity_source` (V70, #708) hold the repository identity a project routes by — an explicit marker `identity` or a normalised git remote, resolved client-side — unique per workspace when set; empty until a capture claims the project. A marker's `identity_style = "path"` (#1033, forwarded as the `identity_style` hook query param alongside a git-remote identity; default `host_path`) names a project that resolution *creates* from the repository path without the host (`acme-api`), falling back to the usual name when another project already holds it; it never renames or re-keys an existing project. See `docs/marker-file.md#repository-identity`. `projects.access_mode` (V68; `open` default / `restricted`) decides whether any authenticated user or only root, the creator (`projects.created_by`, V69) and grant holders (`project_grants`, V68) reach it, decided by `ai_memory_store::authorize_project` — `docs/users.md#per-project-access`. |+| `workspaces`, `projects` | Top of the 3-tuple identity coordinate. `projects.identity` / `identity_source` (V70, #708) hold the repository identity a project routes by — an explicit marker `identity` or a normalised git remote, resolved client-side — unique per workspace when set; empty until a capture claims the project. A marker's `identity_style = "path"` (#1033, forwarded as the `identity_style` hook query param alongside a git-remote identity; default `host_path`) names a project that resolution *creates* from the repository path without the host (`acme-api`), falling back to the usual name when another project already holds it; it never renames or re-keys an existing project. See `docs/marker-file.md#repository-identity`. `projects.access_mode` (V68; `open` default / `restricted`) decides whether any authenticated user or only root, the creator (`projects.created_by`, V69) and grant holders (`project_grants`, V68) reach it, decided by `ai_memory_store::authorize_project` — `docs/users.md#per-project-access`. `projects.profile_contribute` / `profile_consume` (V74) record the marker's `[profile]` opt-outs, forwarded at session start. Reserved projects: `scratch`, `_global` (shared preferences; holds the single-user profile under `profile/`), `_profile` (a workspace profile) and `_profile.<user id>` (a private profile, always `restricted`); capture is never attributed to any of them — `docs/cross-project-profile.md`. || `pages` | Versioned wiki pages with `is_latest` + `supersedes` chain. M8 columns: `last_accessed_at`, `access_count`, and decay-only tombstone marker `superseded_at`. M9 cols: `embedding_provider`, `embedding_model`, `embedding_dim`. V36: `expires_at` (frontmatter TTL). V37: `salience` (NULL = `salience_default`; derived from `page_feedback`). || `pages_fts` | FTS5 virtual table over `(title, body)`, auto-synced by triggers. || `sessions`, `observations` | Sanitized, bounded lifecycle-hook projections. `sessions.ended_observation_count` is the stable generation watermark for resumed-session re-end eligibility; wall clocks are not used for that decision. They are an operational audit trail, not a complete native transcript. |@@ -532,8 +538,8 @@ long-lived entry appearing there is that policy working rather than a fault.| `memory_consolidate` | destructive | LLM-driven page rewrite. `multi_page=true` for atomic fan-out; an update whose path names an existing pinned page is skipped (`_slots/` excepted). Omitting `session_id` (or sending a blank one) consolidates the latest completed session in the resolved project; the same omission on a project with none fails as `no completed session in <scope>`. Consolidation prompts append the target project's active reserved `_prompts/consolidation.md` body as sanitized, 2,000-character-capped, JSON-encoded, untrusted advisory preferences; TTL-expired pages are ignored and a per-call `instructions` argument overrides the page for one call. Both system prompts keep schema, evidence, disclosure, tool-use, and output rules authoritative. || `memory_feedback` | write | Record a quality signal for one page by exact `path`: `helpful`/`not_helpful` step `pages.salience` for sweep-eligible episodic pages, while `stale`/`wrong` floor salience and surface any current page as a `feedback_flagged` lint finding. Never deletes; the path resolves to the current version in the transaction, so a later rewrite clears it. Retrieved content never authorizes feedback by itself. || `memory_auto_improve` | write | Manually review a completed session and apply or stage validated wiki edits through the auto-improvement approval path. Without a session ID, selects the newest completed session with no persisted auto-improvement run so repeated calls advance through preflight skips; an explicit ID remains rerunnable. The server also schedules review for new sessions; `[auto_improve] require_approval = true` leaves proposals pending for manual review. |-| `memory_write_page` | destructive | Write durable wiki knowledge when the user explicitly asks to remember/annotate it. `scope: "global"` writes into the reserved `_global` preferences scope; optional `expires_at` sets an RFC3339 or date-only TTL; optional `session_id` cites a session of the same project as evidence, and on `sessions/<id>.md` stamps the session-page frontmatter and settles the queued consolidation job. |-| `memory_delete_page` | destructive | Delete a single page by exact `path`. Fires the admission chain (op=delete); idempotent. |+| `memory_write_page` | destructive | Write durable wiki knowledge when the user explicitly asks to remember/annotate it. `scope: "global"` writes into the reserved `_global` preferences scope and `scope: "profile"` into the caller's cross-project profile (path placed under `profile/`); optional `expires_at` sets an RFC3339 or date-only TTL; optional `session_id` cites a session of the same project as evidence, and on `sessions/<id>.md` stamps the session-page frontmatter and settles the queued consolidation job. |+| `memory_delete_page` | destructive | Delete a single page by exact `path`; `scope: "profile"` deletes from the caller's cross-project profile. Fires the admission chain (op=delete); idempotent. || `memory_forget_sweep` | destructive | Retention pass: evict cold pages through the wiki layer, purge aged tombstone ancestry, and hard-delete TTL-expired pages. `dry_run=true` for preview. || `memory_lint` | destructive | Rule-based + LLM contradiction findings → `wiki/_lint/`. Also runs a **zero-LLM contradiction detector** (design-memory-aging.md A5): cold semantic/procedural pages whose already-stored embeddings sit in the `contradiction_band_min`–`contradiction_band_max` cosine-similarity band (default 0.4–0.75; "same topic, not a near-duplicate" — at/above the max is A3 dedup, below the min unrelated) get an advisory `contradiction` finding with newer-wins timestamp advice. Bounded (one embeddings load over the capped cold set, capped findings, deterministic); a clean no-op with no embedder configured; advisory-only — never deletes/edits/supersedes a page and persists no edge (invariants #13, #16, #2), so no migration. On a single-language or single-domain store, background similarity between unrelated pages already sits well above the default floor, so the band measures domain proximity more than conflict and produces noisy findings — raise `contradiction_band_min` (`config.toml` or `AI_MEMORY_CONTRADICTION_BAND_MIN`) for such a store. || `memory_install_self_routing` | read-only | Return the canonical slim routing snippet plus managed Agent Skill payloads and target hints for CLAUDE.md / AGENTS.md installs. |@@ -823,6 +829,18 @@ per_user = false # shared + own slots in agent contextclaim_on_session_start = true # false offers metadata; explicit accept claimscreate_on_session_end = true # false stops automatic handoffs at session end and OpenCode turn checkpoints+[profile] # cross-project profile (docs/cross-project-profile.md)+enabled = "auto" # auto: on for single-user, off for multi-user; true / false+share = "auto" # auto | global | workspace | user | off+ # auto: global (all workspaces) single-user, user (private) multi-user+min_projects = 2 # distinct projects a choice must appear in to join the profile+inject_on_session_start = true # fenced digest after the project brief+digest_max_bytes = 3000 # UTF-8 bytes, clamped 1500..12000+baseline_max_bytes = 6000 # digest budget for a project with no pages yet, clamped 2000..20000+apply_max_lines = 40 # most lines `profile apply` writes into a rules file+llm = true # use the configured provider when there is one+ # env: AI_MEMORY_PROFILE__<KEY>, e.g. AI_MEMORY_PROFILE__SHARE=workspace+[consolidation] # LLM consolidation prompt sizingmax_input_tokens = 100000 # approximate whole-input target; min 6000# a flat chars-per-token heuristic, so itdiff --git a/docs/cookbook.md b/docs/cookbook.mdindex 7136578d..fa3fb91c 100644--- a/docs/cookbook.md+++ b/docs/cookbook.md@@ -49,13 +49,37 @@ Your agent calls `memory_write_page` and it lands as a durable wiki page (routedunder `_rules/` when it's a rule). Next session, `memory_query` surfaces it, andif the project's `.ai-memory.toml` opts into the on-start brief, rules areprepended to the agent's context automatically. To make it apply to **all** your-projects, ask for it as a global rule (`scope: "global"`). On a multi-user+projects, ask for it as a standing preference — it goes to your cross-project+profile (see the next recipe), or to the shared `_global` scope with+`scope: "global"`. On a multi-userserver, writing a global rule needs root or a `write` grant on `_global`. Fromanother project's page, link to that standing page with `[[_global:path]]` — italways names the reserved `_global` project in the default workspace. Siblingprojects use `[[project:path]]`; another workspace uses`[[workspace/project:path]]`. Bare `[[name]]` stays inside the current project.+## Recipe: stop re-explaining your habits in every new project++> "In all my projects: use pnpm, keep integration tests in tests/suite."++Your agent writes each one into the cross-project profile+(`memory_write_page` with `scope: "profile"`). From then on every project — and+every harness — gets a short "your usual choices" section at session start, and+the agent applies those choices whenever the repository's rules file and you+say nothing. A brand-new repository gets the whole baseline, plus a pointer to+`ai-memory profile apply` for writing it into that repository's rules file.++- See what it holds: `ai-memory profile list`; drop one: `ai-memory profile+ forget tools/pnpm.md`.+- Keep a client project out of it: `[profile] contribute = false` in that+ repository's `.ai-memory.toml`; keep the digest out of one: `consume = false`.+- Scope an entry to a stack with frontmatter `applies_to: [rust]`.+- On by default for a single user (one profile across every workspace). On a+ shared server it is off until the operator sets `[profile] enabled = true`,+ and then each person gets a private profile.++Details: [`cross-project-profile.md`](cross-project-profile.md).+## Recipe: have a project read a specific document before implementingTwo ways, depending on where the document lives:diff --git a/docs/cross-project-profile.md b/docs/cross-project-profile.mdnew file mode 100644index 00000000..654ad509--- /dev/null+++ b/docs/cross-project-profile.md@@ -0,0 +1,227 @@+# The cross-project profile++ai-memory keeps knowledge per project, so switching harness costs nothing:+Claude Code, Codex and OpenCode in one checkout read the same pages. The+**profile** removes the other cost, switching *project*. It is a small set of+pages recording how you usually work — the package manager you reach for, how+you lay out tests, the architecture you prefer, the review workflow you follow —+and every project receives it at session start, through every harness.++When you start a new repository and describe what you want, the agent already+has your baseline, so you do not re-explain it.++Design and rationale: [`design-cross-project-profile.md`](design-cross-project-profile.md).++## How the agent uses it: rules first, memory as the fallback++The profile never overrides anything more specific. The order is:++1. Your current instructions in the conversation.+2. The repository's rules file (`AGENTS.md`, `CLAUDE.md`, the harness's own).+3. The project's memory (its pages, rules and decisions).+4. The profile: what you usually do across projects.++So when a rules file says "use npm", the profile's "usually pnpm" does not+apply. When nothing says, the agent uses the profile instead of asking again,+and says which default it applied so you can correct it.++A profile entry is a preference you expressed, used as a default. Like all+stored memory it is still data, not a command: it can pick a tool, a layout or+a convention, but it cannot authorize anything your current instructions would+not (tool use, permission changes, disclosure, destructive actions).++## Defaults++| Deployment | Profile | Where it lives |+|---|---|---|+| Single user (no database users, no trusted proxy), any number of workspaces | **on**, shared by every workspace | `default/_global`, under `profile/` |+| Multi-user (database users or a trusted identity proxy) | **off**; opt in with `enabled = true` | one private profile per operator |++A single operator gets one profile across everything, including several+workspaces. A server with several operators keeps the profile off until the+operator enables it, and then each person gets their own private profile:+nothing one operator's agents learn reaches another's.++## What you see at session start++After the project brief (if the project has one), the session start carries a+short fenced section:++```text+> 🧭 ai-memory: your usual choices (cross-project profile)+> Your usual choices from other projects. Use them as defaults when this+> project's rules and the user say nothing; say which default you applied. …+- [javascript] Use pnpm, not npm. (`profile/tools/pnpm.md`)+- Keep integration tests in tests/suite. (`profile/testing/layout.md`)+```++- **One line per entry**, each naming its page, so the agent can open it with+ `memory_read_page` for your reasoning and the evidence behind it.+- **Filtered by stack.** An entry with `applies_to: [rust]` only shows in a+ project whose activity touches Rust (detected from file names such as+ `Cargo.toml` and source extensions in its captured activity). A project with+ no activity yet gets every entry.+- **Bounded.** The section stays within `digest_max_bytes` (default 3,000+ bytes); entries that do not fit are counted, and `memory_query` finds them.+- **Stable.** The order is fixed (category, then path) and nothing+ time-dependent is printed, so the text is byte-identical between sessions+ until the profile changes, which keeps it in the harness's cached prompt.+- **A baseline for new projects.** A project with no memory of its own gets a+ larger budget (`baseline_max_bytes`, default 6,000 bytes) and a note that the+ agent can offer `ai-memory profile apply` to write your usual choices into+ the new repository's rules file.+- Entries marked `enforced_by` (something else, like a hook, already enforces+ them) are left out of the digest.++The profile also travels with retrieval: `memory_query` returns profile entries+in `global_scope_hits`, next to the rest of the global scope.++## Adding, reading and removing entries++Ask the agent to remember a standing preference ("always use pnpm in my+projects"); it writes it with `memory_write_page` and `scope: "profile"`. You+can also write one yourself:++```text+memory_write_page { "scope": "profile", "path": "tools/pnpm.md",+ "body": "# Pnpm\n\nUse pnpm, not npm.\n\nWhy: workspaces and a strict lockfile." }+```++The path is stored under `profile/` (`profile/tools/pnpm.md`). Use a category+folder: `stack`, `architecture`, `workflow`, `testing`, `tools`, `style` or+`habits`; the digest lists them in that order. Optional frontmatter:++| Key | Meaning |+|---|---|+| `summary` | The digest line (otherwise the first line of prose in the body). |+| `applies_to` | Stack tags the entry is scoped to, e.g. `[rust]` or `typescript`. |+| `enforced_by` | Something already enforces it (e.g. `pre-push hook`); kept out of the digest. |++Entries are ordinary wiki pages, markdown in git: edit them by hand, and every+change is versioned. `memory_delete_page` with `scope: "profile"` removes one+(git keeps its history).++From the command line (root token on a multi-user server):++```bash+ai-memory profile status # on/off, where it lives, entries, digest size, opt-outs+ai-memory profile list # every entry with its scope tags+ai-memory profile show tools/pnpm.md # one entry+ai-memory profile forget tools/pnpm.md # remove one entry+ai-memory profile list --user alice # an operator's private profile (share = "user")+ai-memory profile list --workspace work # a workspace profile (share = "workspace")+```++## Server settings++In `config.toml` (or `AI_MEMORY_PROFILE__<KEY>`, for example+`AI_MEMORY_PROFILE__SHARE=workspace`):++```toml+[profile]+enabled = "auto" # auto | true | false+share = "auto" # auto | global | workspace | user | off+min_projects = 2+inject_on_session_start = true+digest_max_bytes = 3000 # clamped 1500..12000+baseline_max_bytes = 6000 # clamped 2000..20000+apply_max_lines = 40+llm = true+```++- **`enabled`**: `auto` turns the profile on for a single-operator server and+ off for a multi-user one; `true` and `false` override that for any+ deployment. A multi-user server keeps `auto` off even if you set `share`, so+ enabling it there is always an explicit `enabled = true`.+- **`share`**: where the profile lives.+ - `global`: one profile for the whole server, in `default/_global/profile/`,+ for every workspace. On a multi-user server this is a **team** profile:+ readable by everyone, writable only by root or an operator holding a+ `write` grant on `_global`.+ - `workspace`: one profile per workspace, in that workspace's reserved+ `_profile` project. Use it when workspaces separate things that must not+ mix, such as work and personal, or two clients. On a multi-user server it is+ write-gated like `_global` (root or a `write` grant on that `_profile`).+ - `user`: one private profile per operator, in a restricted project of the+ default workspace named `_profile.<user id>` whose creator is that operator.+ Only they and root can read or write it. On a single-operator server it+ behaves like `global`.+ - `off`: no profile at all.+ - `auto` (default): `global` on a single-operator server, `user` on a+ multi-user one.+- **`min_projects`**: how many distinct projects a choice must appear in before+ it joins the profile on its own (a choice you state as general — "in all my+ projects" — needs only one).+- **`inject_on_session_start`**: `false` keeps the digest out of session start;+ the profile still reaches `memory_query`.+- **`digest_max_bytes`** / **`baseline_max_bytes`**: the digest budgets, in+ UTF-8 bytes. The floors keep room for the fixed precedence and security lines+ plus a few entries.+- **`apply_max_lines`**: the most lines `ai-memory profile apply` writes into a+ rules file.+- **`llm`**: use the configured LLM provider, when there is one, to classify and+ merge entries; `false` keeps the profile fully zero-LLM.++`ai-memory profile status` prints the effective values.++### Enabling it on a multi-user server++```toml+[profile]+enabled = true # share stays "auto": a private profile per operator+```++Each operator authenticates with their own API key; their agents write and read+their own `_profile.<user id>`. Requests made with the root token have no+private profile (there is no database user behind them). For a shared team+profile instead, set `share = "global"` (or `"workspace"`) and grant the+curators `write` on `_global` (or that workspace's `_profile`):++```bash+ai-memory user grant --user alice --workspace default --project _global --level write+```++## Per-project opt-outs++In a project's `.ai-memory.toml`:++```toml+[profile]+contribute = false # never learn from this project (client or NDA work)+consume = false # no profile digest here, and no profile in this project's queries+```++Both default to on. The hook clients forward them at session start and the+server records them on the project, so they apply to every harness, and+removing the key from the marker turns the setting back on at the next session+start. A marker that sets only `[profile]` keys is a settings boundary, like one+that sets `[briefing]` keys: an outer marker's `workspace`/`project` do not+apply through it. `ai-memory profile status` lists the projects that opted out+of contributing.++## Privacy and isolation++- A private profile (`share = "user"`) is a restricted project: another+ operator's read, write or delete is refused, and a query never unions it for+ anyone but its owner.+- The shared scopes (`global` and `workspace` profiles) are readable by every+ operator but writable only by root or a `write` grant, because they reach+ everyone's session starts.+- Event capture is never attributed to a profile project, whether the name comes+ from a directory or a marker.+- Entries go through the same sanitizer as every page; `contribute = false`+ keeps a project out of the profile entirely.++## Troubleshooting++- **No digest at session start.** Run `ai-memory profile status`: the profile+ may be off (a multi-user server needs `enabled = true`), it may have no+ entries yet, the project may set `consume = false`, or every entry may be+ scoped to a stack this project does not use. A session started inside the+ profile's own scope (for example in `_global` itself) gets no digest, since+ those pages are already its project memory.+- **Kimi Code.** Kimi re-fetches on every prompt; the digest is delivered on+ the first prompt of each session only.+- **The agent did not apply a default.** The rules file and your instructions+ win; check that the repository does not say otherwise. Run+ `memory_read_page` on the entry to see what it actually says.diff --git a/docs/design-cross-project-profile.md b/docs/design-cross-project-profile.mdindex de5ca5fb..0bf3adf3 100644--- a/docs/design-cross-project-profile.md+++ b/docs/design-cross-project-profile.md@@ -99,7 +99,8 @@ Explicit values:of that workspace. Use it when workspaces separate contexts that must not mix(work and personal, or two clients).- `user`: one private profile per operator, in a restricted project in the- default workspace whose creator is that operator. It harvests only that+ default workspace, named `_profile.<user id>`, whose creator is that+ operator. It harvests only thatoperator's own sessions and pages and only from projects the operator canread. Other operators cannot read or write it (per-project authorization,`docs/design-per-project-authz.md`); root can, as with every restricted@@ -210,7 +211,7 @@ Both calls fall back to the zero-LLM path on any provider error.## 7. Configuration-Server (`config.toml` / `AI_MEMORY_PROFILE_*`):+Server (`config.toml` / `AI_MEMORY_PROFILE__<KEY>`):```toml[profile]@@ -218,8 +219,8 @@ enabled = "auto" # auto = on for single-user, off for multi-usershare = "auto" # auto | global | workspace | user | offmin_projects = 2inject_on_session_start = true-digest_max_bytes = 3000 # clamped 500..12000-baseline_max_bytes = 6000 # clamped 1000..20000+digest_max_bytes = 3000 # clamped 1500..12000+baseline_max_bytes = 6000 # clamped 2000..20000apply_max_lines = 40llm = true # use the configured provider when there is one```@@ -237,10 +238,15 @@ consume = false # no digest or union in this project`ai-memory profile status | list | show <path> | forget <path> | review |rebuild | apply [--target FILE] [--dry-run]`.+`status` and `list` read `/admin/profile/*`; `show` and `forget` reuse+`/admin/read-page` and `/admin/delete-page` against the profile's scope. All+are root-only on a multi-user server, like every `/admin/*` route; there, each+operator manages their own private profile through MCP.+On the MCP side no tool is added: `memory_write_page` accepts-`scope: "profile"` (the caller's profile scope), `memory_delete_page` removes-an entry the same way, and `memory_query` returns profile hits next to the-global ones.+`scope: "profile"` (the caller's profile scope; the path is placed under+`profile/`), `memory_delete_page` removes an entry the same way, and+`memory_query` returns profile hits in `global_scope_hits`.## 9. Security boundaries@@ -253,6 +259,9 @@ global ones.- Candidates come only from user prompts and curated pages, after thesanitizer; tool output is never a source.- The digest and the LLM prompts treat stored text as data.+- The shared scopes (`_global`, a workspace `_profile`) are read-open and+ write-gated on a multi-user server: root or a `write` grant.+- Event capture is never attributed to a reserved profile project.Each gets an adversarial test and a row in `docs/security-boundaries.md`.diff --git a/docs/marker-file.md b/docs/marker-file.mdindex c01d84ba..fa979b0e 100644--- a/docs/marker-file.md+++ b/docs/marker-file.md@@ -142,6 +142,19 @@ inject_on_session_start = "true"# never traded for content. Clamped server-side to [1500, 20000];# defaults to 4000.max_chars = 4000++# Optional. The cross-project profile (docs/cross-project-profile.md): your+# usual choices from other projects, delivered at session start as defaults+# below this repository's rules file. Both keys default to on.+# `contribute = false` keeps this project out of the profile (client or NDA+# work); `consume = false` keeps the profile digest out of its session starts+# and the profile out of its queries. Forwarded by every hook client at+# session start and recorded on the project, so removing a key turns the+# setting back on. Quoted or bare; only an explicit false / "no" / "off" /+# "0" turns a key off.+[profile]+contribute = false+consume = false```**Naming rules** for `workspace` and `project`, validated server-side:@@ -156,20 +169,25 @@ defensively but the server's regex is the source of truth.`project_strategy` accepts `repo-root` (or `repo_root`) only. Unknownvalues are ignored and behave like the default `basename(cwd)` strategy.+`[profile] contribute` and `consume` are on unless the value is explicitly+falsy (`false` / `0` / `no` / `off`, quoted or bare). A marker that sets only+`[profile]` keys is a settings boundary, like one with `[briefing]` keys.+`default_global` and `inject_on_session_start` accept a truthy value(`true` / `1` / `yes` / `on`, quoted or bare — section-style keys areparsed leniently); anything else behaves as absent. `max_chars` is aplain integer.The session-start brief is **project-scoped**: it draws only from the-session's resolved `(workspace, project)`, and the reserved `_global` scope-is deliberately *not* unioned into it. A standing rule placed in-`_global/_rules/` therefore does not reach the brief. It stays reachable on-demand through `memory_query` (which *does* union `_global`), and a durable-always-on rule belongs in the agent's own rules file (`CLAUDE.md` /-`AGENTS.md`) — see the "Rules vs facts" guidance in `docs/usage.md`. The brief-is compiled as *untrusted history*, so it is deliberately the wrong channel-for instructions the agent is expected to obey every turn.+session's resolved `(workspace, project)`. Cross-project knowledge reaches+the session through the **profile digest** instead, a separate fenced section+after the brief (see `docs/cross-project-profile.md`): the profile's entries+are delivered as defaults the agent applies when the user and the+repository's rules file say nothing. A hard rule that must hold in this+repository whatever the defaults say still belongs in the agent's own rules+file (`CLAUDE.md` / `AGENTS.md`), which takes precedence over memory — see the+"Rules, memory and the profile" guidance in `docs/usage.md`. Other `_global`+pages stay reachable on demand through `memory_query`, which unions them.`drop_subagent_captures` accepts a truthy string (`"true"` / `"1"` /`"yes"` / `"on"`); any other value, or its absence, leaves this project'sdiff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex 00abb7c2..ba142239 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -25,6 +25,10 @@ boundary not yet built.| 1 | Per-project isolation (3-tuple) | `ai-memory-store/src/scope.rs` `ScopeResolver::resolve_read_args`/`resolve_write_args`, no-create `lookup_existing_scope`; reader queries filter by `(workspace_id, project_id)`; `reader.rs` `sessions_for_scope_filtered` joins only consolidation jobs in the requested workspace and project; `reader.rs` `incremental_pages` filters workspace and project before its keyset and limit; `reader.rs` `session_counts_by_agent` filters mixed-source observations by the requested workspace and project | `store` `scope.rs` read-resolution table tests; `tests/suite/multi_session.rs`; `session_observations.rs` `consolidation_summary_latest_generation_is_scope_and_owner_bound` (a foreign-scope job is absent; the own latest generation and owner controls pass), `incremental_pages_equal_timestamps_cutoff_expiry_and_foreign_scope` (foreign scope absent with a same-scope control), `mixed_capture_count_scopes_observations_and_preserves_owner_and_window` (foreign-scope observations cannot turn an own session into a mixed one; same-scope control can) | STRONG || 1b | Reserved `_global` scope union never leaks a foreign project (#930) | `ai-memory-mcp/src/server.rs` `memory_query` — the union runs for single-project queries (`scopes` empty) and searches **only** `lookup_global_scope`'s reserved `(workspace_id, project_id)`, never an arbitrary project; the double-search guard resolves the *queried* project (named or active) so it can't be tricked into skipping | `server.rs` `global_union_never_leaks_a_foreign_projects_pages` (a third real project's page must not surface via the union; reserved page must), `single_project_query_unions_global_scope_and_multi_scope_skips_it` | STRONG || 1c | Reserved `_global` scope is read-open, write-gated (GHSA-7qj3-7wqw-m5w6) | `ai-memory-store/src/project_authz.rs` `ProjectAuthz::authorize` (a write to `default/_global` needs root or a `write` grant in either access mode; creator ignored) fed by `resolve_project_authz`/`read_project_row` (`reserved_global`, grant read for the global scope regardless of mode); `ai-memory-mcp/src/server.rs` `memory_write_page` resolves `scope: "global"` through `write_target_ids_with_actor` like an explicit `default/_global` | `project_authz.rs` `the_global_scope_admits_writes_only_from_root_or_a_write_grant`; `server.rs` `a_user_without_a_global_grant_cannot_change_the_global_scope` (both spellings and delete refused for an ungranted user and for `_global`'s creator; page survives; reads stay open), `a_global_write_grant_admits_writes_and_the_union_stays_readable` (legitimate control: write grant admits both spellings, another user's restricted-project query still unions the page); bite-checked with the authz rule removed and with the raw `create_global_scope` path restored | STRONG |+| 1d | A private cross-project profile is readable and writable by its operator alone (`[profile] share = "user"`) | `ai-memory-store/src/ops.rs` `initial_access_mode` (a `_profile.<user id>` project is always created `restricted`, creator recorded in the same transaction); `ai-memory-store/src/scope.rs` `lookup_profile_scope` / `create_profile_scope` (the project name derives from the authenticated viewer's id; no database user, no private profile); `ai-memory-mcp/src/server.rs` `profile_target_ids` and the `memory_query` profile union (resolved per viewer through the per-project choke point) | store `integration::profile` `a_private_profile_refuses_every_other_operator` (another operator's read and write by name refused; owner control admitted), `reserved_profile_projects_get_their_fixed_access_modes`; `server.rs` `a_private_profile_is_private_to_its_operator` (no union leak; read, write and delete by name refused; owner and own-profile controls); `multi_session.rs` `two_harnesses_of_one_operator_share_one_private_profile`; both fail with the restricted-mode guard removed | STRONG |+| 1e | The shared profile scopes are read-open, write-gated like `_global` | `ai-memory-store/src/project_authz.rs` `is_reserved_global` (a workspace `_profile` joins `default/_global`: on a server that distinguishes operators a write needs root or a `write` grant, creating it grants nothing); `ops.rs` `initial_access_mode` keeps `_profile` open | store `integration::profile` `shared_profiles_are_write_gated_for_database_users` (ungranted user refused for both shares; root and a write grant admitted; reads open); `server.rs` `a_workspace_profile_is_write_gated_and_read_open`; both fail with `_profile` dropped from the gate | STRONG |+| 1f | Event capture never lands in a profile project, and the sweep keeps them | `ai-memory-hooks/src/router.rs` project resolution refuses `ai_memory_core::profile::is_reserved_scope_project` (`_global`, `_profile`, `_profile.*`) from a directory or a marker override, falling back to the server default; `ops.rs` `sweep_hollow_projects` exempts `_profile` and `_profile.%` | `router.rs` `capture_is_never_attributed_to_a_profile_project` (override and directory spellings refused; ordinary `my_profile` control resolves), fails with the check narrowed to `_global`; store `integration::profile` `the_hollow_project_sweep_keeps_empty_profile_projects` | STRONG |+| 1g | The profile reaches only the sessions it is meant for: off by default on a multi-user server, suppressed by `[profile] consume = false` | `ai_memory_core::profile::ProfileSettings::effective_share` (`enabled = auto` is off once operators are distinguished); `router.rs` `render_requested_profile_digest`; `server.rs` `memory_query` drops `profile/` hits for a project whose stored `profile_consume` is off | `router.rs` `a_multi_user_server_has_no_profile_digest_by_default`, `profile_digest_honours_consume_once_per_session_and_the_server_switch`; `server.rs` `the_single_user_profile_lives_in_global_and_honours_consume` (fails with the consume filter removed); core `profile::tests::effective_share_matrix` | STRONG || 2 | Workspace isolation | same as #1; same-named project → distinct ids per workspace | `scope.rs` cross-workspace resolution rows; `multi_scope` dedup/validate | STRONG || 2b | Managed-workstream discovery stays checkout-local, including pagination | `ai-memory-workstream/src/repository.rs` `inspect_repository_fingerprints` shares the launch identity derivation without checkpoint scans; `ai-memory-cli/src/commands/resume.rs` `candidates_for_checkout` queries only the cwd, never registry links; the explicit `--all` walk (`candidates_across_checkouts`) lists each linked checkout through its own fingerprint-scoped request and applies `--workspace` before any request; `ai-memory-hooks/src/workstream.rs` `list_recent_workstreams` resolves an authorized explicit scope on every page; `ai-memory-store/src/workstream.rs` `list_recent` applies workspace/project/repository/worktree predicates before `LIMIT`/`OFFSET` | `resume.rs` `resume_lists_all_current_checkout_rows_not_registered_foreign_checkouts` (same scope/remote foreign checkout refused, 125 local rows visible), `empty_current_checkout_does_not_fall_back_to_the_registry`, `resume_all_walks_every_linked_checkout_and_honours_the_workspace_filter` (a foreign workspace filter sends no request; the default picker still ignores the registry); `workstream.rs` `recent_workstream_pages_reach_older_rows_without_crossing_checkout_or_scope` (foreign repo, worktree, project and workspace excluded on every page; 105 legitimate rows reach the client, huge offsets return nothing); store `recent_workstreams_are_checkout_local_and_include_linked_harnesses` (page two keeps native harness links); `repository.rs` `reports_origin_push_url_and_linked_worktree` verifies lightweight/full fingerprint parity and distinct worktree keys; CLI `resume_yolo_displays_picker_without_scanning_git_status` verifies listing skips status scans | STRONG || 3 | Multi-user auth ladder | `ai-memory-core/src/actor.rs` `AuthLevel::authorize`; `ai-memory-mcp/src/auth.rs` middleware; `admin.rs` `require_root_for_multiuser_admin` / `require_root`; `identity.rs` authorizes `NormalRead` behind the same machine bearer middleware as MCP; `serve.rs` mounts API-only and web+API protected routers behind `require_dual_auth` | `admin.rs` `multiuser_admin_routes_reject_db_user_tier` / `…reject_anonymous` / `create_user_as_user_tier_returns_403`; `auth.rs` unknown-bearer 401; `actor.rs` `skip_admission_chain_rejects_db_users`; `identity.rs` `identity_real_auth_isolates_users_root_and_revoked_keys`, `identity_anonymous_ignores_forged_headers_and_proxy_qualifies_oidc` (distinct users and root, invalid/revoked keys, forged headers, anonymous control); `serve.rs` `api_only_mode_keeps_data_authenticated_and_web_absent` (anonymous API read refused, authenticated control admitted, browser route absent; #986) | STRONG |diff --git a/docs/usage.md b/docs/usage.mdindex 6e67f3fe..0fe5d6e5 100644--- a/docs/usage.md+++ b/docs/usage.md@@ -608,12 +608,29 @@ facts, authorize disclosure or tool use, or override schema, evidence, andoutput rules. TTL-expired preference pages are ignored. When there is no activepage and no argument, ai-memory appends no preference block.-## Rules vs facts+## Rules, memory and the profile++The agent works from an ordered precedence; each level fills gaps in the ones+above it and never overrides them:++1. The user's current instructions in the conversation.+2. The repository's rules file: `CLAUDE.md` for Claude Code; for Codex, Devin+ CLI, OpenCode, OpenCode 2 beta, Cursor, Gemini CLI, Grok Build CLI, Kimi+ Code, Kiro CLI, and Command Code it is usually `AGENTS.md`.+3. The project's memory: its pages, `_rules/`, decisions and gotchas.+4. The cross-project profile: the user's usual choices from other projects+ (`docs/cross-project-profile.md`).++So a hard rule that must hold in a repository belongs in its rules file. Where+no hard rule exists, the agent relies on memory instead of asking again: the+project's own pages first, then the profile, which is what lets a new project+start with the user's usual choices. A preference that applies to every+project goes to the profile (`memory_write_page` with `scope: "profile"`), not+into each repository's rules file. Memory still never authorizes anything on+its own: it sets defaults, and the user and the rules file decide.Durable project rules belong in the agent's rules file, not only in the-wiki. For Claude Code that is `CLAUDE.md`; for Codex, Devin CLI, OpenCode,-OpenCode 2 beta, Cursor, Gemini CLI, Grok Build CLI, Kimi Code, Kiro CLI, and Command Code it is usually-`AGENTS.md`.+wiki.The consolidator classifies compiled observations as `decision`,`fact`, `rule`, or `gotcha`. Rule-tagged pages are routed todiff --git a/docs/users.md b/docs/users.mdindex 97eef6d1..83ee5e3f 100644--- a/docs/users.md+++ b/docs/users.md@@ -747,6 +747,12 @@ ones who should keep access; nothing is granted automatically.having created it first grants nothing. To let a user maintain team-widepreferences: `ai-memory user grant --user alice --project _global --levelwrite` (the scope must already exist; root creates it with its first write).+- **The cross-project profile** (`docs/cross-project-profile.md`) is off on a+ multi-user server until `[profile] enabled = true`. Then each user gets a+ private profile in a `restricted` project named `_profile.<user id>`, which+ only they (and root) can read or write; with `share = "workspace"` a+ workspace's `_profile` is shared and write-gated exactly like the global+ scope above.- **Gates entry, never rows.** Access decides which projects a user reaches;inside a project pages stay shared exactly as before (see below).- **Refusals are explicit.** A user outside a restricted project gets a 403