[GH-ISSUE #8408] [Feature]: Capability packages: let a package register a service only the Engine can read #8344

Closed
opened 2026-11-07 16:42:22 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8408

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

Packages share services through one registry: api.registerService(key, service) stores it, and any package reads it with runtime.services.get(key). Two kinds of key are already host-only: agent-runtime: and mari-actions: (HOST_ONLY_SERVICE_PREFIXES, capability-module-runtime.service.ts ~106). Every other key is open to every package.

Some services are meant only for the Engine. Long-Term Memory registers long-term-memory:runtime for the Engine's generation recall (services/generation/long-term-memory-runtime.ts ~12) and for profile restore (routes/backup.routes.ts ~1383). Because the lookup is open, any installed package can also take it and:

  • run recall for any chat id, bypassing the user's "Other Agents can read memories" switch, which only guards the separate long-term-memory:recall service;
  • call recordPromptAccepted and change what Long-Term Memory believes was sent;
  • hold Long-Term Memory's vault lock through withVaultMutation.

Proposed solution

A host-only flag on registration: api.registerService(key, service, { hostOnly: true }). The Engine's own getCapabilityService(key) still returns the service, while runtime.services.get(key) returns null for every package, including the owner. This is the same rule the two prefixes follow today. Older Engines ignore the third argument, so a package can pass it without a version check, and the Engine's existing reads keep the same key.

Minimal fix

  • packages/server/src/services/capability-packages/capability-service-registry.service.ts:
    • registerCapabilityService(key, service, options?: { hostOnly?: boolean }) records host-only keys in a Set beside the map. The cleanup removes the key from both, under the same identity check as today.
    • getCapabilityService is unchanged; add isHostOnlyCapabilityService(key).
    • resetCapabilityServices also clears the set.
  • packages/server/src/services/capability-packages/capability-module-runtime.service.ts:
    • the api.registerService type (~87) gains the optional third argument;
    • registerService (~399) passes the options through;
    • services.get (~165): return null when the key has a host-only prefix or isHostOnlyCapabilityService(key) is true.
  • packages/shared/src/types/capability-runtime.ts: the CapabilityServiceLookupHost.get doc comment (~29) adds "or for a service registered with hostOnly".
  • packages/shared/src/schemas/capability-package.schema.ts (~1487): a changelog line for the next Capability API minor and the supportedCapabilityApi bump (~1489).
  • No change to the Engine's readers of long-term-memory:runtime, hierarchical-maps:* or conversation-calls:*; they use getCapabilityService.

Regression, in scripts/regressions/capability-runtime-host-services.regression.ts next to the existing host-only loop (~146):

  1. A fixture package registers host-services-full:hidden with { hostOnly: true }:
    • getCapabilityService returns it;
    • reader.services.get and full.services.get both return null.
  2. The same package's key registered without the flag is still visible to the other package, as today.
  3. After the hidden service is released, the same key registered without the flag is visible, so the cleanup cleared the flag.

Alternatives considered

  • Add long-term-memory: keys to HOST_ONLY_SERVICE_PREFIXES. It names one package in the Engine, and it would also hide long-term-memory:recall, which other packages are meant to read.
  • A reserved key shape such as <id>:host:*. It would rename long-term-memory:runtime, so the Engine would have to read both names until every install updates. The flag keeps the key.
  • A manifest field listing host-only keys. It moves the same fact into package metadata and needs schema validation; the flag sits where the service is registered.

Additional context

  • Agents follow-up after this ships: Long-Term Memory passes { hostOnly: true } when it registers long-term-memory:runtime (server-entry.ts ~44). It needs no engine.min bump, because older Engines ignore the argument.
  • The hierarchical-maps:* and conversation-calls:* services are also read only by the Engine. Their owners can adopt the flag separately; this issue doesn't change them.
  • Out of scope, a separate gap: registerService checks key ownership only for the two host-only prefixes, so a package can register a key in another package's namespace. If it activates first, the Engine passes generation recall input (the chat messages) to that package, and the real owner's registration fails with "already registered". A rule that keys start with the package id would close it. It is not part of this issue because Engine fixtures register bare or mismatched keys (externals-probe, ${id}, readiness:success from package readiness-success), and packages outside the catalog may too.
  • This is a package permission surface: it changes what runtime.services.get returns to packages.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8408 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? Packages share services through one registry: `api.registerService(key, service)` stores it, and any package reads it with `runtime.services.get(key)`. Two kinds of key are already host-only: `agent-runtime:` and `mari-actions:` (`HOST_ONLY_SERVICE_PREFIXES`, `capability-module-runtime.service.ts` ~106). Every other key is open to every package. Some services are meant only for the Engine. Long-Term Memory registers `long-term-memory:runtime` for the Engine's generation recall (`services/generation/long-term-memory-runtime.ts` ~12) and for profile restore (`routes/backup.routes.ts` ~1383). Because the lookup is open, any installed package can also take it and: - run `recall` for any chat id, bypassing the user's "Other Agents can read memories" switch, which only guards the separate `long-term-memory:recall` service; - call `recordPromptAccepted` and change what Long-Term Memory believes was sent; - hold Long-Term Memory's vault lock through `withVaultMutation`. ## Proposed solution A host-only flag on registration: `api.registerService(key, service, { hostOnly: true })`. The Engine's own `getCapabilityService(key)` still returns the service, while `runtime.services.get(key)` returns `null` for every package, including the owner. This is the same rule the two prefixes follow today. Older Engines ignore the third argument, so a package can pass it without a version check, and the Engine's existing reads keep the same key. ### Minimal fix - `packages/server/src/services/capability-packages/capability-service-registry.service.ts`: - `registerCapabilityService(key, service, options?: { hostOnly?: boolean })` records host-only keys in a `Set` beside the map. The cleanup removes the key from both, under the same identity check as today. - `getCapabilityService` is unchanged; add `isHostOnlyCapabilityService(key)`. - `resetCapabilityServices` also clears the set. - `packages/server/src/services/capability-packages/capability-module-runtime.service.ts`: - the `api.registerService` type (~87) gains the optional third argument; - `registerService` (~399) passes the options through; - `services.get` (~165): return `null` when the key has a host-only prefix or `isHostOnlyCapabilityService(key)` is true. - `packages/shared/src/types/capability-runtime.ts`: the `CapabilityServiceLookupHost.get` doc comment (~29) adds "or for a service registered with `hostOnly`". - `packages/shared/src/schemas/capability-package.schema.ts` (~1487): a changelog line for the next Capability API minor and the `supportedCapabilityApi` bump (~1489). - No change to the Engine's readers of `long-term-memory:runtime`, `hierarchical-maps:*` or `conversation-calls:*`; they use `getCapabilityService`. Regression, in `scripts/regressions/capability-runtime-host-services.regression.ts` next to the existing host-only loop (~146): 1. A fixture package registers `host-services-full:hidden` with `{ hostOnly: true }`: - `getCapabilityService` returns it; - `reader.services.get` and `full.services.get` both return `null`. 2. The same package's key registered without the flag is still visible to the other package, as today. 3. After the hidden service is released, the same key registered without the flag is visible, so the cleanup cleared the flag. ## Alternatives considered - **Add `long-term-memory:` keys to `HOST_ONLY_SERVICE_PREFIXES`.** It names one package in the Engine, and it would also hide `long-term-memory:recall`, which other packages are meant to read. - **A reserved key shape such as `<id>:host:*`.** It would rename `long-term-memory:runtime`, so the Engine would have to read both names until every install updates. The flag keeps the key. - **A manifest field listing host-only keys.** It moves the same fact into package metadata and needs schema validation; the flag sits where the service is registered. ## Additional context - Agents follow-up after this ships: Long-Term Memory passes `{ hostOnly: true }` when it registers `long-term-memory:runtime` (`server-entry.ts` ~44). It needs no `engine.min` bump, because older Engines ignore the argument. - The `hierarchical-maps:*` and `conversation-calls:*` services are also read only by the Engine. Their owners can adopt the flag separately; this issue doesn't change them. - Out of scope, a separate gap: `registerService` checks key ownership only for the two host-only prefixes, so a package can register a key in another package's namespace. If it activates first, the Engine passes generation recall input (the chat messages) to that package, and the real owner's registration fails with "already registered". A rule that keys start with the package id would close it. It is not part of this issue because Engine fixtures register bare or mismatched keys (`externals-probe`, `${id}`, `readiness:success` from package `readiness-success`), and packages outside the catalog may too. - This is a package permission surface: it changes what `runtime.services.get` returns to packages. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8344
No description provided.