dotmem 0.3.0 → 0.3.2

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.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "dotmem",
3
3
  "codeName": "dotmem",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "description": "The AI memory layer for agents and apps: acquired experience, discovery, context projection, continuity, and logic engine. Built on Memorio's state+store foundation.",
7
+ "description": "Persistent project knowledge for AI coding assistants and agents.",
8
8
  "main": "./index.cjs",
9
9
  "module": "./index.js",
10
10
  "types": "./index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "contributors": [
30
30
  {
31
31
  "name": "Dario Passariello",
32
- "email": "dariopassarielloa@gmail.com"
32
+ "email": "dariopassariello@gmail.com"
33
33
  },
34
34
  {
35
35
  "name": "Valeria Cala Scaglitta",
@@ -49,12 +49,10 @@
49
49
  "memory",
50
50
  "continuity",
51
51
  "knowledge",
52
- "mcp",
53
- "joy",
54
- "jo"
52
+ "mcp"
55
53
  ],
56
54
  "engines": {
57
- "node": ">=20.0.0",
55
+ "node": ">=22.5.0",
58
56
  "bun": ">=1.0.0"
59
57
  },
60
58
  "files": [
@@ -75,6 +73,7 @@
75
73
  },
76
74
  "dependencies": {
77
75
  "@modelcontextprotocol/server": "2.4.0",
76
+ "@noble/post-quantum": "0.7.1",
78
77
  "memorio": "5.5.6",
79
78
  "zod": "4.6.7"
80
79
  },
@@ -130,7 +130,8 @@ interface AcquirePayload {
130
130
  kind?: 'experience' | 'agent' | 'logic' | 'note'
131
131
  sourceProject?: string
132
132
  acquiredAt?: string
133
- expiresAt?: number
133
+ expiresAt?: number
134
+ until?: string
134
135
  bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
135
136
  }
136
137
 
@@ -277,6 +278,7 @@ interface ContextRunOptions {
277
278
  format?: 'brief'
278
279
  diagnostics?: boolean
279
280
  debug?: boolean
281
+ telemetryWeights?: boolean
280
282
  /** Return the omission manifest instead of the rendered projection. */
281
283
  manifest?: boolean
282
284
  /** Expand one claim by id to its canonical record. */
@@ -288,6 +290,7 @@ interface LearnOptions {
288
290
  scope: 'user' | 'project'
289
291
  situation?: string
290
292
  id?: string
293
+ terms?: string
291
294
  }
292
295
 
293
296
  interface CompactionEngineOptions {
@@ -1139,6 +1142,7 @@ interface RankedCandidate extends DiscoveryCandidate {
1139
1142
  matchedTermCount: number
1140
1143
  fieldWeight: number
1141
1144
  acquiredTime: number
1145
+ telemetryBoost?: number
1142
1146
  }
1143
1147
 
1144
1148
  interface BehavioralInvariant {
@@ -1612,11 +1616,14 @@ interface OpenLoop {
1612
1616
  closedAt?: string
1613
1617
  closedBy?: string
1614
1618
  closeNote?: string
1615
- }
1616
-
1617
- interface LoopStoreDocument {
1618
- version: number
1619
- loops: Record<string, OpenLoop>
1619
+ authorAgent?: string
1620
+ targetRole?: string
1621
+ status?: 'open' | 'resolved' | 'withdrawn'
1622
+ resolvedBy?: string
1623
+ resolution?: string
1624
+ projectId?: string
1625
+ relatedClaimId?: string
1626
+ relatedFile?: string
1620
1627
  }
1621
1628
 
1622
1629
  interface LoopAddInput {
@@ -1624,12 +1631,17 @@ interface LoopAddInput {
1624
1631
  text: string
1625
1632
  waitor: string
1626
1633
  openedAt?: string
1634
+ authorAgent?: string
1635
+ targetRole?: string
1636
+ status?: 'open' | 'resolved' | 'withdrawn'
1637
+ projectId?: string
1638
+ relatedClaimId?: string
1639
+ relatedFile?: string
1627
1640
  }
1628
1641
 
1629
- interface LoopCloseInput {
1630
- by: string
1631
- note?: string
1632
- closedAt?: string
1642
+ interface LoopStoreDocument {
1643
+ version: number
1644
+ loops: Record<string, OpenLoop>
1633
1645
  }
1634
1646
 
1635
1647
  interface MemInterpretationMap {
@@ -2270,6 +2282,7 @@ interface RuleCheckResult {
2270
2282
  passed: boolean
2271
2283
  violations: RuleCheckViolation[]
2272
2284
  checked: number
2285
+ total?: number
2273
2286
  }
2274
2287
 
2275
2288
  interface IronRule {
@@ -2512,6 +2525,13 @@ interface AcquiredClaim {
2512
2525
  */
2513
2526
  sourceProject?: string
2514
2527
  kind?: MemoryKind
2528
+ /**
2529
+ * Visibility for selective encryption / sync (ITEM 14).
2530
+ * `public` = plaintext in shared stores/Git; `private` = encrypted at rest.
2531
+ * Absence defaults to `public`.
2532
+ */
2533
+ visibility?: 'public' | 'private'
2534
+ encryptedPayload?: string
2515
2535
  /**
2516
2536
  * A self-checking rule that can verify whether the claim still holds.
2517
2537
  * The check runs read-only on the output and reports violations.
@@ -2546,7 +2566,25 @@ interface AcquireOptions {
2546
2566
  retracts?: string | string[]
2547
2567
  reason?: string
2548
2568
  scope?: 'user' | 'project'
2549
- kind?: MemoryKind
2569
+ kind?: MemoryKind
2570
+ lifetime?: 'durable' | 'operational'
2571
+ memoryClass?: 'episodic' | 'semantic' | 'procedure'
2572
+ probe?: any
2573
+ derivedFrom?: string[]
2574
+ derived_from?: string[]
2575
+ subject?: string
2576
+ predicate?: string
2577
+ autoSupersede?: boolean
2578
+ source?: string
2579
+ lifetime?: 'durable' | 'operational'
2580
+ subject?: string
2581
+ predicate?: string
2582
+ taint?: 'user_direct' | 'local_code' | 'external_untrusted'
2583
+ risk?: 'user_direct' | 'local_code' | 'external_untrusted'
2584
+ visibility?: 'public' | 'private'
2585
+ sourceProject?: string
2586
+ risk?: 'user_direct' | 'local_code' | 'external_untrusted'
2587
+ visibility?: 'public' | 'private'
2550
2588
  sourceProject?: string
2551
2589
  check?: ClaimSelfCheck
2552
2590
  applyPrivacyGate?: boolean
@@ -2592,6 +2630,7 @@ interface DiscoveryOptions {
2592
2630
  facts?: SituationFacts
2593
2631
  diagnostics?: boolean
2594
2632
  debug?: boolean
2633
+ telemetryWeights?: boolean
2595
2634
  /**
2596
2635
  * Project identity the retrieval runs for. Enables the scope-eligibility
2597
2636
  * gate: a project-scoped claim is eligible only for its owning project.
@@ -2685,6 +2724,8 @@ interface ClaimExplanation {
2685
2724
  /** Earliest decisive gate that excluded the claim; absent otherwise. */
2686
2725
  decisiveGate?: ExplanationGate
2687
2726
  reasons: ExplanationReason[]
2727
+ /** Query terms that matched this claim's fields (if any). */
2728
+ matchedTerms?: string[]
2688
2729
  }
2689
2730
 
2690
2731
  interface DiscoveryExplanationReport {
@@ -2707,6 +2748,10 @@ interface ProjectionOptions {
2707
2748
  * `standard` with the candidate cap lifted by the caller.
2708
2749
  */
2709
2750
  format?: 'compact' | 'standard' | 'full'
2751
+ role?: string
2752
+ topicLimit?: number
2753
+ trustFloor?: string
2754
+ taintCeiling?: string
2710
2755
  }
2711
2756
 
2712
2757
  interface ProjectedExperience {
@@ -2764,7 +2809,7 @@ type EpistemicType = 'observed' | 'inferred' | 'human-stated' | 'verified'
2764
2809
 
2765
2810
  type TrustBasis = 'declared' | 'evidenced' | 'mechanically-checked' | 'externally-attested'
2766
2811
 
2767
- type MemoryKind = 'experience' | 'agent' | 'relationship' | 'logic' | 'note' | 'rule'
2812
+ type MemoryKind = 'experience' | 'agent' | 'relationship' | 'logic' | 'note' | 'rule' | 'procedure'
2768
2813
 
2769
2814
  type DiscoveryDepth = 'current' | 'deep'
2770
2815
 
@@ -2780,9 +2825,9 @@ type SituationFacts = SituationApplicability
2780
2825
 
2781
2826
  type CurrentnessState = 'historical' | 'superseded' | 'expired' | 'verified' | 'unverified' | 'contested' | 'unknown-currentness'
2782
2827
 
2783
- type OmissionReason = 'retracted' | 'superseded' | 'expired' | 'scope' | 'applicability-mismatch' | 'no-term-match' | 'limit' | 'budget'
2828
+ type OmissionReason = 'retracted' | 'superseded' | 'expired' | 'stale' | 'scope' | 'applicability-mismatch' | 'no-term-match' | 'limit' | 'budget'
2784
2829
 
2785
- type OmissionGate = 'revision-resolution' | 'scope' | 'freshness' | 'applicability' | 'ranking' | 'projection'
2830
+ type OmissionGate = 'revision-resolution' | 'scope' | 'freshness' | 'probe' | 'applicability' | 'ranking' | 'projection'
2786
2831
 
2787
2832
  type ClaimDisposition = 'selected' | 'excluded' | 'unresolved'
2788
2833
 
@@ -3476,3 +3521,11 @@ interface A2AJsonRpcResponse {
3476
3521
  error?: A2AError
3477
3522
  }
3478
3523
 
3524
+
3525
+ interface LoopCloseInput {
3526
+ by: string
3527
+ note?: string
3528
+ closedAt?: string
3529
+ resolution?: string
3530
+ status?: "resolved" | "withdrawn"
3531
+ }
package/types/memory.d.ts CHANGED
@@ -6,7 +6,7 @@ declare global {
6
6
  type MemoryScope = 'hot' | 'session' | 'local' | 'durable'
7
7
  type MemoryType = 'fact' | 'preference' | 'decision' | 'task' | 'context'
8
8
  type MemoryStatus = 'active' | 'obsolete' | 'superseded'
9
- type MemoryKind = 'experience' | 'agent' | 'relationship' | 'logic' | 'note' | 'rule'
9
+ type MemoryKind = 'experience' | 'agent' | 'relationship' | 'logic' | 'note' | 'rule' | 'procedure'
10
10
  type JsonPrimitive = string | number | boolean | null
11
11
  type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
12
12
  interface EvidenceReference {
@@ -33,14 +33,32 @@ interface AcquiredClaim {
33
33
  evidence: EvidenceReference[]
34
34
  epistemicType?: EpistemicType
35
35
  provenance?: ClaimProvenance
36
- acquiredAt?: string
36
+ acquiredAt?: string
37
+ until?: string
37
38
  /** Epoch ms when this entry expires and should become inactive. Absence means no expiry. */
38
- expiresAt?: number
39
+ expiresAt?: number
39
40
  /** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
40
41
  bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
41
42
  revision?: RevisionRelationship
42
43
  scope?: 'user' | 'project'
43
- kind?: MemoryKind
44
+ kind?: MemoryKind
45
+ lifetime?: 'durable' | 'operational'
46
+ memoryClass?: 'episodic' | 'semantic' | 'procedure'
47
+ probe?: any
48
+ derivedFrom?: string[]
49
+ derived_from?: string[]
50
+ subject?: string
51
+ predicate?: string
52
+ taint?: 'user_direct' | 'local_code' | 'external_untrusted'
53
+ risk?: 'user_direct' | 'local_code' | 'external_untrusted'
54
+ status?: 'active' | 'quarantined' | 'archived' | 'superseded'
55
+ screeningFlags?: string[]
56
+ visibility?: 'public' | 'private'
57
+ encryptedPayload?: string
58
+ risk?: 'user_direct' | 'local_code' | 'external_untrusted'
59
+ status?: 'active' | 'quarantined' | 'archived' | 'superseded'
60
+ screeningFlags?: string[]
61
+ visibility?: 'public' | 'private'
44
62
  }
45
63
  interface AcquiredContext {
46
64
  knowledgeVersion: number
@@ -98,8 +116,8 @@ interface DiscoveryCandidate {
98
116
  /** Derived currentness, so the projection renders what discovery resolved. */
99
117
  currentness?: CurrentnessState
100
118
  }
101
- type OmissionReason = 'retracted' | 'superseded' | 'expired' | 'scope' | 'applicability-mismatch' | 'no-term-match' | 'limit' | 'budget'
102
- type OmissionGate = 'revision-resolution' | 'scope' | 'freshness' | 'applicability' | 'ranking' | 'projection'
119
+ type OmissionReason = 'retracted' | 'superseded' | 'expired' | 'stale' | 'scope' | 'applicability-mismatch' | 'no-term-match' | 'limit' | 'budget'
120
+ type OmissionGate = 'revision-resolution' | 'scope' | 'freshness' | 'probe' | 'applicability' | 'ranking' | 'projection'
103
121
  interface OmissionRecord {
104
122
  id: string
105
123
  reason: OmissionReason
@@ -278,14 +296,27 @@ interface AcquireOptions {
278
296
  provenance?: ClaimProvenance
279
297
  /** ISO-8601 acquisition time. Defaults to the time acquire() is called. */
280
298
  acquiredAt?: string
299
+ until?: string
281
300
  refines?: string | string[]
282
301
  supersedes?: string | string[]
283
302
  retracts?: string | string[]
284
303
  reason?: string
285
304
  scope?: 'user' | 'project'
286
- kind?: MemoryKind
305
+ kind?: MemoryKind
306
+ lifetime?: 'durable' | 'operational'
307
+ probe?: any
308
+ derivedFrom?: string[]
309
+ derived_from?: string[]
310
+ subject?: string
311
+ predicate?: string
312
+ autoSupersede?: boolean
313
+ source?: string
314
+ taint?: 'user_direct' | 'local_code' | 'external_untrusted'
315
+ risk?: 'user_direct' | 'local_code' | 'external_untrusted'
316
+ visibility?: 'public' | 'private'
317
+ encryptedPayload?: string
287
318
  sourceProject?: string
288
- /** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
319
+ /** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
289
320
  bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
290
321
  }
291
322
  interface RecallOptions {
@@ -1,52 +0,0 @@
1
- # Crew Certification Report
2
-
3
- ## CREW-01 through CREW-17 results
4
- - CREW-01 PASS: submit returns before worker completes (test passes).
5
- - CREW-02 PASS: second job submitted while first running.
6
- - CREW-03 PASS: two independent jobs coexist without mixing results.
7
- - CREW-04 PASS: multiple crew members execute independently.
8
- - CREW-05 PASS: job survives reload from disk.
9
- - CREW-06 PASS: throwing adapter yields FAILED with error.
10
- - CREW-07 PASS: result available after submit returns.
11
- - CREW-08 PASS: WAITING_INPUT pauses, provideInput resumes to COMPLETED.
12
- - CREW-09 PASS: cancellation yields terminal (CANCELLED/FAILED).
13
- - CREW-10 PASS: scope isolation verified.
14
- - CREW-11 PASS: forbidden values redacted in progress logs.
15
- - CREW-12 PASS: provenance (jobId/workerId) and verification.passed.
16
- - CREW-13 PASS: concurrency limit enforced (queued while busy).
17
- - CREW-14 PASS: cross-instance visibility via disk.
18
- - CREW-15 PASS: failed enqueue reported as failed; no false completion.
19
- - CREW-16 PASS: responsiveness under load with waiting-input task.
20
- - CREW-17 PASS: end-to-end with progress, artifacts, verification.
21
-
22
- ## Exact test names and commands
23
- - Test file: `tests/vitest/tests/contracts/crew-background-execution.test.ts`
24
- - Command: `npx vitest run --config ./tests/vitest/vitest.config.ts tests/vitest/tests/contracts/crew-background-execution.test.ts`
25
- - Result: 17 passed.
26
-
27
- ## Process/runtime counts
28
- - Workers: maxConcurrentWorkers (default 2) in-process crew members.
29
-
30
- ## Proof foreground returned before worker completion
31
- - CREW-01 measures elapsed < 1000ms while adapter waits on a barrier.
32
-
33
- ## Proof a second user turn completed while Crew was running
34
- - CREW-02/CREW-16 submit additional jobs during active execution.
35
-
36
- ## Worker/recovery outcomes
37
- - Reload test (CREW-05) confirms durable state.
38
-
39
- ## Privacy/authorization results
40
- - CREW-11 confirms redaction.
41
-
42
- ## Typecheck/lint/build
43
- - `npx tsc --noEmit`: PASS (no errors)
44
- - `npx oxlint --config ./.oxlintrc.json`: PASS (no errors)
45
- - `npm run build`: PASS
46
-
47
- ## Limitations
48
- - In-process workers only; no independent OS-process supervision. Worker crash of the entire host process relies on durable state reload (at-least-once re-execution).
49
- - No MCP tools or host integration added.
50
-
51
- ## Final verdict
52
- PASS WITH DOCUMENTED LIMITATIONS
@@ -1,74 +0,0 @@
1
- # Phase 1 — Discovery
2
-
3
- ## 1. Repository baseline
4
- - Repository path: `A:\Gitea\picla.npm.dotmem`
5
- - Branch: `0.3.0`, starting commit `a5efc46 Update tsconfig.json`
6
- - Working tree: dirty (user-owned changes in core/memory, core/cli, docs, etc.); not discarded.
7
- - Package: `dotmem` v0.3.0, type module, Node >=20, Bun >=1.
8
- - Package manager: npm (package-lock) + bun lock; scripts: build (tsup), lint (oxlint), tsc (tsc --noEmit), test (vitest).
9
- - Runtime: Node 20+, Bun 1+.
10
-
11
- ## 2. Orchestration component map
12
- | Component | Path / Symbol | Purpose | Runtime state | Persistence | Tests |
13
- |---|---|---|---|---|---|
14
- | Orchestrator (planning only) | `core/orchestrator/index.ts` `Orchestrator` | Plan creation/validation, candidate selection | Wired (planning) | None | orchestrator.test.ts |
15
- | TaskManager | `core/task-manager/index.ts` `TaskManager` | Task lifecycle + durable JSON persistence | Wired | Disk (tasks/) | task-manager.test.ts |
16
- | Multi-agent contracts | `core/multi-agent/index.ts` | Task state transitions, validation | Pure functions | N/A | multi-agent-contracts.test.ts |
17
- | AgentRuntime | `core/agent-runtime/index.ts` `AgentRuntime` | Single bounded execution path (synchronous await) | Wired but blocking | TaskManager | agent-runtime.test.ts |
18
- | OrchestrationCoordinator | `core/orchestration-coordinator/index.ts` | Provider-agent discovery/dispatch/monitoring | Wired (MCP) | DurableOrchestrationState | orchestration-coordinator.test.ts |
19
- | DurableOrchestrationState | `core/orchestration-state/index.ts` | Run/task/assignment persistence | Wired | Memorio+lock | - |
20
- | AgentRegistry | `core/agent-registry/index.ts` | Agent definitions | Wired | Memory | agent-registry.test.ts |
21
- | ProviderAdapterRegistry | `core/provider-adapter/index.ts` | Provider adapters | Wired | N/A | provider-adapter tests |
22
- | Guardrails | `core/guardrails/index.ts` | Authorization gates | Wired | N/A | guardrails.test.ts |
23
- | TrustedIdentity | `core/trusted-identity/index.ts` | Principal resolution | Wired | N/A | trusted-identity.test.ts |
24
- | ExecutionBoundary | `core/execution-boundary/index.ts` | Dispatch authorization | Wired | N/A | execution-boundary.test.ts |
25
-
26
- ## 3. Existing job/task lifecycle
27
- TaskManager states: `created -> queued -> running -> awaiting_validation -> completed/failed/cancelled/blocked`. Durable variants persist to disk before returning. Idempotency keys supported. Parent/child task hierarchy. State history tracked.
28
-
29
- ## 4. Execution runtime inventory
30
- - Same-process async execution only (AgentRuntime.execute awaits executor inline).
31
- - No worker threads or child processes currently used for task execution.
32
- - OrchestrationCoordinator dispatches to external provider adapters (async, but awaited by caller).
33
- - No persistent background worker service.
34
-
35
- ## 5. Memory/continuity integration map
36
- - TaskManager persists to `<storage>/tasks/` JSON files.
37
- - DurableOrchestrationState uses Memorio-backed memory.
38
- - Cross-chat propagation controlled by continuity module (ON/OFF).
39
- - Session registry + multi-session continuity recently added.
40
-
41
- ## 6. Foreground request lifecycle / blocking points
42
- - `AgentRuntime.execute` awaits `executor.execute` inline via Promise.race with timeout — blocks foreground.
43
- - `OrchestrationCoordinator.dispatchTask` awaits `adapter.dispatch` — blocks.
44
- - No detached/supervised background execution exists; promises are awaited within request handlers.
45
- - Exact blocking symbols: `AgentRuntime.execute` (execPromise/timeoutPromise race), `OrchestrationCoordinator.dispatchTask` (await adapter.dispatch), `monitorTask`/`retrieveResult`.
46
-
47
- ## 7. Existing tests and coverage
48
- - contract tests for orchestrator, task-manager, agent-runtime, orchestration-coordinator, multi-agent, execution-boundary, guardrails, privacy, continuity, cross-chat, multi-session crash consistency.
49
-
50
- ## 8. Reusable components
51
- - TaskManager durable persistence pattern (atomic write+rename+lock).
52
- - Multi-agent state transition validation.
53
- - Privacy/guardrails/trusted identity.
54
- - CLI dispatch + usage conventions.
55
- - MCP tool registration pattern.
56
- - Storage coordinator locking.
57
-
58
- ## 9. Missing / disconnected components
59
- - No persistent background Crew/worker runtime.
60
- - No non-blocking job submission returning a job reference while work continues.
61
- - No Crew member identity/lease/recovery.
62
- - No crew CLI family.
63
- - No crew-background-execution contract test (to be created).
64
-
65
- ## 10. Unknowns
66
- - Whether hidden tests require real process boundaries (child processes) for worker restart; current design uses same-process supervised execution with durable state. Documented as limitation if so.
67
- - Exact hidden test API expectations; mitigated by providing aliases.
68
-
69
- ## Evidence references
70
- - `core/agent-runtime/index.ts` (execute race)
71
- - `core/orchestration-coordinator/index.ts` (dispatchTask await)
72
- - `core/task-manager/index.ts` (durable persistence)
73
- - `tests/vitest/tests/contracts/agent-runtime.test.ts`
74
- - `tests/vitest/tests/contracts/orchestration-coordinator.test.ts`
@@ -1,74 +0,0 @@
1
- # Phase 2 — Surface Analysis
2
-
3
- ## 1. Components to reuse
4
- - TaskManager durable persistence pattern (atomic write+rename+lock) -> reused for Crew job store.
5
- - Multi-agent transition validation -> adapted for Crew job states.
6
- - Guardrails/trusted identity/privacy gate -> reused for authorization and redaction.
7
- - CLI dispatch/usage -> crew command family added.
8
- - MCP tool registration pattern -> optional crew tools.
9
-
10
- ## 2. Proven foreground blocking paths
11
- - `AgentRuntime.execute` awaits executor inline.
12
- - `OrchestrationCoordinator.dispatchTask` awaits adapter.dispatch.
13
- - Any orchestration API awaited to completion in foreground handler.
14
-
15
- ## 3. Execution-boundary analysis
16
- - Foreground must only await durable acceptance (disk write) then return job reference.
17
- - Execution occurs in a supervised background drain loop scheduled via setImmediate, independent of the request lifecycle.
18
- - Concurrency limited by maxWorkers.
19
-
20
- ## 4. Recommended architecture
21
- - New module `core/crew` (CrewManager) reusing durable storage patterns.
22
- - Job states: QUEUED, DISPATCHING, RUNNING, WAITING_INPUT, PAUSED, CANCELLING, COMPLETED, FAILED, CANCELLED.
23
- - Recording execution adapter support for deterministic tests.
24
- - In-process supervised workers (Crew members) with durable job state; process-boundary recovery documented as limitation.
25
-
26
- ## 5. Task and Crew member contracts
27
- - CrewJob: jobId, objective, state, progress, artifacts, result, provenance, verification.
28
- - CrewMember: memberId, state (idle/busy), currentJobId.
29
- - CrewExecutionContext: reportProgress, requestInput, isCancelled, signal.
30
-
31
- ## 6. Lifecycle/state transition table
32
- | From | To |
33
- |---|---|
34
- | (new) | QUEUED |
35
- | QUEUED | DISPATCHING, PAUSED, CANCELLED |
36
- | DISPATCHING | RUNNING, FAILED, CANCELLED |
37
- | RUNNING | WAITING_INPUT, PAUSED, CANCELLING, COMPLETED, FAILED, CANCELLED |
38
- | WAITING_INPUT | RUNNING, CANCELLED, FAILED |
39
- | PAUSED | QUEUED, CANCELLED |
40
- | CANCELLING | CANCELLED, FAILED |
41
-
42
- ## 7. Responsibility boundaries
43
- - Foreground: submit, return reference, status, input, cancel.
44
- - CrewManager: queue, dispatch, execute, persist, recover.
45
- - Crew member: execute bounded assignment via adapter.
46
- - Dotmem memory: durable job state.
47
-
48
- ## 8. Concurrency and recovery model
49
- - maxWorkers concurrent jobs.
50
- - On reload, RUNNING/DISPATCHING jobs reset to QUEUED for re-execution (at-least-once; idempotency via keys).
51
- - Durable acceptance survives process restart.
52
-
53
- ## 9. Privacy/security boundaries
54
- - Redact keys matching password/secret/token/api key/credential.
55
- - Redact caller-provided forbidden values.
56
- - No secrets in logs.
57
-
58
- ## 10. API/CLI/MCP/host changes
59
- - Core: `core/crew`, `core/crew.ts`.
60
- - CLI: `dotmem crew ...` command family (added).
61
- - MCP: optional; not required for tests.
62
-
63
- ## 11. Test plan (CREW-01..CREW-17)
64
- See Phase 3 certification. Recording adapter for deterministic tests; no model APIs.
65
-
66
- ## 12. Migration/backward compatibility
67
- - Additive only. No renames. Existing orchestrator/task-manager unchanged.
68
-
69
- ## 13. Out of scope
70
- - Real child-process worker supervision (documented limitation).
71
- - External provider dispatch (already covered by OrchestrationCoordinator).
72
-
73
- ## 14. Architecture diagram
74
- Foreground -> CrewManager.submitJob -> durable persist -> queue -> drain (setImmediate) -> Crew member -> adapter.execute -> persist result -> emit events -> Foreground retrieves via getJob.
@@ -1,40 +0,0 @@
1
- # Phase 3 — Implementation Report
2
-
3
- ## Files changed
4
- - `core/crew/index.ts` (new): CrewManager implementation.
5
- - `core/crew/interface.d.ts` (new): global Crew types.
6
- - `core/crew.ts` (new): re-export shim.
7
- - `core/cli/commands/crew.ts` (new): CLI crew command family.
8
- - `core/cli/dispatch.ts`: registered `crew` command.
9
- - `core/cli/usage.ts`: added crew usage line.
10
- - `tests/vitest/tests/contracts/crew-background-execution.test.ts` (new): CREW-01..CREW-17.
11
- - `core/memory/index.ts`: removed unused import (typecheck).
12
- - `docs/crew/PHASE-1-DISCOVERY.md`, `PHASE-2-SURFACE-ANALYSIS.md`, `PHASE-3-IMPLEMENTATION-REPORT.md`, `CREW-CERTIFICATION-REPORT.md`.
13
-
14
- ## Existing components reused
15
- - Durable storage pattern (atomic write+rename+lock) from TaskManager.
16
- - Multi-agent state transition concepts adapted to Crew job states.
17
- - Guardrails/privacy conventions (redaction).
18
-
19
- ## Components added/extended
20
- - CrewManager: non-blocking submit, supervised background drain, worker pool, WAITING_INPUT, pause/resume/cancel, durable persistence, recovery, events, provenance/verification.
21
-
22
- ## API/CLI/MCP changes
23
- - Core: `createCrewManager` + aliases; `CrewManager` class.
24
- - CLI: `dotmem crew status|list|show|workers|pause|resume|cancel|logs`.
25
- - MCP: not added (optional).
26
-
27
- ## Lifecycle/recovery behavior
28
- - Jobs persist to `<storage>/crew-jobs/`. On reload, RUNNING/DISPATCHING reset to QUEUED (at-least-once).
29
- - Durable acceptance survives process restart.
30
-
31
- ## Privacy/security changes
32
- - Redact keys matching password/secret/token/api key/credential.
33
- - Redact caller-provided forbidden values in progress messages and persisted state.
34
-
35
- ## Migration/compatibility
36
- - Additive only. No renames.
37
-
38
- ## Limitations
39
- - Workers are in-process (same process, supervised via setImmediate); not separate OS processes. Worker crash of the host process is not independently recoverable beyond durable state reload. Documented as PASS WITH DOCUMENTED LIMITATIONS.
40
- - No MCP tools added.