@remnic/core 9.3.692 → 9.3.693

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/access-boundary.d.ts +2 -2
  2. package/dist/access-boundary.js +3 -3
  3. package/dist/access-cli.js +57 -6
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +1 -1
  6. package/dist/access-http.js +6 -6
  7. package/dist/access-mcp.d.ts +3 -1
  8. package/dist/access-mcp.js +5 -5
  9. package/dist/access-operations.d.ts +8 -3
  10. package/dist/access-operations.js +6 -4
  11. package/dist/{access-service-DvApf9LZ.d.ts → access-service-DxCpgyVW.d.ts} +95 -1
  12. package/dist/access-service.d.ts +1 -1
  13. package/dist/access-service.js +2 -2
  14. package/dist/access-surface-catalog.d.ts +1 -1
  15. package/dist/access-surface-catalog.js +2 -0
  16. package/dist/access-surface-catalog.js.map +1 -1
  17. package/dist/{chunk-2EN5WZQB.js → chunk-5HGPDRQZ.js} +2 -2
  18. package/dist/chunk-5HGPDRQZ.js.map +1 -0
  19. package/dist/{chunk-W4MICQIZ.js → chunk-F7BVJ3IE.js} +2 -2
  20. package/dist/{chunk-7MOTEVAA.js → chunk-HRUULBBV.js} +3 -1
  21. package/dist/chunk-HRUULBBV.js.map +1 -0
  22. package/dist/{chunk-NEILAC3H.js → chunk-JNKH2XWQ.js} +35 -5
  23. package/dist/chunk-JNKH2XWQ.js.map +1 -0
  24. package/dist/{chunk-V56S3A23.js → chunk-MQTPUPLP.js} +295 -15
  25. package/dist/chunk-MQTPUPLP.js.map +1 -0
  26. package/dist/{chunk-DO7MDZMU.js → chunk-RHWFMBO5.js} +32 -5
  27. package/dist/chunk-RHWFMBO5.js.map +1 -0
  28. package/dist/{chunk-O4ZIV62T.js → chunk-THKNO6OX.js} +6 -5
  29. package/dist/{chunk-O4ZIV62T.js.map → chunk-THKNO6OX.js.map} +1 -1
  30. package/dist/{chunk-SEK4XIDN.js → chunk-WYB44HHV.js} +20 -6
  31. package/dist/chunk-WYB44HHV.js.map +1 -0
  32. package/dist/{cli-BjsY9Le7.d.ts → cli-DoQsv4ut.d.ts} +1 -1
  33. package/dist/cli.d.ts +2 -2
  34. package/dist/cli.js +7 -7
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +8 -8
  37. package/dist/mcp-memory-inspector-app.d.ts +1 -1
  38. package/dist/orchestrator.js +2 -2
  39. package/dist/schemas.d.ts +28 -28
  40. package/dist/transfer/types.d.ts +12 -12
  41. package/package.json +2 -2
  42. package/src/access-boundary.ts +2 -1
  43. package/src/access-cli.ts +65 -2
  44. package/src/access-http.ts +20 -0
  45. package/src/access-mcp.ts +29 -0
  46. package/src/access-operations.ts +46 -0
  47. package/src/access-service.ts +55 -0
  48. package/src/access-surface-catalog.test.ts +1 -1
  49. package/src/access-surface-catalog.ts +2 -0
  50. package/src/cli.ts +1 -0
  51. package/src/coding/coding-namespace.ts +1 -1
  52. package/src/coding/session-delta-surfaces.test.ts +383 -0
  53. package/src/coding/session-delta-surfaces.ts +325 -0
  54. package/src/coding/session-delta.test.ts +411 -0
  55. package/src/coding/session-delta.ts +442 -0
  56. package/dist/chunk-2EN5WZQB.js.map +0 -1
  57. package/dist/chunk-7MOTEVAA.js.map +0 -1
  58. package/dist/chunk-DO7MDZMU.js.map +0 -1
  59. package/dist/chunk-NEILAC3H.js.map +0 -1
  60. package/dist/chunk-SEK4XIDN.js.map +0 -1
  61. package/dist/chunk-V56S3A23.js.map +0 -1
  62. /package/dist/{chunk-W4MICQIZ.js.map → chunk-F7BVJ3IE.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import './storage.js';
2
2
  import './types-B1VHaf2w.js';
3
- export { C as CodingScopedWriteInput, l as ENGRAM_ACCESS_WRITE_SCHEMA_VERSION, m as EngramAccessActionConfidenceRequest, n as EngramAccessActionConfidenceResponse, o as EngramAccessBriefingRequest, p as EngramAccessBriefingResponse, q as EngramAccessCapsuleListResponse, r as EngramAccessDaySummaryRequest, s as EngramAccessEntityListResponse, t as EngramAccessEntityResponse, u as EngramAccessEntitySummary, v as EngramAccessHealthResponse, f as EngramAccessInputError, w as EngramAccessLcmCompactionFlushRequest, x as EngramAccessLcmCompactionFlushResponse, y as EngramAccessLcmCompactionRecordRequest, z as EngramAccessLcmCompactionRecordResponse, B as EngramAccessLcmSearchRequest, F as EngramAccessLcmSearchResponse, G as EngramAccessLcmStatusResponse, H as EngramAccessMaintenanceResponse, I as EngramAccessMemoryBrowseRequest, J as EngramAccessMemoryBrowseResponse, K as EngramAccessMemoryRecord, E as EngramAccessMemoryResponse, L as EngramAccessMemoryStoreRequest, M as EngramAccessMemorySummary, N as EngramAccessObserveMessage, O as EngramAccessObserveRequest, Q as EngramAccessObserveResponse, R as EngramAccessOfflineSyncApplyFileContentRequest, S as EngramAccessOfflineSyncApplyFileContentResponse, T as EngramAccessOfflineSyncApplyRequest, U as EngramAccessOfflineSyncApplyResponse, V as EngramAccessOfflineSyncFileContentRequest, W as EngramAccessOfflineSyncFileContentResponse, X as EngramAccessOfflineSyncFilesRequest, Y as EngramAccessOfflineSyncFilesResponse, Z as EngramAccessOfflineSyncSnapshotRequest, _ as EngramAccessOfflineSyncSnapshotResponse, $ as EngramAccessOfflineSyncSnapshotStreamResponse, a0 as EngramAccessQmdCollectionState, a1 as EngramAccessQmdHealthResponse, a2 as EngramAccessQualityResponse, a3 as EngramAccessRecallExplainRequest, a4 as EngramAccessRecallExplainResponse, a5 as EngramAccessRecallRequest, e as EngramAccessRecallResponse, a6 as EngramAccessReviewDispositionRequest, a7 as EngramAccessReviewDispositionResponse, a8 as EngramAccessReviewQueueResponse, a9 as EngramAccessScopeDebug, d as EngramAccessService, aa as EngramAccessSetCodingContextRequest, ab as EngramAccessSuggestionSubmitRequest, ac as EngramAccessTimelineResponse, ad as EngramAccessTrustZoneBrowseRequest, ae as EngramAccessTrustZoneBrowseResponse, af as EngramAccessTrustZoneDemoSeedRequest, ag as EngramAccessTrustZoneDemoSeedResponse, ah as EngramAccessTrustZonePromoteRequest, ai as EngramAccessTrustZonePromoteResponse, aj as EngramAccessTrustZoneRecordSummary, ak as EngramAccessTrustZoneStatusResponse, al as EngramAccessWriteEnvelope, c as EngramAccessWriteResponse, am as MemoryScopePlan, an as shapeMemorySummary } from './access-service-DvApf9LZ.js';
3
+ export { C as CodingScopedWriteInput, n as ENGRAM_ACCESS_WRITE_SCHEMA_VERSION, o as EngramAccessActionConfidenceRequest, p as EngramAccessActionConfidenceResponse, q as EngramAccessBriefingRequest, r as EngramAccessBriefingResponse, s as EngramAccessCapsuleListResponse, t as EngramAccessDaySummaryRequest, u as EngramAccessEntityListResponse, v as EngramAccessEntityResponse, w as EngramAccessEntitySummary, x as EngramAccessHealthResponse, h as EngramAccessInputError, y as EngramAccessLcmCompactionFlushRequest, z as EngramAccessLcmCompactionFlushResponse, B as EngramAccessLcmCompactionRecordRequest, F as EngramAccessLcmCompactionRecordResponse, G as EngramAccessLcmSearchRequest, H as EngramAccessLcmSearchResponse, I as EngramAccessLcmStatusResponse, J as EngramAccessMaintenanceResponse, K as EngramAccessMemoryBrowseRequest, L as EngramAccessMemoryBrowseResponse, M as EngramAccessMemoryRecord, E as EngramAccessMemoryResponse, N as EngramAccessMemoryStoreRequest, O as EngramAccessMemorySummary, Q as EngramAccessObserveMessage, R as EngramAccessObserveRequest, S as EngramAccessObserveResponse, T as EngramAccessOfflineSyncApplyFileContentRequest, U as EngramAccessOfflineSyncApplyFileContentResponse, V as EngramAccessOfflineSyncApplyRequest, W as EngramAccessOfflineSyncApplyResponse, X as EngramAccessOfflineSyncFileContentRequest, Y as EngramAccessOfflineSyncFileContentResponse, Z as EngramAccessOfflineSyncFilesRequest, _ as EngramAccessOfflineSyncFilesResponse, $ as EngramAccessOfflineSyncSnapshotRequest, a0 as EngramAccessOfflineSyncSnapshotResponse, a1 as EngramAccessOfflineSyncSnapshotStreamResponse, a2 as EngramAccessQmdCollectionState, a3 as EngramAccessQmdHealthResponse, a4 as EngramAccessQualityResponse, a5 as EngramAccessRecallExplainRequest, a6 as EngramAccessRecallExplainResponse, a7 as EngramAccessRecallRequest, g as EngramAccessRecallResponse, a8 as EngramAccessReviewDispositionRequest, a9 as EngramAccessReviewDispositionResponse, aa as EngramAccessReviewQueueResponse, ab as EngramAccessScopeDebug, f as EngramAccessService, ac as EngramAccessSetCodingContextRequest, ad as EngramAccessSuggestionSubmitRequest, ae as EngramAccessTimelineResponse, af as EngramAccessTrustZoneBrowseRequest, ag as EngramAccessTrustZoneBrowseResponse, ah as EngramAccessTrustZoneDemoSeedRequest, ai as EngramAccessTrustZoneDemoSeedResponse, aj as EngramAccessTrustZonePromoteRequest, ak as EngramAccessTrustZonePromoteResponse, al as EngramAccessTrustZoneRecordSummary, am as EngramAccessTrustZoneStatusResponse, an as EngramAccessWriteEnvelope, e as EngramAccessWriteResponse, ao as MemoryScopePlan, ap as shapeMemorySummary } from './access-service-DxCpgyVW.js';
4
4
  import './recall-explain-renderer.js';
5
5
  import './types-2NoBoRBM.js';
6
6
  import './recall-audit-anomaly.js';
@@ -3,7 +3,7 @@ import {
3
3
  EngramAccessInputError,
4
4
  EngramAccessService,
5
5
  shapeMemorySummary
6
- } from "./chunk-V56S3A23.js";
6
+ } from "./chunk-MQTPUPLP.js";
7
7
  import "./chunk-GDASG7NC.js";
8
8
  import "./chunk-GDB4J2H3.js";
9
9
  import "./chunk-ARV3AUOM.js";
@@ -11,7 +11,7 @@ import "./chunk-2D27ODNX.js";
11
11
  import "./chunk-SOBJ6NEY.js";
12
12
  import "./chunk-BT7NVCML.js";
13
13
  import "./chunk-H7XKCNR6.js";
14
- import "./chunk-7MOTEVAA.js";
14
+ import "./chunk-HRUULBBV.js";
15
15
  import "./chunk-RS25QOKZ.js";
16
16
  import "./chunk-JGSKJHF7.js";
17
17
  import "./chunk-FF4KLI5W.js";
@@ -1,6 +1,6 @@
1
1
  import { OperationName } from './access-boundary.js';
2
2
  import 'zod';
3
- import './access-service-DvApf9LZ.js';
3
+ import './access-service-DxCpgyVW.js';
4
4
  import './storage.js';
5
5
  import './page-versioning.js';
6
6
  import './consolidation-operator.js';
@@ -27,6 +27,7 @@ var MCP_TOOLS = [
27
27
  { tool: "memory_store", operation: "memory_store" },
28
28
  { tool: "coding_decision", operation: "coding_decision" },
29
29
  { tool: "coding_architecture", operation: "coding_architecture" },
30
+ { tool: "coding_delta", operation: "coding_delta" },
30
31
  { tool: "suggestion_submit", operation: null },
31
32
  { tool: "entity_get", operation: null },
32
33
  { tool: "review_queue_list", operation: null },
@@ -117,6 +118,7 @@ var HTTP_ROUTES = [
117
118
  { method: "POST", pathname: "/engram/v1/memories", operation: "memory_store" },
118
119
  { method: "POST", pathname: "/engram/v1/coding/decisions", operation: "coding_decision" },
119
120
  { method: "POST", pathname: "/engram/v1/coding/architecture", operation: "coding_architecture" },
121
+ { method: "POST", pathname: "/engram/v1/coding/delta", operation: "coding_delta" },
120
122
  { method: "POST", pathname: "/engram/v1/suggestions", operation: null },
121
123
  { method: "GET", pathname: "/engram/v1/memories", operation: null },
122
124
  { method: "GET", pathname: "/engram/v1/memories/:id", operation: "memory_get" },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/access-surface-catalog.ts"],"sourcesContent":["/**\n * Static inventory of every handler on the MCP and HTTP access surfaces, with\n * its migration status against the access boundary (issue #1525).\n *\n * The fitness test (`access-surface-catalog.test.ts`) walks this catalog,\n * checks each entry against the live registry, and counts unmigrated handlers.\n * The ratchet (`scripts/check-ratchets.mjs`) reads this file and counts\n * `operation: null` entries so the unmigrated count can only decrease.\n *\n * WHEN MIGRATING A HANDLER (follow-up PRs):\n * 1. Add the operation to `access-operations.ts` via `defineOperation`.\n * 2. Flip its entry here from `operation: null` to `operation: \"<name>\"`.\n * 3. Delete the surface-local validation the handler used to do.\n * 4. Run `node scripts/check-ratchets.mjs --update` to ratchet the count\n * down — the improvement is recorded in `scripts/ratchet-baseline.json`.\n *\n * WHEN ADDING A NEW HANDLER:\n * 1. Add the entry here with `operation: null` (the fitness test will fail\n * until you either migrate it or acknowledge it as unmigrated).\n * 2. Migrate it in the same PR if it carries user input — the boundary's\n * whole point is that no new handler bypasses it.\n */\n\nimport type { OperationName } from \"./access-boundary.js\";\n\n/**\n * One row per MCP tool, keyed by the canonical SHORT name (no `engram.`/\n * `remnic.` prefix — both aliases dispatch to the same operation). The name\n * MUST match the tool's short suffix as advertised by `tools/list`.\n */\nexport interface McpToolEntry {\n readonly tool: string;\n readonly operation: OperationName | null;\n}\n\n/**\n * One row per HTTP route that invokes an access-service method. Routes that\n * only serve static assets, SSE streams, or admin console HTML are excluded —\n * they don't carry user-validated request envelopes into the facade.\n */\nexport interface HttpRouteEntry {\n readonly method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n readonly pathname: string;\n readonly operation: OperationName | null;\n}\n\n// Each tool below corresponds 1:1 to an `engram.*` definition in\n// `EngramMcpServer.tools` (access-mcp.ts). The fitness test asserts the live\n// `tools/list` response matches this list by short name, so a new tool cannot\n// land without either migrating it or acknowledging the unmigrated count.\nexport const MCP_TOOLS: readonly McpToolEntry[] = [\n { tool: \"recall\", operation: null },\n { tool: \"recall_explain\", operation: null },\n { tool: \"set_coding_context\", operation: null },\n { tool: \"recall_tier_explain\", operation: null },\n { tool: \"recall_xray\", operation: null },\n { tool: \"wearables_status\", operation: null },\n { tool: \"wearables_sync\", operation: null },\n { tool: \"transcript_day\", operation: null },\n { tool: \"transcript_search\", operation: null },\n { tool: \"transcript_memories\", operation: null },\n { tool: \"action_confidence\", operation: null },\n { tool: \"chatgpt_memory_inspector\", operation: null },\n { tool: \"day_summary\", operation: null },\n { tool: \"capsule_export\", operation: null },\n { tool: \"capsule_import\", operation: null },\n { tool: \"capsule_list\", operation: null },\n { tool: \"memory_governance_run\", operation: null },\n { tool: \"procedure_mining_run\", operation: null },\n { tool: \"pattern_reinforcement_run\", operation: null },\n { tool: \"procedural_stats\", operation: null },\n { tool: \"memory_get\", operation: \"memory_get\" },\n { tool: \"memory_timeline\", operation: null },\n { tool: \"memory_store\", operation: \"memory_store\" },\n { tool: \"coding_decision\", operation: \"coding_decision\" },\n { tool: \"coding_architecture\", operation: \"coding_architecture\" },\n { tool: \"suggestion_submit\", operation: null },\n { tool: \"entity_get\", operation: null },\n { tool: \"review_queue_list\", operation: null },\n { tool: \"observe\", operation: null },\n { tool: \"lcm_search\", operation: null },\n { tool: \"lcm_compaction_flush\", operation: null },\n { tool: \"lcm_compaction_record\", operation: null },\n { tool: \"continuity_audit_generate\", operation: null },\n { tool: \"continuity_incident_open\", operation: null },\n { tool: \"continuity_incident_close\", operation: null },\n { tool: \"continuity_incident_list\", operation: null },\n { tool: \"continuity_loop_add_or_update\", operation: null },\n { tool: \"continuity_loop_review\", operation: null },\n { tool: \"identity_anchor_get\", operation: null },\n { tool: \"identity_anchor_update\", operation: null },\n { tool: \"memory_identity\", operation: null },\n { tool: \"work_task\", operation: null },\n { tool: \"work_project\", operation: null },\n { tool: \"work_board\", operation: null },\n { tool: \"shared_context_write_output\", operation: null },\n { tool: \"shared_feedback_record\", operation: null },\n { tool: \"shared_priorities_append\", operation: null },\n { tool: \"shared_context_cross_signals_run\", operation: null },\n { tool: \"shared_context_curate_daily\", operation: null },\n { tool: \"compounding_weekly_synthesize\", operation: null },\n { tool: \"compounding_promote_candidate\", operation: null },\n { tool: \"compression_guidelines_optimize\", operation: null },\n { tool: \"compression_guidelines_activate\", operation: null },\n { tool: \"memory_search\", operation: \"memory_search\" },\n { tool: \"memory_profile\", operation: null },\n { tool: \"memory_entities_list\", operation: null },\n { tool: \"memory_questions\", operation: null },\n { tool: \"memory_last_recall\", operation: null },\n { tool: \"memory_intent_debug\", operation: null },\n { tool: \"memory_qmd_debug\", operation: null },\n { tool: \"memory_graph_explain\", operation: null },\n { tool: \"graph_snapshot\", operation: null },\n { tool: \"memory_feedback\", operation: null },\n { tool: \"memory_promote\", operation: null },\n { tool: \"memory_outcome\", operation: null },\n { tool: \"memory_action_apply\", operation: null },\n { tool: \"context_checkpoint\", operation: null },\n { tool: \"briefing\", operation: null },\n { tool: \"review_list\", operation: null },\n { tool: \"review_resolve\", operation: null },\n { tool: \"contradiction_scan_run\", operation: null },\n { tool: \"memory_summarize_hourly\", operation: null },\n { tool: \"conversation_index_update\", operation: null },\n { tool: \"profiling_report\", operation: null },\n { tool: \"graph_edge_decay_run\", operation: null },\n { tool: \"live_connectors_run\", operation: null },\n { tool: \"peer_list\", operation: null },\n { tool: \"peer_get\", operation: null },\n { tool: \"peer_set\", operation: null },\n { tool: \"peer_delete\", operation: null },\n { tool: \"peer_profile_get\", operation: null },\n { tool: \"peer_forget\", operation: null },\n { tool: \"console_state\", operation: null },\n { tool: \"dreams_status\", operation: null },\n { tool: \"dreams_run\", operation: null },\n];\n\n// Each route below corresponds 1:1 to a service-invoking route branch in\n// `EngramAccessHttpServer.handle` (access-http.ts). Pathname patterns use\n// `:param` for path segments. The fitness test asserts each entry resolves\n// against the catalog so a new service route cannot land without either\n// migrating it or acknowledging the unmigrated count. Infrastructure probes\n// (health, adapters, the /mcp delegate, admin console, SSE-only endpoints)\n// carry no user request envelope and are intentionally excluded.\nexport const HTTP_ROUTES: readonly HttpRouteEntry[] = [\n { method: \"POST\", pathname: \"/engram/v1/recall\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/coding-context\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/capsules/export\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/capsules/import\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/offline-sync/snapshot\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/offline-sync/snapshot-stream\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/snapshot\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/files\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/file-content\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/apply-file-content\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/apply\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/recall/explain\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/action-confidence\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/recall/tier-explain\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/recall/xray\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/wearables/sync\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/transcript\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/transcripts/search\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/memories\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/observe\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/search\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/compaction/flush\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/compaction/record\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/lcm/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/memories\", operation: \"memory_store\" },\n { method: \"POST\", pathname: \"/engram/v1/coding/decisions\", operation: \"coding_decision\" },\n { method: \"POST\", pathname: \"/engram/v1/coding/architecture\", operation: \"coding_architecture\" },\n { method: \"POST\", pathname: \"/engram/v1/suggestions\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/memories\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/memories/:id\", operation: \"memory_get\" },\n { method: \"GET\", pathname: \"/engram/v1/memories/:id/timeline\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/entities\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/entities/:id\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review-queue\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/maintenance\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/quality\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/trust-zones/status\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/procedural/stats\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/trust-zones/records\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/review-disposition\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/trust-zones/promote\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/trust-zones/demo-seed\", operation: null },\n { method: \"POST\", pathname: \"/v1/citations/observed\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review/contradictions\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review/contradictions/:id\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/review/resolve\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/graph/snapshot\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/contradiction-scan\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/graph/events\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/console/state\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers/:id/profile\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"PUT\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"DELETE\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/dreams/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/dreams/run\", operation: null },\n];\n\n/**\n * Total unmigrated-handler count across both surfaces. The ratchet baseline\n * tracks this number; it may only decrease. `access-surface-catalog.test.ts`\n * recomputes it from the live catalog and asserts equality, so a catalog edit\n * without a baseline bump (or, ideally, a migration) fails the gate.\n */\nexport function countUnmigratedHandlers(): number {\n let count = 0;\n for (const entry of MCP_TOOLS) {\n if (entry.operation === null) count += 1;\n }\n for (const entry of HTTP_ROUTES) {\n if (entry.operation === null) count += 1;\n }\n return count;\n}\n"],"mappings":";;;AAkDO,IAAM,YAAqC;A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M,cAAc,KAAM,UAAS;AAAA,EACzC;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/access-surface-catalog.ts"],"sourcesContent":["/**\n * Static inventory of every handler on the MCP and HTTP access surfaces, with\n * its migration status against the access boundary (issue #1525).\n *\n * The fitness test (`access-surface-catalog.test.ts`) walks this catalog,\n * checks each entry against the live registry, and counts unmigrated handlers.\n * The ratchet (`scripts/check-ratchets.mjs`) reads this file and counts\n * `operation: null` entries so the unmigrated count can only decrease.\n *\n * WHEN MIGRATING A HANDLER (follow-up PRs):\n * 1. Add the operation to `access-operations.ts` via `defineOperation`.\n * 2. Flip its entry here from `operation: null` to `operation: \"<name>\"`.\n * 3. Delete the surface-local validation the handler used to do.\n * 4. Run `node scripts/check-ratchets.mjs --update` to ratchet the count\n * down — the improvement is recorded in `scripts/ratchet-baseline.json`.\n *\n * WHEN ADDING A NEW HANDLER:\n * 1. Add the entry here with `operation: null` (the fitness test will fail\n * until you either migrate it or acknowledge it as unmigrated).\n * 2. Migrate it in the same PR if it carries user input — the boundary's\n * whole point is that no new handler bypasses it.\n */\n\nimport type { OperationName } from \"./access-boundary.js\";\n\n/**\n * One row per MCP tool, keyed by the canonical SHORT name (no `engram.`/\n * `remnic.` prefix — both aliases dispatch to the same operation). The name\n * MUST match the tool's short suffix as advertised by `tools/list`.\n */\nexport interface McpToolEntry {\n readonly tool: string;\n readonly operation: OperationName | null;\n}\n\n/**\n * One row per HTTP route that invokes an access-service method. Routes that\n * only serve static assets, SSE streams, or admin console HTML are excluded —\n * they don't carry user-validated request envelopes into the facade.\n */\nexport interface HttpRouteEntry {\n readonly method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n readonly pathname: string;\n readonly operation: OperationName | null;\n}\n\n// Each tool below corresponds 1:1 to an `engram.*` definition in\n// `EngramMcpServer.tools` (access-mcp.ts). The fitness test asserts the live\n// `tools/list` response matches this list by short name, so a new tool cannot\n// land without either migrating it or acknowledging the unmigrated count.\nexport const MCP_TOOLS: readonly McpToolEntry[] = [\n { tool: \"recall\", operation: null },\n { tool: \"recall_explain\", operation: null },\n { tool: \"set_coding_context\", operation: null },\n { tool: \"recall_tier_explain\", operation: null },\n { tool: \"recall_xray\", operation: null },\n { tool: \"wearables_status\", operation: null },\n { tool: \"wearables_sync\", operation: null },\n { tool: \"transcript_day\", operation: null },\n { tool: \"transcript_search\", operation: null },\n { tool: \"transcript_memories\", operation: null },\n { tool: \"action_confidence\", operation: null },\n { tool: \"chatgpt_memory_inspector\", operation: null },\n { tool: \"day_summary\", operation: null },\n { tool: \"capsule_export\", operation: null },\n { tool: \"capsule_import\", operation: null },\n { tool: \"capsule_list\", operation: null },\n { tool: \"memory_governance_run\", operation: null },\n { tool: \"procedure_mining_run\", operation: null },\n { tool: \"pattern_reinforcement_run\", operation: null },\n { tool: \"procedural_stats\", operation: null },\n { tool: \"memory_get\", operation: \"memory_get\" },\n { tool: \"memory_timeline\", operation: null },\n { tool: \"memory_store\", operation: \"memory_store\" },\n { tool: \"coding_decision\", operation: \"coding_decision\" },\n { tool: \"coding_architecture\", operation: \"coding_architecture\" },\n { tool: \"coding_delta\", operation: \"coding_delta\" },\n { tool: \"suggestion_submit\", operation: null },\n { tool: \"entity_get\", operation: null },\n { tool: \"review_queue_list\", operation: null },\n { tool: \"observe\", operation: null },\n { tool: \"lcm_search\", operation: null },\n { tool: \"lcm_compaction_flush\", operation: null },\n { tool: \"lcm_compaction_record\", operation: null },\n { tool: \"continuity_audit_generate\", operation: null },\n { tool: \"continuity_incident_open\", operation: null },\n { tool: \"continuity_incident_close\", operation: null },\n { tool: \"continuity_incident_list\", operation: null },\n { tool: \"continuity_loop_add_or_update\", operation: null },\n { tool: \"continuity_loop_review\", operation: null },\n { tool: \"identity_anchor_get\", operation: null },\n { tool: \"identity_anchor_update\", operation: null },\n { tool: \"memory_identity\", operation: null },\n { tool: \"work_task\", operation: null },\n { tool: \"work_project\", operation: null },\n { tool: \"work_board\", operation: null },\n { tool: \"shared_context_write_output\", operation: null },\n { tool: \"shared_feedback_record\", operation: null },\n { tool: \"shared_priorities_append\", operation: null },\n { tool: \"shared_context_cross_signals_run\", operation: null },\n { tool: \"shared_context_curate_daily\", operation: null },\n { tool: \"compounding_weekly_synthesize\", operation: null },\n { tool: \"compounding_promote_candidate\", operation: null },\n { tool: \"compression_guidelines_optimize\", operation: null },\n { tool: \"compression_guidelines_activate\", operation: null },\n { tool: \"memory_search\", operation: \"memory_search\" },\n { tool: \"memory_profile\", operation: null },\n { tool: \"memory_entities_list\", operation: null },\n { tool: \"memory_questions\", operation: null },\n { tool: \"memory_last_recall\", operation: null },\n { tool: \"memory_intent_debug\", operation: null },\n { tool: \"memory_qmd_debug\", operation: null },\n { tool: \"memory_graph_explain\", operation: null },\n { tool: \"graph_snapshot\", operation: null },\n { tool: \"memory_feedback\", operation: null },\n { tool: \"memory_promote\", operation: null },\n { tool: \"memory_outcome\", operation: null },\n { tool: \"memory_action_apply\", operation: null },\n { tool: \"context_checkpoint\", operation: null },\n { tool: \"briefing\", operation: null },\n { tool: \"review_list\", operation: null },\n { tool: \"review_resolve\", operation: null },\n { tool: \"contradiction_scan_run\", operation: null },\n { tool: \"memory_summarize_hourly\", operation: null },\n { tool: \"conversation_index_update\", operation: null },\n { tool: \"profiling_report\", operation: null },\n { tool: \"graph_edge_decay_run\", operation: null },\n { tool: \"live_connectors_run\", operation: null },\n { tool: \"peer_list\", operation: null },\n { tool: \"peer_get\", operation: null },\n { tool: \"peer_set\", operation: null },\n { tool: \"peer_delete\", operation: null },\n { tool: \"peer_profile_get\", operation: null },\n { tool: \"peer_forget\", operation: null },\n { tool: \"console_state\", operation: null },\n { tool: \"dreams_status\", operation: null },\n { tool: \"dreams_run\", operation: null },\n];\n\n// Each route below corresponds 1:1 to a service-invoking route branch in\n// `EngramAccessHttpServer.handle` (access-http.ts). Pathname patterns use\n// `:param` for path segments. The fitness test asserts each entry resolves\n// against the catalog so a new service route cannot land without either\n// migrating it or acknowledging the unmigrated count. Infrastructure probes\n// (health, adapters, the /mcp delegate, admin console, SSE-only endpoints)\n// carry no user request envelope and are intentionally excluded.\nexport const HTTP_ROUTES: readonly HttpRouteEntry[] = [\n { method: \"POST\", pathname: \"/engram/v1/recall\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/coding-context\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/capsules/export\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/capsules/import\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/offline-sync/snapshot\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/offline-sync/snapshot-stream\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/snapshot\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/files\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/file-content\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/apply-file-content\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/offline-sync/apply\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/recall/explain\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/action-confidence\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/recall/tier-explain\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/recall/xray\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/wearables/sync\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/transcript\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/transcripts/search\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/wearables/memories\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/observe\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/search\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/compaction/flush\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/lcm/compaction/record\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/lcm/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/memories\", operation: \"memory_store\" },\n { method: \"POST\", pathname: \"/engram/v1/coding/decisions\", operation: \"coding_decision\" },\n { method: \"POST\", pathname: \"/engram/v1/coding/architecture\", operation: \"coding_architecture\" },\n { method: \"POST\", pathname: \"/engram/v1/coding/delta\", operation: \"coding_delta\" },\n { method: \"POST\", pathname: \"/engram/v1/suggestions\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/memories\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/memories/:id\", operation: \"memory_get\" },\n { method: \"GET\", pathname: \"/engram/v1/memories/:id/timeline\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/entities\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/entities/:id\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review-queue\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/maintenance\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/quality\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/trust-zones/status\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/procedural/stats\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/trust-zones/records\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/review-disposition\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/trust-zones/promote\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/trust-zones/demo-seed\", operation: null },\n { method: \"POST\", pathname: \"/v1/citations/observed\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review/contradictions\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/review/contradictions/:id\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/review/resolve\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/graph/snapshot\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/contradiction-scan\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/graph/events\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/console/state\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers/:id/profile\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"PUT\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"DELETE\", pathname: \"/engram/v1/peers/:id\", operation: null },\n { method: \"GET\", pathname: \"/engram/v1/dreams/status\", operation: null },\n { method: \"POST\", pathname: \"/engram/v1/dreams/run\", operation: null },\n];\n\n/**\n * Total unmigrated-handler count across both surfaces. The ratchet baseline\n * tracks this number; it may only decrease. `access-surface-catalog.test.ts`\n * recomputes it from the live catalog and asserts equality, so a catalog edit\n * without a baseline bump (or, ideally, a migration) fails the gate.\n */\nexport function countUnmigratedHandlers(): number {\n let count = 0;\n for (const entry of MCP_TOOLS) {\n if (entry.operation === null) count += 1;\n }\n for (const entry of HTTP_ROUTES) {\n if (entry.operation === null) count += 1;\n }\n return count;\n}\n"],"mappings":";;;AAkDO,IAAM,YAAqC;AAAA,EAChD,EAAE,MAAM,UAAU,WAAW,KAAK;AAAA,EAClC,EAAE,MAAM,kBAAkB,WAAW,KAAK;AAAA,EAC1C,EAAE,MAAM,sBAAsB,WAAW,KAAK;AAAA,EAC9C,EAAE,MAAM,uBAAuB,WAAW,KAAK;AAAA,EAC/C,EAAE,MAAM,eAAe,WAAW,KAAK;AAAA,EACvC,EAAE,MAAM,oBAAoB,WAAW,KAAK;AAAA,EAC5C,EAAE,MAAM,kBAAkB,WAAW,KAAK;AAAA,EAC1C,EAAE,MAAM,kBAAkB,WAAW,KAAK;AAAA,EAC1C,EAAE,MAAM,qBAAqB,WAAW,KAAK;AAAA,EAC7C,EAAE,MAAM,uBAAuB,WAAW,KAAK;AAAA,EAC/C,EAAE,MAAM,qBAAqB,WAAW,KAAK;AAAA,EAC7C,EAAE,MAAM,4BAA4B,WAAW,KAAK;AAAA,EACpD,EAAE,MAAM,eAAe,WAAW,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AA6B,WAAW,KAAK;AAAA,EACxE,EAAE,QAAQ,QAAQ,UAAU,iCAAiC,WAAW,KAAK;AAAA,EAC7E,EAAE,QAAQ,OAAO,UAAU,2BAA2B,WAAW,KAAK;AAAA,EACtE,EAAE,QAAQ,OAAO,UAAU,4BAA4B,WAAW,KAAK;AAAA,EACvE,EAAE,QAAQ,OAAO,UAAU,oBAAoB,WAAW,KAAK;AAAA,EAC/D,EAAE,QAAQ,OAAO,UAAU,gCAAgC,WAAW,KAAK;AAAA,EAC3E,EAAE,QAAQ,OAAO,UAAU,wBAAwB,WAAW,KAAK;AAAA,EACnE,EAAE,QAAQ,OAAO,UAAU,wBAAwB,WAAW,KAAK;AAAA,EACnE,EAAE,QAAQ,UAAU,UAAU,wBAAwB,WAAW,KAAK;AAAA,EACtE,EAAE,QAAQ,OAAO,UAAU,4BAA4B,WAAW,KAAK;AAAA,EACvE,EAAE,QAAQ,QAAQ,UAAU,yBAAyB,WAAW,KAAK;AACvE;AAQO,SAAS,0BAAkC;AAChD,MAAI,QAAQ;AACZ,aAAW,SAAS,WAAW;AAC7B,QAAI,MAAM,cAAc,KAAM,UAAS;AAAA,EACzC;AACA,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc,KAAM,UAAS;AAAA,EACzC;AACA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EngramAccessInputError
3
- } from "./chunk-V56S3A23.js";
3
+ } from "./chunk-MQTPUPLP.js";
4
4
  import {
5
5
  expandTildePath
6
6
  } from "./chunk-EYIEWJNI.js";
@@ -104,4 +104,4 @@ export {
104
104
  listRegisteredOperations,
105
105
  __resetRegistryForTest
106
106
  };
107
- //# sourceMappingURL=chunk-2EN5WZQB.js.map
107
+ //# sourceMappingURL=chunk-5HGPDRQZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/access-boundary.ts"],"sourcesContent":["/**\n * Single input-validation and error boundary for the CLI/MCP/HTTP access\n * surfaces (issue #1525, epic #1520 Phase 1).\n *\n * Every operation that crosses the access-service facade passes through ONE\n * registry entry: a zod-validated request envelope, a shared error mapper,\n * and the \"reject invalid input and list valid options\" behavior that\n * CLAUDE.md rules 14/17/24/28/36/48/51 previously had to be re-implemented\n * per handler. The three surfaces become thin adapters — one operation\n * definition, three transports — so a validation fix lands everywhere at\n * once.\n *\n * Host-agnostic (rule 31): operation names carry no `openclaw-*`/`engram-*`\n * prefix. Session/namespace tenancy stays in the handler layer (resolved via\n * ScopePlan #1521); the boundary validates SHAPE, not tenancy.\n */\n\nimport { z } from \"zod\";\nimport { EngramAccessInputError, type EngramAccessService } from \"./access-service.js\";\nimport { expandTildePath } from \"./utils/path.js\";\n\n// ---------------------------------------------------------------------------\n// Canonical operation names — host-agnostic (rule 31)\n// ---------------------------------------------------------------------------\n\n/**\n * Canonical operation ids. One id is shared by the MCP tool, the HTTP route,\n * and the CLI command that expose the same operation. Add to this union as\n * each domain-group migration PR (memory ops → connectors → namespaces …)\n * lands; the fitness test in `access-surface-catalog.test.ts` treats the\n * registered set as the migration state.\n */\nexport type OperationName =\n | \"memory_get\"\n | \"memory_search\"\n | \"memory_store\"\n | \"coding_decision\"\n | \"coding_architecture\"\n | \"coding_delta\";\n\n// ---------------------------------------------------------------------------\n// Operation context — what every handler receives\n// ---------------------------------------------------------------------------\n\n/**\n * Per-call context. `service` is the facade the handler delegates to; the\n * boundary never reaches past it. `authenticatedPrincipal` is resolved by\n * the SURFACE (MCP header / HTTP identity / CLI flag) before the boundary\n * runs, so handlers stay principal-source-agnostic. `hooks` carries\n * transport-level callbacks (e.g. HTTP write-quota enforcement) that must\n * fire atomically inside the service call; surfaces that have no such hook\n * leave it undefined.\n */\nexport interface OperationContext {\n readonly service: EngramAccessService;\n readonly authenticatedPrincipal?: string;\n readonly hooks?: OperationHooks;\n}\n\n/**\n * Transport-level callbacks a handler forwards into the service call. Kept\n * narrow on purpose: the boundary owns validation + dispatch shape, not\n * transport policy. Add fields here only when a surface genuinely needs a\n * callback the service itself consumes.\n */\nexport interface OperationHooks {\n /** HTTP write-quota gate; throws to reject the write when exhausted. */\n readonly enforceWriteQuota?: () => void | Promise<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Operation spec + bound operation\n// ---------------------------------------------------------------------------\n\nexport interface OperationSpec<In, Out> {\n /** Canonical operation id; matches an {@link OperationName}. */\n readonly name: OperationName;\n readonly description: string;\n /** Zod schema validating the raw request envelope. */\n readonly schema: z.ZodType<In>;\n /** Handler invoked with the parsed input; throws EngramAccessInputError for domain faults. */\n readonly handler: (input: In, ctx: OperationContext) => Promise<Out>;\n}\n\nexport interface BoundOperation<In = unknown, Out = unknown> {\n readonly spec: OperationSpec<In, Out>;\n /** Validate the raw envelope, then invoke the handler. Throws EngramAccessInputError on any validation failure. */\n readonly run: (rawInput: unknown, ctx: OperationContext) => Promise<Out>;\n}\n\n// ---------------------------------------------------------------------------\n// Shared normalizers the boundary owns (rules 17, 28, 36, 48, 51)\n// ---------------------------------------------------------------------------\n\n/**\n * Coerce boolean-like strings at the edge (rule 36). Accepts actual booleans\n * and the string spellings clients send (\"true\"/\"false\"/\"1\"/\"0\"/\"yes\"/\"no\"/\n * \"on\"/\"off\", case-insensitive). Rejects anything else loudly — `Boolean(\"false\")`\n * would silently be `true`, which is the bug rule 36 exists to prevent.\n *\n * `undefined`/`null`/`\"\"` → `undefined`, so callers can keep treating an\n * absent flag as \"use the default\" without a separate presence check.\n */\nexport function coerceBooleanLike(value: unknown): boolean | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"boolean\") return value;\n if (typeof value === \"string\") {\n const lower = value.trim().toLowerCase();\n if (lower === \"true\" || lower === \"1\" || lower === \"yes\" || lower === \"on\") return true;\n if (lower === \"false\" || lower === \"0\" || lower === \"no\" || lower === \"off\") return false;\n }\n throw new EngramAccessInputError(\n `expected a boolean-like value (true|false|1|0|yes|no|on|off); got ${JSON.stringify(value)}`,\n );\n}\n\n/**\n * Coerce + validate a positive integer from a numeric string or number\n * (rule 28). Loosely-typed MCP/CLI clients send `\"5\"`; `typeof saved === \"number\"`\n * on read-back would reject it later, so we coerce at the edge and reject\n * booleans/objects loudly (`Number(true) === 1` would silently pass otherwise).\n *\n * `undefined`/`null`/`\"\"` → `undefined`.\n */\nexport function coercePositiveInteger(value: unknown, label: string): number | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value) || value <= 0 || !Number.isInteger(value)) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n return value;\n }\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n if (!/^[+-]?\\d+$/.test(trimmed)) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n const parsed = Number(trimmed);\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n }\n return parsed;\n }\n throw new EngramAccessInputError(`${label} expects a positive integer; got ${JSON.stringify(value)}`);\n}\n\n/**\n * Expand `~` in a path-shaped input (rule 17). Node `fs` does NOT expand `~`;\n * ad-hoc regex drifts. `undefined`/`null`/`\"\"` → `undefined`.\n */\nexport function normalizeOptionalPath(value: unknown): string | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value !== \"string\") {\n throw new EngramAccessInputError(`expected a path string; got ${JSON.stringify(value)}`);\n }\n return expandTildePath(value);\n}\n\n// ---------------------------------------------------------------------------\n// Error formatting — rule 51: list valid options, never silently default\n// ---------------------------------------------------------------------------\n\n/**\n * Turn a zod failure into an {@link EngramAccessInputError} whose message\n * names the offending field and — for enum/union issues — lists the valid\n * options, so the caller can correct rather than guess (rule 51).\n */\nexport function formatZodIssues(error: z.ZodError): string {\n const parts: string[] = [];\n for (const issue of error.issues) {\n const path = issue.path.length > 0 ? issue.path.join(\".\") : \"(root)\";\n const options = enumOptionsFromIssue(issue);\n const suffix = options ? `. Valid: ${options.join(\", \")}` : \"\";\n parts.push(`${path}: ${issue.message}${suffix}`);\n }\n return parts.length > 0\n ? `request validation failed: ${parts.join(\"; \")}`\n : \"request validation failed\";\n}\n\nfunction enumOptionsFromIssue(issue: z.ZodIssue): readonly string[] | undefined {\n // zod exposes accepted enum values on the issue for ZodEnum / ZodNativeEnum\n // and on the options of invalid_union discriminators. Reading them here\n // keeps \"list valid options\" in ONE place rather than per handler.\n if (issue.code === z.ZodIssueCode.invalid_enum_value) {\n const rawOptions = (issue as { options?: unknown }).options;\n if (Array.isArray(rawOptions)) {\n return rawOptions.map((opt) => String(opt));\n }\n }\n return undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Registry\n// ---------------------------------------------------------------------------\n\nconst registry = new Map<OperationName, BoundOperation>();\n\n/**\n * Register an operation. Throws if the name is already registered — duplicate\n * registration is a programming error, not a runtime input fault, so it throws\n * a plain Error (not the input-error class surfaces translate for clients).\n */\nexport function defineOperation<In, Out>(spec: OperationSpec<In, Out>): BoundOperation<In, Out> {\n if (registry.has(spec.name)) {\n throw new Error(`access-boundary: operation already registered: ${spec.name}`);\n }\n const bound: BoundOperation<In, Out> = {\n spec,\n run: async (rawInput, ctx) => {\n const parseResult = spec.schema.safeParse(rawInput);\n if (!parseResult.success) {\n throw new EngramAccessInputError(formatZodIssues(parseResult.error));\n }\n return spec.handler(parseResult.data, ctx);\n },\n };\n // Store under the canonical name; the cast is safe because In/Out are\n // erased at the registry boundary and recovered by callers via getOperation.\n registry.set(spec.name, bound as unknown as BoundOperation);\n return bound;\n}\n\n/** Look up a registered operation by canonical name. */\nexport function getOperation(name: OperationName): BoundOperation | undefined {\n return registry.get(name);\n}\n\n/** All registered operation names. */\nexport function listRegisteredOperations(): readonly OperationName[] {\n return [...registry.keys()];\n}\n\n/** Test-only: clear the registry so pilot definitions can be re-registered. */\nexport function __resetRegistryForTest(): void {\n registry.clear();\n}\n"],"mappings":";;;;;;;;AAiBA,SAAS,SAAS;AAsFX,SAAS,k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GAAG;AAAA,IAC3C;AAAA,EACF;AAGA,WAAS,IAAI,KAAK,MAAM,KAAkC;AAC1D,SAAO;AACT;AAGO,SAAS,aAAa,MAAiD;AAC5E,SAAO,SAAS,IAAI,IAAI;AAC1B;AAGO,SAAS,2BAAqD;AACnE,SAAO,CAAC,GAAG,SAAS,KAAK,CAAC;AAC5B;AAGO,SAAS,yBAA+B;AAC7C,WAAS,MAAM;AACjB;","names":[]}
@@ -311,7 +311,7 @@ import {
311
311
  lcmReadSessionIdsForNamespaces,
312
312
  resolveCodingNamespaceOverlay,
313
313
  resolveScopeProfilePlan
314
- } from "./chunk-7MOTEVAA.js";
314
+ } from "./chunk-HRUULBBV.js";
315
315
  import {
316
316
  listTrustZoneRecords,
317
317
  searchTrustZoneRecords
@@ -15248,4 +15248,4 @@ export {
15248
15248
  resolvePersistedMemoryRelativePath,
15249
15249
  Orchestrator
15250
15250
  };
15251
- //# sourceMappingURL=chunk-W4MICQIZ.js.map
15251
+ //# sourceMappingURL=chunk-F7BVJ3IE.js.map
@@ -632,9 +632,11 @@ function clusterByKey(items, keyFn) {
632
632
  }
633
633
 
634
634
  export {
635
+ defaultGitInvoker,
635
636
  stableHash,
636
637
  normalizeOriginUrl,
637
638
  resolveGitContext,
639
+ sanitizeFragment,
638
640
  projectNamespaceName,
639
641
  projectTagProjectId,
640
642
  combineNamespaces,
@@ -647,4 +649,4 @@ export {
647
649
  resolveScopeProfilePlan,
648
650
  expandScopeProfileReadNamespaces
649
651
  };
650
- //# sourceMappingURL=chunk-7MOTEVAA.js.map
652
+ //# sourceMappingURL=chunk-HRUULBBV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/coding/git-context.ts","../src/coding/coding-namespace.ts","../src/namespaces/scope-profiles.ts","../src/procedural/reinforcement-core.ts"],"sourcesContent":["/**\n * GitContextResolver — pure module for detecting the git project + branch\n * a session is operating in.\n *\n * Introduced by issue #569 (coding-agent project/branch-scoped namespaces).\n *\n * This module is deliberately pure:\n * - no orchestrator references\n * - no config side-effects\n * - no namespace wiring\n *\n * Downstream slices (PR 2+ of #569) wire `resolveGitContext` into the\n * `NamespaceResolver` / `Orchestrator` so that memories are scoped to a\n * detected project / branch without leaking across repos.\n *\n * CLAUDE.md rule 17 (expand `~`): the `rootPath` returned here is always an\n * absolute, tilde-expanded path. Callers must not re-expand.\n *\n * CLAUDE.md rule 51 (reject invalid input): `cwd` must be an absolute path\n * and must exist. `resolveGitContext` returns `null` — rather than throwing —\n * when the directory is not inside a git worktree, because being outside a\n * repo is a normal runtime state (e.g. agent opened in a scratch dir).\n */\nimport path from \"node:path\";\n\nimport { expandTildePath } from \"../utils/path.js\";\nimport { launchProcessSync } from \"../runtime/child-process.js\";\n\n// Re-export so existing callers / tests that imported `expandTildePath` from\n// this module keep working. CLAUDE.md #17 requires consistent `~` expansion\n// across every user-facing path input; the canonical implementation now\n// lives in `utils/path.ts`.\nexport { expandTildePath };\n\n// ──────────────────────────────────────────────────────────────────────────\n// Public types\n// ──────────────────────────────────────────────────────────────────────────\n\nexport interface GitContext {\n /**\n * Stable identifier for the project. Derived from `git remote get-url origin`\n * when an origin remote is configured, otherwise from the repo root path.\n *\n * Formatted as `origin:<hex>` or `root:<hex>` so that the source is visible\n * to operators (see `remnic doctor`, issue #569 acceptance criteria).\n */\n projectId: string;\n /**\n * Current branch, e.g. `main`, `feat/foo`. `null` only in detached-HEAD\n * state (e.g. rebase in progress). Callers should treat `null` as \"no\n * branch-scope overlay applies\" without erroring.\n */\n branch: string | null;\n /**\n * Absolute path to the repository root (the directory containing `.git`).\n * Tilde-expanded per CLAUDE.md #17.\n */\n rootPath: string;\n /**\n * Best-effort default branch (usually `main` or `master`). Derived from the\n * `refs/remotes/origin/HEAD` symbolic ref. `null` when not available (e.g.\n * fresh clone without a default branch symref, or no origin remote).\n */\n defaultBranch: string | null;\n}\n\n/**\n * Injectable git-invocation surface. Only the commands `resolveGitContext`\n * actually needs are exposed. Tests inject a mock implementation to avoid\n * spawning a real git process.\n */\nexport interface GitInvoker {\n /**\n * Run `git <args>` with `cwd` as the working directory. Must return\n * `{ stdout, exitCode }` with `stdout` trimmed by the caller as needed.\n * Implementations should NOT throw for non-zero exit codes — they should\n * return the exit code so the resolver can decide how to recover.\n */\n (cwd: string, args: string[]): { stdout: string; exitCode: number };\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Default git invoker — spawns real `git` via the shared child-process helper\n// ──────────────────────────────────────────────────────────────────────────\n\nconst DEFAULT_GIT_TIMEOUT_MS = 2_000;\n\nexport function defaultGitInvoker(): GitInvoker {\n return (cwd: string, args: string[]) => {\n const result = launchProcessSync(\"git\", args, {\n cwd,\n encoding: \"utf-8\",\n timeout: DEFAULT_GIT_TIMEOUT_MS,\n shell: false,\n });\n if (result.error) {\n // Spawn failure (git not on PATH, timeout, etc.). Surface as non-zero.\n return { stdout: \"\", exitCode: 127 };\n }\n return {\n stdout: typeof result.stdout === \"string\" ? result.stdout : \"\",\n exitCode: typeof result.status === \"number\" ? result.status : 1,\n };\n };\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Stable hashing\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Non-cryptographic stable hash. Used only to derive a deterministic\n * `projectId` from either the origin URL or the root path. The hash does not\n * need to be collision-resistant against adversarial input — it is purely a\n * namespace discriminator.\n *\n * Uses FNV-1a 32-bit so we don't pull in `node:crypto` for a simple bucket\n * key. Output is lowercase hex, zero-padded to 8 characters.\n */\nexport function stableHash(input: string): string {\n let hash = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n hash ^= input.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, \"0\");\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Origin URL normalization\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Normalize a git remote URL so that equivalent SSH / HTTPS forms of the\n * same repo produce the same `projectId`. Handles:\n * - `git@github.com:foo/bar.git` → `github.com/foo/bar`\n * - `https://github.com/foo/bar` → `github.com/foo/bar`\n * - `https://github.com/foo/bar.git` → `github.com/foo/bar`\n * - `ssh://git@github.com/foo/bar` → `github.com/foo/bar`\n * - `ssh://git@github.com:2222/foo/bar` → `github.com/foo/bar` (port stripped)\n *\n * Case-insensitive (remote hostnames and most repo paths on major forges are\n * case-insensitive in practice).\n */\nexport function normalizeOriginUrl(rawUrl: string): string {\n let url = rawUrl.trim();\n if (!url) return \"\";\n\n // Strip trailing `.git` case-insensitively — the whole result is\n // lowercased at the end, so `.GIT` / `.Git` must be treated the same as\n // `.git`. Previously the `.endsWith(\".git\")` check let `.GIT` leak\n // through and appear in the output.\n if (/\\.git$/i.test(url)) url = url.slice(0, -4);\n\n // Windows drive-letter local path (e.g. `C:/repos/app`): detect here\n // so the scp matcher below can accept single-character SSH host aliases\n // (`h:foo/bar` from `.ssh/config`). A drive letter is exactly one ASCII\n // letter followed by `:/` or `:\\`; SSH aliases never have a slash\n // immediately after the colon.\n if (/^[A-Za-z]:[\\\\/]/.test(url)) {\n return url.toLowerCase();\n }\n\n // Protocol-prefixed: ssh://, https://, http://, git://, file://\n // Must be tried FIRST so that scp-style detection below doesn't\n // incorrectly swallow an ssh:// URL that happens to contain `:port/`.\n //\n // Matches:\n // 1: host — bracketed IPv6 `[2001:db8::1]`, plain host with no `:` / `/`,\n // OR empty (for `file:///path` which has no host component).\n // 2: port (optional) — preserved in the output so two repos on the same\n // host under different ports get distinct project namespaces.\n // Losing the port risked false-coalescing separate repos on custom\n // SSH mesh setups.\n // 3: path (optional)\n const protoMatch =\n /^[a-z][a-z0-9+.-]*:\\/\\/(?:[^@/]+@)?(\\[[^\\]]+\\]|[^/:]*)(?::(\\d+))?(\\/.*)?$/i.exec(url);\n if (protoMatch) {\n let host = protoMatch[1] ?? \"\";\n // Detect IPv6 via the bracketed input form BEFORE stripping brackets,\n // so that when we later re-attach a port we can preserve the\n // `[host]:port` boundary. Without the brackets, `host:2222` is\n // ambiguous with a longer bare IPv6 address like `2001:db8::1:2222`.\n const wasBracketed =\n host.startsWith(\"[\") && host.endsWith(\"]\");\n if (wasBracketed) host = host.slice(1, -1);\n const port = protoMatch[2];\n const repoPath = (protoMatch[3] ?? \"\").replace(/^\\/+/, \"\");\n const hostPort = port\n ? wasBracketed\n ? `[${host}]:${port}`\n : `${host}:${port}`\n : host;\n // For protocols without a host component (file:///path), fall back to\n // a stable prefix so distinct local paths don't collapse to \"/path\".\n const prefix = hostPort.length > 0 ? hostPort : \"localhost\";\n return `${prefix}/${repoPath}`.toLowerCase();\n }\n\n // scp-like syntax: [user@]host:path. Protocol-prefixed URLs (`scheme://`)\n // are handled above, so the scp branch below guards against them: a\n // matched `host` of `scheme` followed by a path starting with `//` is\n // a protocol URL that fell through and must NOT be parsed here.\n // `user@` is optional — git also accepts userless scp forms like\n // `host:org/repo`. Valid scp paths may start with digits (e.g.\n // `git@host:123/repo.git`), so no numeric guard is needed: port-bearing\n // URLs have the `://` prefix and match the protocol branch above before\n // reaching here.\n //\n // Windows drive letters were filtered above, so single-character SSH\n // host aliases (`h:foo/bar`) are accepted here.\n //\n // Bracketed IPv6 (`[2001:db8::1]`) is supported: the host alternative\n // matches the bracketed literal up to `]` without splitting on internal\n // `:`. Brackets are stripped in the normalised form so the scp and\n // `ssh://` forms of the same IPv6 remote produce identical projectIds.\n const scpMatch =\n /^(?:([^@\\s/]+)@)?(\\[[^\\]]+\\]|[^:@\\s/]+):(.+)$/.exec(url);\n if (scpMatch) {\n let host = scpMatch[2] ?? \"\";\n if (host.startsWith(\"[\") && host.endsWith(\"]\")) host = host.slice(1, -1);\n const repoPath = scpMatch[3] ?? \"\";\n // Reject protocol-like leftovers (e.g. `file:///path` where the scp\n // regex greedily matched `file` as host and `///path` as path).\n if (repoPath.startsWith(\"//\")) {\n return url.toLowerCase();\n }\n return `${host}/${repoPath.replace(/^\\/+/, \"\")}`.toLowerCase();\n }\n\n // Fallback: use raw lowercased\n return url.toLowerCase();\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Resolver\n// ──────────────────────────────────────────────────────────────────────────\n\nexport interface ResolveGitContextOptions {\n /** Inject a git invoker (tests). Defaults to spawning real `git`. */\n invoker?: GitInvoker;\n}\n\n/**\n * Detect the git project + branch for `cwd`.\n *\n * Returns `null` when:\n * - `cwd` is not an absolute path (invalid input, CLAUDE.md #51)\n * - `cwd` is not inside a git worktree\n * - `git` is not available on PATH\n *\n * Never throws.\n */\nexport async function resolveGitContext(\n cwd: string,\n options: ResolveGitContextOptions = {},\n): Promise<GitContext | null> {\n // Wrap the whole body so the documented \"Never throws\" contract is\n // enforced. Possible throw sites include:\n // - `expandTildePath` → `resolveHomeDir()` → `os.homedir()` when HOME\n // is unset (e.g. minimal containers)\n // - a custom `options.invoker` that raises instead of returning a\n // non-zero exitCode\n // - any future helper added to this chain\n // All of those map to \"not in a repo\" / `null`.\n try {\n // Validate input: must be a non-empty string.\n if (typeof cwd !== \"string\" || cwd.length === 0) return null;\n\n // Expand `~` per CLAUDE.md #17, then require absolute path.\n const expanded = expandTildePath(cwd);\n if (!path.isAbsolute(expanded)) return null;\n\n const invoker = options.invoker ?? defaultGitInvoker();\n\n // 1. Locate the repo root.\n const topLevel = invoker(expanded, [\"rev-parse\", \"--show-toplevel\"]);\n if (topLevel.exitCode !== 0) return null;\n const rootPath = topLevel.stdout.trim();\n if (!rootPath) return null;\n\n // 2. Current branch. `--abbrev-ref HEAD` returns `HEAD` in detached\n // state, which we normalize to `null`. On a fresh `git init` the\n // HEAD ref is unborn and `--abbrev-ref HEAD` fails, but\n // `symbolic-ref HEAD` still returns the target branch. Fall back\n // so newly-initialized repos get a sensible branch name.\n const branchResult = invoker(rootPath, [\"rev-parse\", \"--abbrev-ref\", \"HEAD\"]);\n let branch: string | null = null;\n if (branchResult.exitCode === 0) {\n const raw = branchResult.stdout.trim();\n branch = raw && raw !== \"HEAD\" ? raw : null;\n } else {\n const unbornRef = invoker(rootPath, [\"symbolic-ref\", \"--quiet\", \"HEAD\"]);\n if (unbornRef.exitCode === 0) {\n const raw = unbornRef.stdout.trim();\n const prefix = \"refs/heads/\";\n if (raw.startsWith(prefix)) {\n const candidate = raw.slice(prefix.length);\n if (candidate) branch = candidate;\n }\n }\n }\n\n // 3. Origin URL — optional. Used to derive a stable `projectId`.\n const originResult = invoker(rootPath, [\"remote\", \"get-url\", \"origin\"]);\n let projectId: string;\n if (originResult.exitCode === 0) {\n const normalized = normalizeOriginUrl(originResult.stdout);\n projectId = normalized ? `origin:${stableHash(normalized)}` : `root:${stableHash(rootPath)}`;\n } else {\n projectId = `root:${stableHash(rootPath)}`;\n }\n\n // 4. Default branch — best effort.\n const headRef = invoker(rootPath, [\"symbolic-ref\", \"--quiet\", \"refs/remotes/origin/HEAD\"]);\n let defaultBranch: string | null = null;\n if (headRef.exitCode === 0) {\n const raw = headRef.stdout.trim();\n const prefix = \"refs/remotes/origin/\";\n if (raw.startsWith(prefix)) {\n const candidate = raw.slice(prefix.length);\n if (candidate) defaultBranch = candidate;\n }\n }\n\n return {\n projectId,\n branch,\n rootPath,\n defaultBranch,\n };\n } catch {\n // Never throws — any unexpected error falls back to \"not in a repo\".\n return null;\n }\n}\n","/**\n * Coding-agent namespace overlay (issue #569 PR 2 + PR 3).\n *\n * Given a `CodingContext` (from `resolveGitContext`) and a `CodingModeConfig`,\n * returns the namespace that recall + write paths should use — or `null` when\n * no overlay should apply (coding mode disabled, no context supplied, or\n * feature flags off).\n *\n * PR 2 ships the project overlay. PR 3 will add the branch overlay; the\n * function here already handles both flags so the schema / types / plumbing\n * don't have to change a second time when branch-scope lands.\n *\n * Pure function — no orchestrator, no config side-effects. Callers keep rule\n * 42 (read + write through same namespace layer) by consulting the same\n * function on both paths.\n */\n\nimport type { CodingContext, CodingModeConfig } from \"../types.js\";\nimport { stableHash } from \"./git-context.js\";\n\nexport interface CodingNamespaceOverlay {\n /**\n * Effective namespace to use for this session's memory operations. When\n * `branchScope` is on, takes the form `project:<id>/branch:<b>`; otherwise\n * `project:<id>`.\n */\n namespace: string;\n /**\n * Read fallbacks — additional namespaces a caller should include in recall\n * so that, for example, a branch-scoped session still sees project-level\n * memories that were written before the branch scope was enabled.\n *\n * Writes MUST go to `namespace` only; these are read-side only.\n *\n * Introduced to carry PR 3's branch→project fallback; PR 2 returns an empty\n * array here.\n */\n readFallbacks: string[];\n /**\n * `\"project\"` when only project scope applies, `\"branch\"` when branch scope\n * is also layered on. Used for diagnostics (`remnic doctor`) and logging.\n */\n scope: \"project\" | \"branch\";\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Sanitization\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Normalize a projectId / branch fragment so the resulting namespace passes\n * the router's `isSafeRouteNamespace` check (`[A-Za-z0-9._-]{1,64}`).\n *\n * Namespaces are used as filesystem directory names and must not contain\n * path separators (`/`, `\\`) or colons — so both `:` and `/` collapse to `-`.\n * The project-id format `origin:<8hex>` and branch names like `feat/x` both\n * flow through this helper before hitting the storage layer.\n *\n * NOT a security boundary — projectIds come from `resolveGitContext` (known\n * hex), and branch names come from local git. This defends against corrupt\n * input only.\n */\n/**\n * Single-pass sanitization — each input character is visited exactly once.\n * Rewriting as an explicit loop (instead of chained `replace()` calls with\n * greedy quantifiers) closes the polynomial-backtracking surface that\n * CodeQL flagged on patterns like `-+` and `^-+|-+$`.\n */\nexport function sanitizeFragment(input: string): string {\n if (typeof input !== \"string\") return \"\";\n const trimmed = input.trim().toLowerCase();\n let out = \"\";\n let prevIsDash = true; // suppress leading dashes\n for (let i = 0; i < trimmed.length; i += 1) {\n const c = trimmed[i]!;\n const cc = trimmed.charCodeAt(i);\n const isSafe =\n (cc >= 48 && cc <= 57) /* 0-9 */ ||\n (cc >= 97 && cc <= 122) /* a-z */ ||\n cc === 46 /* . */ ||\n cc === 95 /* _ */;\n if (isSafe) {\n out += c;\n prevIsDash = false;\n } else if (!prevIsDash) {\n out += \"-\";\n prevIsDash = true;\n }\n }\n // Strip a single trailing dash introduced by the final run of unsafe chars.\n if (out.endsWith(\"-\")) out = out.slice(0, -1);\n return out;\n}\n\n/**\n * Cap to the router's per-namespace upper bound.\n *\n * Raw truncation alone would collapse distinct long inputs that differ near\n * the end (e.g. two `feat/...` branches with different suffixes) into the\n * same namespace — silently mixing recall/write state across branches or\n * projects. When truncation is needed, we append a short deterministic\n * hash suffix (`-<8hex>`) derived from the FULL pre-truncated value so\n * collisions only happen under true hash collisions, not simple prefix\n * overlap.\n *\n * The tail is trimmed to leave room for the separator and 8-char hash and\n * any trailing `-` introduced by the slice is stripped so the final\n * character before `-<hash>` is always alphanumeric or `.`/`_`.\n */\nconst MAX_NAMESPACE_LEN = 64;\nconst HASH_SUFFIX_LEN = 9; // \"-\" + 8 hex chars\n\nfunction capLength(value: string): string {\n if (value.length <= MAX_NAMESPACE_LEN) return value;\n // Reuse the FNV-1a 32-bit hash from git-context — one canonical\n // implementation, one set of edge-case fixes. Uses Math.imul for\n // correct 32-bit wrap-around, which plain `*` would not guarantee\n // for the largest intermediate products.\n const hash = stableHash(value);\n // Trim trailing '-' with a linear, non-backtracking loop. A regex\n // like `-+$` is linear too, but an explicit loop keeps CodeQL happy\n // about polynomial backtracking warnings when several `\\-+` patterns\n // appear in the same module.\n let end = MAX_NAMESPACE_LEN - HASH_SUFFIX_LEN;\n while (end > 0 && value.charCodeAt(end - 1) === 45 /* '-' */) end -= 1;\n return `${value.slice(0, end)}-${hash}`;\n}\n\n/**\n * Produce the project-scope namespace name. Exported for tests and for\n * `remnic doctor` to render. Guaranteed to satisfy `isSafeRouteNamespace`:\n * no `/`, no `:`, lowercase only, length-capped to 64 chars.\n */\nexport function projectNamespaceName(projectId: string): string {\n const frag = sanitizeFragment(projectId);\n return capLength(`project-${frag || \"unknown\"}`);\n}\n\nexport function projectTagProjectId(projectTag: string): string {\n const trimmed = projectTag.trim();\n const frag = sanitizeFragment(trimmed);\n const disambig = trimmed.length > 0 && frag !== trimmed;\n const suffix = disambig ? `-${stableHash(trimmed)}` : \"\";\n return `tag:${frag || \"unknown\"}${suffix}`;\n}\n\n/**\n * Preserve case when sanitizing a principal-derived base namespace. The\n * router's `isSafeRouteNamespace` check accepts `[A-Za-z0-9._-]{1,64}`, so\n * upper-case characters in the principal name are safe and MUST be kept to\n * avoid colliding two otherwise-distinct principals (e.g. `Alice` vs\n * `alice`) into the same combined namespace.\n *\n * Otherwise identical to `sanitizeFragment`: single-pass, linear, no\n * polynomial-backtracking quantifiers, unsafe chars collapse to `-` with\n * leading/trailing dashes suppressed.\n */\nfunction sanitizeBaseFragment(input: string): string {\n if (typeof input !== \"string\") return \"\";\n const trimmed = input.trim();\n let out = \"\";\n let prevIsDash = true;\n for (let i = 0; i < trimmed.length; i += 1) {\n const c = trimmed[i]!;\n const cc = trimmed.charCodeAt(i);\n const isSafe =\n (cc >= 48 && cc <= 57) /* 0-9 */ ||\n (cc >= 65 && cc <= 90) /* A-Z */ ||\n (cc >= 97 && cc <= 122) /* a-z */ ||\n cc === 46 /* . */ ||\n cc === 95 /* _ */;\n if (isSafe) {\n out += c;\n prevIsDash = false;\n } else if (!prevIsDash) {\n out += \"-\";\n prevIsDash = true;\n }\n }\n if (out.endsWith(\"-\")) out = out.slice(0, -1);\n return out;\n}\n\n/**\n * Combine a principal-derived base namespace (e.g. `default`, `alice`) with a\n * coding-agent overlay namespace (e.g. `project-origin-abcd1234`). The result\n * is a single safe-route token that preserves principal isolation (CLAUDE.md\n * rule 42: read + write must resolve through the same namespace layer — and\n * here, through the same principal-scoped prefix) while layering project or\n * project/branch scope on top.\n *\n * Multiple principals working in the same repo thus get distinct namespaces:\n *\n * alice + project-origin-ab12 → alice-project-origin-ab12\n * bob + project-origin-ab12 → bob-project-origin-ab12\n * Alice + project-origin-ab12 → Alice-project-origin-ab12 (distinct)\n *\n * The base fragment preserves case so `Alice` and `alice` remain distinct;\n * the overlay fragment is still lowercase-sanitized because it derives from\n * deterministic, pre-lowercased git hashes.\n *\n * Output is re-capped through `capLength` so a very long base + overlay\n * combination still fits inside `isSafeRouteNamespace` (≤ 64 chars). The\n * deterministic hash suffix on truncation keeps distinct inputs distinct.\n */\nexport function combineNamespaces(base: string, overlay: string): string {\n const baseFrag = sanitizeBaseFragment(base);\n const overlayFrag = sanitizeFragment(overlay);\n if (!baseFrag) return capLength(overlayFrag || \"unknown\");\n if (!overlayFrag) return capLength(baseFrag);\n return capLength(`${baseFrag}-${overlayFrag}`);\n}\n\n/**\n * Produce the branch-scope namespace name. Format:\n * `project-<id>-branch-<name>[-<hash>]`. Uses `-` as the structural separator\n * rather than `/` or `:` so the result is a single safe route-namespace\n * token that can be used directly as a filesystem directory.\n *\n * Two failure modes must not collapse distinct branches to one namespace:\n *\n * 1. Sanitization is lossy (`feat/x` and `feat-x` both sanitize to\n * `feat-x`; `Feature` and `feature` both sanitize to `feature`). When\n * sanitization rewrote any character, we append a short hash of the\n * RAW branch so distinct inputs stay distinct.\n * 2. Truncation is applied when the total exceeds 64 chars. In that\n * mode `capLength` appends its own hash of the full pre-truncated\n * value.\n *\n * Long branches that also sanitize may receive both kinds of hashes — that\n * is acceptable: the router only requires the result be unique and\n * deterministic, and the two hashes derive from different domains so they\n * don't conflict.\n */\nexport function branchNamespaceName(projectId: string, branch: string): string {\n const projectFrag = sanitizeFragment(projectId);\n const trimmedBranch = branch.trim();\n const branchFrag = sanitizeFragment(trimmedBranch);\n // Lossy-sanitization disambiguator: append hash of the raw (trimmed)\n // branch when sanitization actually changed the string. Preserves\n // distinctness across `feat/x` vs `feat-x` and `Feature` vs `feature`.\n // The comparison uses the raw trimmed value (NOT `.toLowerCase()`) so\n // case-only variants are treated as lossy and receive their own hash.\n // Empty / already-safe-lowercase inputs get no hash so the common case\n // stays readable.\n const disambig = trimmedBranch.length > 0 && branchFrag !== trimmedBranch;\n const base = `project-${projectFrag || \"unknown\"}-branch-${branchFrag || \"unknown\"}`;\n const suffixed = disambig ? `${base}-${stableHash(trimmedBranch)}` : base;\n return capLength(suffixed);\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Overlay resolver\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Compute the namespace overlay for a session.\n *\n * Returns `null` when no overlay applies — callers should then use their\n * existing `defaultNamespaceForPrincipal(...)` result unchanged. This keeps\n * CLAUDE.md #30 (escape hatch): setting `codingMode.projectScope: false`\n * exactly restores pre-#569 behaviour at every call site.\n *\n * @param codingContext — git context from the connector\n * @param config — coding mode flags (projectScope, branchScope, globalFallback)\n * @param defaultNamespace — retained for call-site compatibility; no longer\n * used. The global fallback is expressed as an empty-string sentinel in\n * `readFallbacks`, which `combineNamespaces(principal, \"\")` resolves to the\n * principal's own namespace at the call site.\n */\nexport function resolveCodingNamespaceOverlay(\n codingContext: CodingContext | null | undefined,\n config: Pick<CodingModeConfig, \"projectScope\" | \"branchScope\" | \"globalFallback\">,\n defaultNamespace?: string,\n): CodingNamespaceOverlay | null {\n // No context supplied (session isn't in a git repo, or connector didn't\n // attach one) → no overlay.\n if (!codingContext) return null;\n\n // Project scope disabled → no overlay at all. Branch scope depends on\n // project scope being on; there is no branch-only mode.\n if (!config.projectScope) return null;\n\n // Require a non-empty projectId — defensive.\n const projectId = typeof codingContext.projectId === \"string\" ? codingContext.projectId.trim() : \"\";\n if (!projectId) return null;\n\n const projectNs = projectNamespaceName(projectId);\n\n // Root/global namespace fallback: when `globalFallback` is true, include\n // the principal's self namespace in readFallbacks so cross-project knowledge\n // remains visible. CLAUDE.md #30: the gate is `globalFallback` — set to\n // false for strict project isolation.\n //\n // The fallback value is \"\" (empty string), NOT the defaultNamespace name.\n // The orchestrator passes each fallback through combineNamespaces(principal, fallback),\n // and combineNamespaces(base, \"\") returns base unchanged — yielding the\n // principal's own namespace. Using the actual namespace name (e.g., \"default\")\n // would produce \"default-default\" after combination, missing the target.\n const includeRoot = config.globalFallback === true;\n\n // Branch-scope layering (PR 3):\n // - only when config.branchScope is explicitly true\n // - only when we actually have a branch (null in detached HEAD)\n // - project namespace becomes a read fallback so project-level memories\n // remain visible from any branch (deliberate asymmetry — branch writes\n // don't leak up, but project reads leak down).\n // - when globalFallback is on, the root namespace is also appended so\n // globally useful memories surface in every branch.\n if (config.branchScope && typeof codingContext.branch === \"string\" && codingContext.branch.length > 0) {\n const branchNs = branchNamespaceName(projectId, codingContext.branch);\n const fallbacks = [projectNs];\n if (includeRoot) fallbacks.push(\"\");\n return {\n namespace: branchNs,\n readFallbacks: fallbacks,\n scope: \"branch\",\n };\n }\n\n return {\n namespace: projectNs,\n readFallbacks: includeRoot ? [\"\"] : [],\n scope: \"project\",\n };\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Diagnostics (issue #569 PR 3 + PR 8)\n// ──────────────────────────────────────────────────────────────────────────\n\nexport interface CodingScopeDescription {\n /** \"none\" when no overlay is active; otherwise the resolved scope level. */\n scope: \"none\" | \"project\" | \"branch\";\n /** Project id (raw, not sanitized) when a context is attached. */\n projectId: string | null;\n /** Branch name (raw, not sanitized) when available. */\n branch: string | null;\n /** Effective namespace writes route to. `null` when no overlay applies. */\n effectiveNamespace: string | null;\n /** Read fallbacks included in recall (non-empty only when branch-scope is on). */\n readFallbacks: string[];\n /**\n * Why no overlay applies, when `scope === \"none\"`. One of:\n * - `\"no-context\"` — connector didn't attach a CodingContext\n * - `\"disabled\"` — codingMode.projectScope is false\n * - `\"empty-project\"` — codingContext.projectId was empty/whitespace\n */\n disabledReason: \"no-context\" | \"disabled\" | \"empty-project\" | null;\n}\n\n/**\n * Human-readable description of the coding-agent scope that currently applies\n * for a session. Consumed by `remnic doctor` (PR 8) and by logs to surface\n * why recall routes where it does.\n *\n * Pure — callers pass the coding context + config they already have.\n */\nexport function describeCodingScope(\n codingContext: CodingContext | null | undefined,\n config: Pick<CodingModeConfig, \"projectScope\" | \"branchScope\" | \"globalFallback\">,\n defaultNamespace?: string,\n): CodingScopeDescription {\n const projectId = codingContext?.projectId ?? null;\n const branch = codingContext?.branch ?? null;\n\n if (!codingContext) {\n return {\n scope: \"none\",\n projectId: null,\n branch: null,\n effectiveNamespace: null,\n readFallbacks: [],\n disabledReason: \"no-context\",\n };\n }\n if (!config.projectScope) {\n return {\n scope: \"none\",\n projectId,\n branch,\n effectiveNamespace: null,\n readFallbacks: [],\n disabledReason: \"disabled\",\n };\n }\n const trimmedId = typeof projectId === \"string\" ? projectId.trim() : \"\";\n if (!trimmedId) {\n return {\n scope: \"none\",\n projectId,\n branch,\n effectiveNamespace: null,\n readFallbacks: [],\n disabledReason: \"empty-project\",\n };\n }\n\n const overlay = resolveCodingNamespaceOverlay(codingContext, config, defaultNamespace);\n // Unreachable in practice given the guards above, but keep the return\n // shape consistent if the resolver grows new null branches later.\n if (!overlay) {\n return {\n scope: \"none\",\n projectId,\n branch,\n effectiveNamespace: null,\n readFallbacks: [],\n disabledReason: \"disabled\",\n };\n }\n return {\n scope: overlay.scope,\n projectId,\n branch,\n effectiveNamespace: overlay.namespace,\n readFallbacks: overlay.readFallbacks,\n disabledReason: null,\n };\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// LCM session-key namespacing (#1495)\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Reserved structural sentinel for the namespaced LCM `session_id` encoding\n * (#1495 P1). U+001F (UNIT SEPARATOR) is a C0 control character that CANNOT\n * occur in a route namespace (`isSafeRouteNamespace` ⇒ `[A-Za-z0-9._-]{1,64}`,\n * see routing/engine.ts) and does not occur in any legitimate session key, so\n * it is an unforgeable structural marker for the namespace boundary.\n *\n * SECURITY — why this is unforgeable (the #1495 P1 fix):\n * The LCM archive is keyed by the `session_id` STRING (exact `session_id = ?`\n * and prefix `session_id LIKE '<prefix>%'`), NOT physically partitioned by\n * namespace. The previous encoding `${namespace}:${sessionKey}` shared the SAME\n * string space as a raw default-store key, so a caller authorized for the\n * `default` store could pass a raw `sessionKey` equal to another namespace's\n * encoded key (`\"<overlay-ns>:<victim-session>\"`) and exact-match the victim's\n * rows — a cross-tenant read leak.\n *\n * The new encoding makes the namespaced and default key-spaces PROVABLY\n * DISJOINT:\n * - Overlay key = `\\x1f<namespace>\\x1f<sessionKey>` — always begins with\n * `\\x1f` followed by a NON-`\\x1f` character (the namespace is non-empty and\n * `\\x1f`-free). The leading `\\x1f<namespace>\\x1f` is an unambiguous,\n * injective frame: the namespace cannot contain `\\x1f`, so the second `\\x1f`\n * terminates it without any escaping of the (raw) session key.\n * - Default key = the raw `sessionKey`, UNLESS it already begins with the\n * sentinel, in which case it is escaped to begin with `\\x1f\\x1f` (see\n * `escapeDefaultLcmKey`). A default key therefore NEVER matches the overlay\n * frame `\\x1f<non-\\x1f>…`.\n * Hence no caller-controlled raw `sessionKey` (default path) can reproduce an\n * overlay key, closing the forgery for BOTH the exact-`session_id` match and the\n * `sessionPrefix` LIKE match (an overlay prefix `\\x1f<ns>\\x1f<rawPrefix>` stays a\n * valid LIKE-prefix of the overlay full keys, and a default prefix can only\n * LIKE-match default keys).\n *\n * Existing default-store rows need NO migration: legitimate session keys never\n * contain `\\x1f`, so `escapeDefaultLcmKey` is a no-op for them and they remain\n * byte-for-byte their raw form. The namespaced encoding is NEW in this\n * unreleased PR, so changing its shape costs nothing.\n */\nconst LCM_NS_SENTINEL = \"\\u001f\";\n\n/**\n * Make a default-store (raw) LCM key disjoint from the namespaced key-space.\n *\n * Namespaced overlay keys always begin with `\\x1f` followed by a non-`\\x1f`\n * namespace character. A raw default key collides with that frame ONLY if it\n * begins with `\\x1f`. Legitimate session keys never contain `\\x1f`, so this is a\n * pure no-op for them; a forged key that begins with `\\x1f` is escaped to begin\n * with `\\x1f\\x1f`, which can never equal an overlay key (whose second character\n * is a `[A-Za-z0-9._-]` namespace char, never `\\x1f`).\n */\nfunction escapeDefaultLcmKey(sessionKey: string): string {\n return sessionKey.startsWith(LCM_NS_SENTINEL)\n ? `${LCM_NS_SENTINEL}${sessionKey}`\n : sessionKey;\n}\n\n/**\n * Build the LCM/structured-history `session_id` that a write-producing surface\n * archives under, and that a same-session reader must search under, so reads\n * and writes never drift (#1495, CLAUDE.md rule 42).\n *\n * The LCM archive filters strictly by the `session_id` string, so the writer's\n * archival key and the reader's lookup key MUST agree byte-for-byte. The\n * encoding frames the namespace with the reserved {@link LCM_NS_SENTINEL}\n * (`\\x1f<namespace>\\x1f<sessionKey>`) whenever that namespace diverges from the\n * single-store default; otherwise it passes the (escaped) raw `sessionKey` so\n * single-user / no-overlay deployments keep pre-#1495 behavior exactly. The two\n * key-spaces are provably disjoint, so a caller-controlled raw `sessionKey`\n * cannot forge another namespace's encoded id (see the {@link LCM_NS_SENTINEL}\n * doc comment for the full security rationale).\n *\n * `observe`, compaction flush/record, and the orchestrator recall readers all\n * route through this one helper so a project-scoped (cwd/projectTag) or\n * explicit-namespace session reads its own compressed-history / structured /\n * targeted-fact evidence instead of missing it.\n */\nexport function lcmSessionKeyForNamespace(\n namespace: string | undefined,\n sessionKey: string | undefined,\n defaultNamespace: string,\n): string | undefined {\n if (typeof sessionKey !== \"string\" || sessionKey.length === 0) return sessionKey;\n if (\n typeof namespace === \"string\" &&\n namespace.length > 0 &&\n namespace !== defaultNamespace\n ) {\n // Namespaced (overlay / explicit) key: frame the namespace with the reserved\n // sentinel so the boundary is unambiguous AND unforgeable from the default\n // key-space. The namespace is guaranteed `\\x1f`-free by `isSafeRouteNamespace`.\n return `${LCM_NS_SENTINEL}${namespace}${LCM_NS_SENTINEL}${sessionKey}`;\n }\n // Default store: raw sessionKey, escaped only if it would otherwise intrude on\n // the namespaced key-space (no-op for every legitimate key).\n return escapeDefaultLcmKey(sessionKey);\n}\n\n/**\n * Map an ORDERED, read-authorized namespace set (the SAME set normal QMD/file\n * recall searches) to the ordered set of LCM `session_id`s a same-session reader\n * must query (#1505 thread \"Include coding fallback namespaces in LCM reads\").\n *\n * The LCM archive filters strictly by `session_id`, and `observe` archives each\n * turn under `${effectiveNamespace}:${sessionKey}` for the namespace that was\n * effective when it was written. A branch-scoped session that overlays\n * `${base-project-*-branch-*}` only sees rows written under THAT namespace if it\n * reads a single overlay key — but normal recall ALSO searches the\n * `codingOverlay.readFallbacks` (project / root) namespaces, so rows archived at\n * project/root scope are surfaced by QMD/file recall yet MISSED by a single-key\n * LCM read. Deriving the LCM read keys from the SAME `recallNamespaces` set keeps\n * the LCM read path from diverging: every namespace recall is authorized to read\n * (read-auth gate already applied upstream in `recallNamespaces`) contributes one\n * LCM key, ordered primary-overlay-first then fallbacks. Unreadable namespaces\n * are never in `recallNamespaces`, so they are never searched here either (no\n * cross-tenant read leak).\n *\n * Single-user / no-overlay recall passes a single-namespace set that collapses to\n * the raw `sessionKey`, so the result is `[sessionKey]` — byte-for-byte the\n * pre-#1505 single-key behavior.\n *\n * SESSIONLESS recall (`sessionKey === undefined`): returns `[undefined]` so the\n * caller issues ONE archive-wide LCM read with no exact `session_id` filter —\n * byte-for-byte the pre-#1505 sessionless behavior. It must NOT substitute the\n * literal `\"default\"` session id (codex P2 \"Preserve unscoped LCM searches\n * without a session key\"): that would filter to a session literally named\n * `default`, silently dropping the explicit-cue / targeted / focused / response /\n * event LCM sections for every recall that omits a session key.\n *\n * The result is deduped while preserving first-seen order so the caller can query\n * keys in priority order and short-circuit on the first hit without re-querying an\n * identical key (e.g. when two namespaces both collapse to the default store).\n */\nexport function lcmReadSessionIdsForNamespaces(\n namespaces: readonly string[],\n sessionKey: string | undefined,\n defaultNamespace: string,\n): Array<string | undefined> {\n // Sessionless ⇒ a single archive-wide read (no `session_id` filter). NEVER the\n // literal \"default\" session id (codex P2).\n if (typeof sessionKey !== \"string\" || sessionKey.length === 0) {\n return [undefined];\n }\n const out: string[] = [];\n const seen = new Set<string>();\n for (const namespace of namespaces) {\n const key =\n lcmSessionKeyForNamespace(namespace, sessionKey, defaultNamespace) ??\n sessionKey;\n if (!seen.has(key)) {\n seen.add(key);\n out.push(key);\n }\n }\n return out;\n}\n","import { createHash } from \"node:crypto\";\n\nimport { combineNamespaces, type CodingNamespaceOverlay } from \"../coding/coding-namespace.js\";\nimport { stableHash } from \"../coding/git-context.js\";\nimport { isSafeRouteNamespace } from \"../routing/engine.js\";\nimport type {\n CodingContext,\n PluginConfig,\n ScopeProfileConfig,\n ScopeProfileLayerId,\n ScopeProfilePromotionTarget,\n ScopeTeamConfig,\n} from \"../types.js\";\nimport { canReadNamespace, canWriteNamespace, defaultNamespaceForPrincipal } from \"./principal.js\";\n\ntype ScopeProfileCodingOverlay = Pick<CodingNamespaceOverlay, \"namespace\" | \"readFallbacks\">;\n\nexport interface ScopeProfileLayerResolution {\n id: ScopeProfileLayerId;\n kind: \"user-project\" | \"team-project\" | \"user-global\" | \"server-shared\";\n namespace?: string;\n readable: boolean;\n writable: boolean;\n promotable: boolean;\n reason: string;\n}\n\nexport interface ScopeProfilePromotionResolution {\n target: ScopeProfilePromotionTarget;\n namespace?: string;\n authorized: boolean;\n reason: string;\n}\n\nexport interface ResolvedScopeProfilePlan {\n profileId: string;\n profile: ScopeProfileConfig;\n baseNamespace: string;\n writeLayer: ScopeProfileLayerId;\n writeNamespace: string;\n readNamespaces: string[];\n layers: ScopeProfileLayerResolution[];\n promotionTargets: ScopeProfilePromotionResolution[];\n warnings: string[];\n}\n\nexport interface ResolveScopeProfilePlanOptions {\n config: PluginConfig;\n principal?: string;\n codingContext?: CodingContext | null;\n codingOverlay?: ScopeProfileCodingOverlay | null;\n}\n\nfunction activeScopeProfile(config: PluginConfig): { profileId: string; profile: ScopeProfileConfig } | null {\n const profileId = config.defaultScopeProfile;\n if (!profileId) return null;\n const profile = (config.scopeProfiles ?? {})[profileId];\n return profile ? { profileId, profile } : null;\n}\n\nfunction principalListed(list: string[], principal: string | undefined): boolean {\n if (!principal) return false;\n return list.includes(principal) || list.includes(\"*\");\n}\n\nfunction derivedScopeProfileSelfNamespace(principal: string | undefined, config: PluginConfig): string | null {\n if (!principal || principal === config.defaultNamespace || principal === config.sharedNamespace) return null;\n if (isSafeRouteNamespace(principal)) return principal;\n return \"principal-\" + createHash(\"sha256\").update(principal).digest(\"hex\").slice(0, 54);\n}\n\nfunction scopeProfileSelfNamespace(principal: string | undefined, config: PluginConfig): string {\n const existing = defaultNamespaceForPrincipal(principal, config);\n if (existing !== config.defaultNamespace) return existing;\n return derivedScopeProfileSelfNamespace(principal, config) ?? existing;\n}\n\nfunction hasExplicitNamespacePolicy(namespace: string, config: PluginConfig): boolean {\n return (config.namespacePolicies ?? []).some((policy) => policy.name === namespace);\n}\n\nfunction isScopeProfileImplicitSelfNamespace(\n principal: string | undefined,\n namespace: string,\n config: PluginConfig,\n): boolean {\n const derived = derivedScopeProfileSelfNamespace(principal, config);\n return Boolean(\n derived &&\n namespace === derived &&\n namespace !== config.defaultNamespace &&\n namespace !== config.sharedNamespace &&\n isSafeRouteNamespace(namespace) &&\n !hasExplicitNamespacePolicy(namespace, config),\n );\n}\n\nfunction canReadScopeProfileNamespace(\n principal: string | undefined,\n namespace: string,\n config: PluginConfig,\n): boolean {\n return isScopeProfileImplicitSelfNamespace(principal, namespace, config) || canReadNamespace(principal, namespace, config);\n}\n\nfunction canWriteScopeProfileNamespace(\n principal: string | undefined,\n namespace: string,\n config: PluginConfig,\n): boolean {\n return isScopeProfileImplicitSelfNamespace(principal, namespace, config) || canWriteNamespace(principal, namespace, config);\n}\n\nfunction resolveTeam(\n config: PluginConfig,\n profile: ScopeProfileConfig,\n principal: string | undefined,\n): { teamId: string; team: ScopeTeamConfig } | null {\n const configuredTeamId = profile.teamProject?.teamId;\n if (configuredTeamId) {\n const configured = (config.teams ?? {})[configuredTeamId];\n return configured ? { teamId: configuredTeamId, team: configured } : null;\n }\n const readableTeams = Object.entries(config.teams ?? {}).filter(([, team]) =>\n principalListed(team.principals, principal) || principalListed(team.read, principal),\n );\n const needsWritableTeam = profile.writeDefault === \"teamProject\" || profile.readOrder.includes(\"teamProject\");\n if (needsWritableTeam) {\n const writableTeam = readableTeams.find(([, team]) => principalListed(team.write, principal));\n if (writableTeam) return { teamId: writableTeam[0], team: writableTeam[1] };\n }\n const needsPromotableTeam =\n profile.promotionTargets.includes(\"teamProject\") || profile.autoPromote.targets.includes(\"teamProject\");\n if (needsPromotableTeam) {\n const promotableTeam = readableTeams.find(\n ([, team]) => principalListed(team.promote, principal) || principalListed(team.write, principal),\n );\n if (promotableTeam) return { teamId: promotableTeam[0], team: promotableTeam[1] };\n }\n const firstReadableTeam = readableTeams[0];\n return firstReadableTeam\n ? { teamId: firstReadableTeam[0], team: firstReadableTeam[1] }\n : null;\n}\n\nfunction renderTeamProjectNamespace(params: {\n template: string;\n teamId: string;\n principal: string | undefined;\n codingContext: CodingContext;\n codingOverlay: ScopeProfileCodingOverlay;\n}): { namespace: string; unknownPlaceholders: string[] } {\n const replacements: Record<string, string> = {\n teamId: params.teamId,\n principal: params.principal ?? \"anonymous\",\n projectId: params.codingContext.projectId,\n projectHash: stableHash(params.codingContext.projectId),\n projectNamespace: params.codingOverlay.namespace,\n };\n const unknownPlaceholders: string[] = [];\n const namespace = params.template.replace(/\\{([A-Za-z][A-Za-z0-9]*)\\}/g, (match, key: string) => {\n const replacement = replacements[key];\n if (replacement !== undefined) return replacement;\n if (!unknownPlaceholders.includes(key)) unknownPlaceholders.push(key);\n return match;\n });\n return { namespace, unknownPlaceholders };\n}\n\nfunction resolveLayer(params: {\n id: ScopeProfileLayerId;\n config: PluginConfig;\n profile: ScopeProfileConfig;\n principal: string | undefined;\n baseNamespace: string;\n codingContext: CodingContext | null | undefined;\n codingOverlay: ScopeProfileCodingOverlay | null | undefined;\n}): ScopeProfileLayerResolution {\n const { id, config, profile, principal, baseNamespace, codingContext, codingOverlay } = params;\n if (id === \"userGlobal\") {\n return {\n id,\n kind: \"user-global\",\n namespace: baseNamespace,\n readable: canReadScopeProfileNamespace(principal, baseNamespace, config),\n writable: canWriteScopeProfileNamespace(principal, baseNamespace, config),\n promotable: canWriteScopeProfileNamespace(principal, baseNamespace, config),\n reason: \"principal self/global namespace\",\n };\n }\n if (id === \"serverShared\") {\n return {\n id,\n kind: \"server-shared\",\n namespace: config.sharedNamespace,\n readable: canReadNamespace(principal, config.sharedNamespace, config),\n writable: canWriteNamespace(principal, config.sharedNamespace, config),\n promotable: canWriteNamespace(principal, config.sharedNamespace, config),\n reason: \"configured shared namespace\",\n };\n }\n if (id === \"userProject\") {\n if (!codingContext || !codingOverlay) {\n return {\n id,\n kind: \"user-project\",\n readable: false,\n writable: false,\n promotable: false,\n reason: \"missing project context\",\n };\n }\n const namespace = combineNamespaces(baseNamespace, codingOverlay.namespace);\n const explicitProjectPolicy = hasExplicitNamespacePolicy(namespace, config);\n const baseReadable = canReadScopeProfileNamespace(principal, baseNamespace, config);\n const baseWritable = canWriteScopeProfileNamespace(principal, baseNamespace, config);\n const projectReadable = explicitProjectPolicy\n ? canReadNamespace(principal, namespace, config)\n : baseReadable;\n const projectWritable = explicitProjectPolicy\n ? canWriteNamespace(principal, namespace, config)\n : baseWritable;\n return {\n id,\n kind: \"user-project\",\n namespace,\n readable: projectReadable,\n writable: projectWritable,\n promotable: projectWritable,\n reason: explicitProjectPolicy\n ? \"explicit user-project namespace policy\"\n : baseReadable || baseWritable\n ? \"principal project namespace derived from coding context\"\n : \"principal base namespace is not authorized\",\n };\n }\n const team = resolveTeam(config, profile, principal);\n if (!team) {\n return {\n id,\n kind: \"team-project\",\n readable: false,\n writable: false,\n promotable: false,\n reason: \"no authorized team mapping\",\n };\n }\n if (!codingContext || !codingOverlay) {\n return {\n id,\n kind: \"team-project\",\n readable: false,\n writable: false,\n promotable: false,\n reason: \"missing project context\",\n };\n }\n const template =\n profile.teamProject?.namespaceTemplate ??\n team.team.projectNamespaceTemplate ??\n \"team-{teamId}-project-{projectHash}\";\n const renderedNamespace = renderTeamProjectNamespace({\n template,\n teamId: team.teamId,\n principal,\n codingContext,\n codingOverlay,\n });\n const namespace = renderedNamespace.namespace.trim();\n if (renderedNamespace.unknownPlaceholders.length > 0) {\n return {\n id,\n kind: \"team-project\",\n namespace,\n readable: false,\n writable: false,\n promotable: false,\n reason: `unknown team-project namespace template placeholder(s): ${renderedNamespace.unknownPlaceholders.join(\", \")}`,\n };\n }\n if (!namespace || !isSafeRouteNamespace(namespace)) {\n return {\n id,\n kind: \"team-project\",\n namespace,\n readable: false,\n writable: false,\n promotable: false,\n reason: \"team-project namespace template resolved to an unsafe namespace\",\n };\n }\n const teamReadable = principalListed(team.team.read, principal) || principalListed(team.team.principals, principal);\n const teamWritable = principalListed(team.team.write, principal);\n const teamPromotable = principalListed(team.team.promote, principal) || principalListed(team.team.write, principal);\n const userProjectSuffix = `-${codingOverlay.namespace}`;\n const userProjectBase = namespace.endsWith(userProjectSuffix)\n ? namespace.slice(0, -userProjectSuffix.length)\n : \"\";\n const dynamicUserProjectCollision =\n userProjectBase.length > 0 &&\n (userProjectBase === config.defaultNamespace ||\n userProjectBase === config.sharedNamespace ||\n (config.namespacePolicies ?? []).some((policy) => policy.name === userProjectBase));\n const protectedNamespace =\n namespace === config.defaultNamespace ||\n namespace === config.sharedNamespace ||\n dynamicUserProjectCollision ||\n (config.namespacePolicies ?? []).some((policy) => policy.name === namespace);\n const policyReadable = !protectedNamespace || canReadNamespace(principal, namespace, config);\n const policyWritable = !protectedNamespace || canWriteNamespace(principal, namespace, config);\n const policyBlocked = protectedNamespace && (!policyReadable || !policyWritable);\n return {\n id,\n kind: \"team-project\",\n namespace,\n readable: teamReadable && policyReadable,\n writable: teamWritable && policyWritable,\n promotable: teamPromotable && policyWritable,\n reason: policyBlocked\n ? \"team-project namespace collides with a protected namespace policy\"\n : \"trusted team-project namespace derived from team and project config\",\n };\n}\n\nexport function resolveScopeProfilePlan(\n options: ResolveScopeProfilePlanOptions,\n): ResolvedScopeProfilePlan | null {\n const active = activeScopeProfile(options.config);\n if (!active || !options.config.namespacesEnabled) return null;\n\n const baseNamespace = scopeProfileSelfNamespace(options.principal, options.config);\n const layerIds = Array.from(\n new Set<ScopeProfileLayerId>([\n ...active.profile.readOrder,\n active.profile.writeDefault,\n \"userGlobal\",\n ...active.profile.promotionTargets.filter((target): target is ScopeProfileLayerId =>\n [\"userProject\", \"teamProject\", \"userGlobal\", \"serverShared\"].includes(target),\n ),\n ]),\n );\n const layerMap = new Map<ScopeProfileLayerId, ScopeProfileLayerResolution>();\n for (const id of layerIds) {\n layerMap.set(\n id,\n resolveLayer({\n id,\n config: options.config,\n profile: active.profile,\n principal: options.principal,\n baseNamespace,\n codingContext: options.codingContext,\n codingOverlay: options.codingOverlay,\n }),\n );\n }\n\n const readNamespaces: string[] = [];\n for (const id of active.profile.readOrder) {\n const layer = layerMap.get(id);\n if (layer?.readable && layer.namespace && !readNamespaces.includes(layer.namespace)) {\n readNamespaces.push(layer.namespace);\n }\n }\n\n const preferredWriteLayer = layerMap.get(active.profile.writeDefault);\n const readableWriteLayers = active.profile.readOrder\n .map((id) => layerMap.get(id))\n .filter(\n (layer): layer is ScopeProfileLayerResolution =>\n Boolean(layer?.writable && layer.namespace && readNamespaces.includes(layer.namespace)),\n );\n const fallbackWriteLayer =\n preferredWriteLayer?.writable &&\n preferredWriteLayer.namespace &&\n readNamespaces.includes(preferredWriteLayer.namespace)\n ? preferredWriteLayer\n : readableWriteLayers[0];\n const warnings: string[] = [];\n if (!fallbackWriteLayer?.namespace) {\n warnings.push(`scope profile ${active.profileId} has no writable layer inside the profile read stack; writes disabled`);\n } else if (fallbackWriteLayer.id !== active.profile.writeDefault) {\n warnings.push(\n `scope profile ${active.profileId} writeDefault ${active.profile.writeDefault} unavailable: ${preferredWriteLayer?.reason ?? \"not resolved\"}`,\n );\n }\n\n const promotionTargets = active.profile.promotionTargets.map((target) => {\n const layer = layerMap.get(target as ScopeProfileLayerId);\n if (!layer) {\n return {\n target,\n authorized: false,\n reason: \"promotion target did not resolve to a profile layer\",\n };\n }\n return {\n target,\n namespace: layer.namespace,\n authorized: layer.promotable && Boolean(layer.namespace),\n reason: layer.reason,\n };\n });\n\n return {\n profileId: active.profileId,\n profile: active.profile,\n baseNamespace,\n writeLayer: fallbackWriteLayer?.id ?? active.profile.writeDefault,\n writeNamespace: fallbackWriteLayer?.namespace ?? \"\",\n readNamespaces,\n layers: [...layerMap.values()],\n promotionTargets,\n warnings,\n };\n}\n\nexport function expandScopeProfileReadNamespaces(options: {\n profilePlan: ResolvedScopeProfilePlan;\n principalSelfNamespace: string;\n config: PluginConfig;\n principal?: string;\n codingOverlay?: ScopeProfileCodingOverlay | null;\n legacyRecallNamespaces?: string[];\n}): string[] {\n if (options.profilePlan.readNamespaces.length === 0) {\n return [];\n }\n const out = [...options.profilePlan.readNamespaces];\n const add = (namespace: string | undefined): void => {\n if (namespace && !out.includes(namespace)) out.push(namespace);\n };\n const userProjectReadable =\n options.profilePlan.profile.readOrder.includes(\"userProject\") &&\n options.profilePlan.layers.some(\n (layer) => layer.id === \"userProject\" && layer.readable && layer.namespace,\n );\n const userGlobalReadable =\n options.profilePlan.profile.readOrder.includes(\"userGlobal\") &&\n options.profilePlan.layers.some(\n (layer) => layer.id === \"userGlobal\" && layer.readable && layer.namespace,\n );\n if (userProjectReadable) {\n for (const fallback of options.codingOverlay?.readFallbacks ?? []) {\n if (fallback === \"\" && !userGlobalReadable) continue;\n const fallbackNamespace = combineNamespaces(options.principalSelfNamespace, fallback);\n if (\n !hasExplicitNamespacePolicy(fallbackNamespace, options.config) ||\n canReadScopeProfileNamespace(options.principal, fallbackNamespace, options.config)\n ) {\n add(fallbackNamespace);\n }\n }\n }\n return out;\n}\n","/**\n * Generic reinforcement-core primitives extracted from `procedure-miner.ts`\n * (issue #687 PR 1/4). Procedure-specific scoring (success rate, step\n * normalization) intentionally stays in the miner — this module only\n * exposes category-agnostic clustering and cluster summarization helpers\n * so future PRs can run reinforcement across non-procedural categories.\n *\n * Pure refactor — no behavior change.\n */\n\n/**\n * Group `items` into clusters keyed by `keyFn(item)`.\n *\n * - Preserves the original input order within each cluster's array.\n * - The returned `Map` insertion order matches first-seen key order, so\n * downstream iteration is deterministic for a given input.\n * - Throws `TypeError` if `keyFn` returns a non-string (e.g. `undefined`,\n * `null`, or a number). Callers must produce a stable string key.\n */\nexport function clusterByKey<T>(items: readonly T[], keyFn: (item: T) => string): Map<string, T[]> {\n const clusters = new Map<string, T[]>();\n for (const item of items) {\n const key = keyFn(item);\n if (typeof key !== \"string\") {\n throw new TypeError(\n `clusterByKey: keyFn must return a string, got ${key === null ? \"null\" : typeof key}`,\n );\n }\n const existing = clusters.get(key);\n if (existing) {\n existing.push(item);\n } else {\n clusters.set(key, [item]);\n }\n }\n return clusters;\n}\n\nexport interface ClusterSummary {\n /** Number of items in the cluster. */\n count: number;\n /** Earliest timestamp seen in the cluster (string min via `localeCompare`). */\n firstSeen: string;\n /** Latest timestamp seen in the cluster (string max via `localeCompare`). */\n lastSeen: string;\n}\n\n/**\n * Summarize a cluster by counting items and tracking earliest/latest\n * timestamps. Timestamp comparison uses `String#localeCompare`, which is\n * correct for ISO-8601 strings (lexicographic order matches chronological\n * order).\n *\n * - Throws `RangeError` on empty clusters — `firstSeen`/`lastSeen` are not\n * meaningful without at least one item.\n * - When all timestamps are equal, `firstSeen === lastSeen`.\n */\nexport function summarizeCluster<T>(\n cluster: readonly T[],\n extractTimestamp: (item: T) => string,\n): ClusterSummary {\n if (cluster.length === 0) {\n throw new RangeError(\"summarizeCluster: cluster must contain at least one item\");\n }\n let firstSeen = extractTimestamp(cluster[0]);\n let lastSeen = firstSeen;\n for (let i = 1; i < cluster.length; i += 1) {\n const ts = extractTimestamp(cluster[i]);\n if (ts.localeCompare(firstSeen) < 0) firstSeen = ts;\n if (ts.localeCompare(lastSeen) > 0) lastSeen = ts;\n }\n return { count: cluster.length, firstSeen, lastSeen };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,OAAO,UAAU;AA8DjB,IAAM,yBAAyB;AAExB,SAAS,oBAAgC;AAC9C,SAAO,CAAC,KAAa,SAAmB;AACtC,UAAM,SAAS,kBAAkB,OAAO,MAAM;AAAA,MAC5C;AAAA,MACA,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO;AAAA,IACT,CAAC;AACD,QAAI,OAAO,OAAO;AAEhB,aAAO,EAAE,QAAQ,IAAI,UAAU,IAAI;AAAA,IACrC;AACA,WAAO;AAAA,MACL,QAAQ,OAAO,OAA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M,MAAM,MAAM,IAAI;AACtB,QAAI,OAAO,QAAQ,UAAU;AAC3B,YAAM,IAAI;AAAA,QACR,iDAAiD,QAAQ,OAAO,SAAS,OAAO,GAAG;AAAA,MACrF;AAAA,IACF;AACA,UAAM,WAAW,SAAS,IAAI,GAAG;AACjC,QAAI,UAAU;AACZ,eAAS,KAAK,IAAI;AAAA,IACpB,OAAO;AACL,eAAS,IAAI,KAAK,CAAC,IAAI,CAAC;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AACT;","names":["namespace"]}
@@ -3,10 +3,11 @@ import {
3
3
  } from "./chunk-UDJLF3BO.js";
4
4
  import {
5
5
  defineOperation
6
- } from "./chunk-2EN5WZQB.js";
6
+ } from "./chunk-5HGPDRQZ.js";
7
7
  import {
8
- DECISION_SUBCOMMANDS
9
- } from "./chunk-V56S3A23.js";
8
+ DECISION_SUBCOMMANDS,
9
+ DELTA_SUBCOMMANDS
10
+ } from "./chunk-MQTPUPLP.js";
10
11
 
11
12
  // src/access-operations.ts
12
13
  import { z } from "zod";
@@ -134,12 +135,40 @@ var codingArchitectureOperation = defineOperation({
134
135
  return { result };
135
136
  }
136
137
  });
138
+ var codingDeltaSchema = z.preprocess(
139
+ (data) => {
140
+ if (data !== null && typeof data === "object" && !Array.isArray(data)) {
141
+ const obj = data;
142
+ const cleaned = {};
143
+ for (const [key, value] of Object.entries(obj)) {
144
+ if (value !== null) cleaned[key] = value;
145
+ }
146
+ return cleaned;
147
+ }
148
+ return data;
149
+ },
150
+ z.object({
151
+ subcommand: z.enum(DELTA_SUBCOMMANDS),
152
+ sessionKey: z.string().trim().max(512).optional(),
153
+ namespace: z.string().trim().max(256).optional()
154
+ })
155
+ );
156
+ var codingDeltaOperation = defineOperation({
157
+ name: "coding_delta",
158
+ description: "Get the session delta (commits + touched files since last seen) for the session's coding namespace (issue #1548 Track A PR 4).",
159
+ schema: codingDeltaSchema,
160
+ handler: async (input, ctx) => {
161
+ const result = await ctx.service.codingDelta(input, ctx.authenticatedPrincipal);
162
+ return { result };
163
+ }
164
+ });
137
165
  var REGISTERED_OPERATIONS = [
138
166
  memoryGetOperation.spec.name,
139
167
  memorySearchOperation.spec.name,
140
168
  memoryStoreOperation.spec.name,
141
169
  codingDecisionOperation.spec.name,
142
- codingArchitectureOperation.spec.name
170
+ codingArchitectureOperation.spec.name,
171
+ codingDeltaOperation.spec.name
143
172
  ];
144
173
 
145
174
  export {
@@ -148,6 +177,7 @@ export {
148
177
  memoryStoreOperation,
149
178
  codingDecisionOperation,
150
179
  codingArchitectureOperation,
180
+ codingDeltaOperation,
151
181
  REGISTERED_OPERATIONS
152
182
  };
153
- //# sourceMappingURL=chunk-NEILAC3H.js.map
183
+ //# sourceMappingURL=chunk-JNKH2XWQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/access-operations.ts"],"sourcesContent":["/**\n * Pilot operation definitions for the access boundary (issue #1525).\n *\n * Three operations migrate through the registry in this PR — `memory_get`,\n * `memory_search`, and the `memory_store` write op — so the boundary's\n * normalization matrix (rules 17/28/36/48/51) and shared error mapping reach\n * MCP, HTTP, and CLI from one place. Domain-group migrations (memory ops →\n * connectors → namespaces …) land as follow-up PRs that add `defineOperation`\n * calls here and delete the surface-local validation they replace.\n *\n * Importing this module for its side effects registers the pilot operations;\n * surfaces then dispatch via {@link getOperation} from `./access-boundary.js`.\n */\n\nimport { z } from \"zod\";\n\nimport { defineOperation } from \"./access-boundary.js\";\nimport { memoryStoreRequestSchema, type MemoryStoreRequest } from \"./access-schema.js\";\nimport type {\n EngramAccessMemoryResponse,\n EngramAccessWriteResponse,\n} from \"./access-service.js\";\nimport {\n DECISION_SUBCOMMANDS,\n type DecisionSurfaceRequest,\n type DecisionSurfaceResponse,\n} from \"./coding/decision-surfaces.js\";\nimport {\n type ArchitectureSurfaceRequest,\n type ArchitectureSurfaceResponse,\n} from \"./coding/architecture-surfaces.js\";\nimport {\n DELTA_SUBCOMMANDS,\n type DeltaSurfaceRequest,\n type DeltaSurfaceResponse,\n} from \"./coding/session-delta-surfaces.js\";\n\n// ---------------------------------------------------------------------------\n// memory_get — fetch one memory by id\n// ---------------------------------------------------------------------------\n\n/**\n * `memoryId` is required and non-empty (rule 51: the MCP dispatcher previously\n * fell back to `typeof args.memoryId === \"string\" ? args.memoryId : \"\"`,\n * silently passing an empty id into the service). `namespace` is\n * `.nullable().optional()` because MCP clients send `null` (gotcha #2).\n * `namespace` has no `.min(1)` because the pre-boundary handlers forwarded\n * empty/whitespace strings, and `resolveNamespace` treats empty identically\n * to absent (both trim to falsy → default namespace). Rejecting empty would\n * break HTTP callers that send a bare `?namespace=` (Cursor review).\n */\nconst memoryGetSchema = z.object({\n memoryId: z.string().trim().min(1, \"memoryId is required\").max(512),\n namespace: z.string().trim().max(256).nullable().optional(),\n});\n\nexport interface MemoryGetInput {\n readonly memoryId: string;\n readonly namespace?: string | null;\n}\n\nexport interface MemoryGetOutput {\n readonly result: EngramAccessMemoryResponse;\n}\n\nexport const memoryGetOperation = defineOperation<MemoryGetInput, MemoryGetOutput>({\n name: \"memory_get\",\n description: \"Fetch one memory by id.\",\n schema: memoryGetSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memoryGet(\n input.memoryId,\n input.namespace ?? undefined,\n ctx.authenticatedPrincipal,\n );\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// memory_search — semantic search across memories\n// ---------------------------------------------------------------------------\n\nconst memorySearchSchema = z.object({\n query: z.string().trim().min(1, \"query is required\").max(2048),\n namespace: z.string().trim().max(256).nullable().optional(),\n // No upper cap: the pre-boundary MCP handler forwarded any finite number to\n // memorySearch, and the QMD/search backends honor large limits. Capping at\n // 100 would reject existing clients that request larger result sets.\n maxResults: z.number().int().min(1).nullable().optional(),\n collection: z.string().trim().min(1).max(256).nullable().optional(),\n});\n\nexport interface MemorySearchInput {\n readonly query: string;\n readonly namespace?: string | null;\n readonly maxResults?: number | null;\n readonly collection?: string | null;\n}\n\nexport interface MemorySearchOutput {\n readonly result: {\n readonly query: string;\n readonly results: ReadonlyArray<{ path: string; score: number; snippet: string }>;\n readonly count: number;\n };\n}\n\nexport const memorySearchOperation = defineOperation<MemorySearchInput, MemorySearchOutput>({\n name: \"memory_search\",\n description: \"Search memories across readable namespaces.\",\n schema: memorySearchSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memorySearch({\n query: input.query,\n namespace: input.namespace ?? undefined,\n maxResults: input.maxResults ?? undefined,\n collection: input.collection ?? undefined,\n principal: ctx.authenticatedPrincipal,\n });\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// memory_store — the pilot WRITE op\n// ---------------------------------------------------------------------------\n\nexport type MemoryStoreInput = MemoryStoreRequest;\n\nexport interface MemoryStoreOutput {\n readonly result: EngramAccessWriteResponse;\n}\n\nexport const memoryStoreOperation = defineOperation<MemoryStoreInput, MemoryStoreOutput>({\n name: \"memory_store\",\n description: \"Store an explicit memory through the access layer.\",\n // Reuse the existing schema verbatim — the migration is behavior-preserving;\n // the schema's external contract is NOT changing in this PR (per the issue's\n // pitfall note).\n schema: memoryStoreRequestSchema,\n handler: async (input, ctx) => {\n const result = await ctx.service.memoryStore(\n {\n ...input,\n authenticatedPrincipal: ctx.authenticatedPrincipal,\n },\n // Forward transport-level hooks (e.g. HTTP's atomic write-quota gate)\n // so the hook still fires inside the service's idempotent-write lock —\n // never before, never on a replay (#1434 invariant preserved by the\n // boundary migration).\n\n ctx.hooks,\n );\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// coding_decision — decision-record surfaces (issue #1548 Track A PR 2)\n// ---------------------------------------------------------------------------\n\n/**\n * The subcommand field is required and MUST be one of the four valid values\n * (rule 51 — reject loudly, list the options, never silently default). The\n * remaining fields are optional because each subcommand uses a different\n * subset; the handler validates subcommand-specific requirements after\n * routing.\n */\n/**\n * MCP clients send `null` for absent optional fields. Zod `.optional()`\n * rejects `null`, so strip nulls at the object level before the inner\n * schema validates (review: cursor null-field thread).\n */\nconst codingDecisionSchema = z.preprocess(\n (data) => {\n if (data && typeof data === \"object\" && !Array.isArray(data)) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(data as Record<string, unknown>)) {\n if (v !== null) out[k] = v;\n }\n return out;\n }\n return data;\n },\n z.object({\n subcommand: z.enum(DECISION_SUBCOMMANDS),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n id: z.string().trim().max(512).optional(),\n title: z.string().trim().max(512).optional(),\n status: z.string().trim().max(64).optional(),\n context: z.string().trim().max(8192).optional(),\n decision: z.string().trim().max(8192).optional(),\n consequences: z.string().trim().max(8192).optional(),\n entityRefs: z.array(z.string().trim().min(1).max(256)).optional(),\n supersedesId: z.string().trim().max(512).optional(),\n }),\n);\n\nexport type CodingDecisionInput = DecisionSurfaceRequest;\nexport type CodingDecisionOutput = { result: DecisionSurfaceResponse };\n\nexport const codingDecisionOperation = defineOperation<\n CodingDecisionInput,\n CodingDecisionOutput\n>({\n name: \"coding_decision\",\n description:\n \"List, get, record, or supersede decision records in the session's coding namespace (issue #1548 Track A).\",\n schema: codingDecisionSchema as z.ZodType<CodingDecisionInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingDecision(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// coding_architecture — architecture-card surfaces (issue #1548 Track A PR 3)\n// ---------------------------------------------------------------------------\n\nconst codingArchitectureSchema = z.preprocess(\n (data) => {\n if (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n const obj = data as Record<string, unknown>;\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== null) cleaned[key] = value;\n }\n return cleaned;\n }\n return data;\n },\n z.object({\n subcommand: z.enum([\"get\", \"refresh\"]),\n sessionKey: z.string().optional(),\n namespace: z.string().optional(),\n }),\n);\n\nexport type CodingArchitectureInput = ArchitectureSurfaceRequest;\nexport type CodingArchitectureOutput = { result: ArchitectureSurfaceResponse };\n\nexport const codingArchitectureOperation = defineOperation<\n CodingArchitectureInput,\n CodingArchitectureOutput\n>({\n name: \"coding_architecture\",\n description:\n \"Get or refresh the architecture card for the session's coding namespace (issue #1548 Track A PR 3).\",\n schema: codingArchitectureSchema as z.ZodType<CodingArchitectureInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingArchitecture(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// coding_delta — session-delta surface (issue #1548 Track A PR 4)\n// ---------------------------------------------------------------------------\n\nconst codingDeltaSchema = z.preprocess(\n (data) => {\n if (data !== null && typeof data === \"object\" && !Array.isArray(data)) {\n const obj = data as Record<string, unknown>;\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== null) cleaned[key] = value;\n }\n return cleaned;\n }\n return data;\n },\n z.object({\n subcommand: z.enum(DELTA_SUBCOMMANDS),\n sessionKey: z.string().trim().max(512).optional(),\n namespace: z.string().trim().max(256).optional(),\n }),\n);\n\nexport type CodingDeltaInput = DeltaSurfaceRequest;\nexport type CodingDeltaOutput = { result: DeltaSurfaceResponse };\n\nexport const codingDeltaOperation = defineOperation<\n CodingDeltaInput,\n CodingDeltaOutput\n>({\n name: \"coding_delta\",\n description:\n \"Get the session delta (commits + touched files since last seen) for the session's coding namespace (issue #1548 Track A PR 4).\",\n schema: codingDeltaSchema as z.ZodType<CodingDeltaInput>,\n handler: async (input, ctx) => {\n const result = await ctx.service.codingDelta(input, ctx.authenticatedPrincipal);\n return { result };\n },\n});\n\n// ---------------------------------------------------------------------------\n// Surface registration map — what each transport calls the pilot ops\n// ---------------------------------------------------------------------------\n\n/**\n * The canonical short names (no `engram.`/`remnic.` prefix) of the operations\n * the boundary owns today. The fitness test treats this set as the migrated\n * set; everything else on a surface is unmigrated and counted by the ratchet.\n */\nexport const REGISTERED_OPERATIONS = [\n memoryGetOperation.spec.name,\n memorySearchOperation.spec.name,\n memoryStoreOperation.spec.name,\n codingDecisionOperation.spec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