@chude/memory 4.0.0 → 4.0.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.
Files changed (60) hide show
  1. package/README.md +58 -11
  2. package/dist/application/services/embedding-service.d.ts +8 -1
  3. package/dist/application/services/friction-service.d.ts +18 -2
  4. package/dist/application/services/index.d.ts +11 -1
  5. package/dist/application/services/memory-governance-service.d.ts +65 -0
  6. package/dist/application/services/memory-ranking-service.d.ts +65 -0
  7. package/dist/application/services/persona-profile-service.d.ts +29 -0
  8. package/dist/application/services/projection-registry.d.ts +18 -0
  9. package/dist/application/services/remote-event-sync-service.d.ts +76 -0
  10. package/dist/application/services/smart-context-service.d.ts +34 -1
  11. package/dist/application/services/temporal-graph-service.d.ts +30 -0
  12. package/dist/domain/entities/graph-edge.d.ts +87 -0
  13. package/dist/domain/entities/index.d.ts +5 -0
  14. package/dist/domain/entities/memory-event.d.ts +101 -0
  15. package/dist/domain/entities/memory-governance.d.ts +100 -0
  16. package/dist/domain/entities/memory-utility-metric.d.ts +65 -0
  17. package/dist/domain/entities/persona-entry.d.ts +67 -0
  18. package/dist/domain/ports/capability.d.ts +35 -0
  19. package/dist/domain/ports/embedding.d.ts +21 -0
  20. package/dist/domain/ports/index.d.ts +1 -0
  21. package/dist/domain/ports/redactor.d.ts +3 -0
  22. package/dist/domain/ports/repositories.d.ts +155 -1
  23. package/dist/domain/ports/sources.d.ts +1 -1
  24. package/dist/domain/services/path-decoder.d.ts +1 -1
  25. package/dist/domain/value-objects/project-path.d.ts +2 -2
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +774 -328
  28. package/dist/infrastructure/capabilities/capability-status.d.ts +10 -0
  29. package/dist/infrastructure/capabilities/index.d.ts +1 -0
  30. package/dist/infrastructure/database/event-log.d.ts +40 -8
  31. package/dist/infrastructure/database/health-checker.d.ts +22 -1
  32. package/dist/infrastructure/database/index.d.ts +3 -3
  33. package/dist/infrastructure/database/repositories/embedding-repository.d.ts +18 -4
  34. package/dist/infrastructure/database/repositories/friction-repository.d.ts +2 -1
  35. package/dist/infrastructure/database/repositories/graph-repository.d.ts +17 -0
  36. package/dist/infrastructure/database/repositories/index.d.ts +4 -0
  37. package/dist/infrastructure/database/repositories/memory-governance-repository.d.ts +21 -0
  38. package/dist/infrastructure/database/repositories/memory-utility-repository.d.ts +15 -0
  39. package/dist/infrastructure/database/repositories/persona-repository.d.ts +16 -0
  40. package/dist/infrastructure/database/schema.d.ts +40 -0
  41. package/dist/infrastructure/embedding/embedding-provider-factory.d.ts +3 -2
  42. package/dist/infrastructure/embedding/ollama-provider.d.ts +1 -0
  43. package/dist/infrastructure/hooks/config-manager.d.ts +17 -0
  44. package/dist/infrastructure/providers/provider-egress-policy.d.ts +21 -0
  45. package/dist/infrastructure/providers/provider-registry.d.ts +8 -4
  46. package/dist/infrastructure/remote/git-remote-event-transport.d.ts +40 -0
  47. package/dist/infrastructure/security/pattern-redactor.d.ts +3 -0
  48. package/dist/infrastructure/security/secret-audit-service.d.ts +57 -0
  49. package/dist/infrastructure/sources/project-name-resolver.d.ts +2 -2
  50. package/dist/presentation/cli/commands/audit-secrets.d.ts +54 -0
  51. package/dist/presentation/cli/commands/friction/types.d.ts +13 -0
  52. package/dist/presentation/cli/commands/governance.d.ts +27 -0
  53. package/dist/presentation/cli/commands/index.d.ts +6 -0
  54. package/dist/presentation/cli/commands/profile.d.ts +23 -0
  55. package/dist/presentation/cli/commands/remote.d.ts +21 -3
  56. package/dist/presentation/cli/commands/sync/ambient.d.ts +7 -0
  57. package/dist/presentation/cli/commands/sync/types.d.ts +8 -12
  58. package/dist/presentation/cli/formatters/envelope.d.ts +2 -2
  59. package/dist/presentation/cli/index.js +918 -351
  60. package/package.json +9 -6
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Canonical memory event envelope.
3
+ *
4
+ * v5 event logs store these envelopes as source-of-truth records. Database
5
+ * tables and indexes are projections rebuilt from this canonical shape.
6
+ */
7
+ import type { FactType } from "./fact.js";
8
+ export declare const MEMORY_EVENT_SCHEMA_VERSION = 2;
9
+ export type MemoryEventKind = FactType | "governance" | "privacy" | "consent" | "projection";
10
+ export type MemoryEventOperation = "add" | "update" | "delete" | "supersede" | "noop" | "migrate";
11
+ export type MemoryEventVisibility = "project" | "workspace" | "global";
12
+ export type RedactionState = "none" | "redacted" | "quarantined";
13
+ export type ConsentStatus = "not_required" | "granted" | "denied" | "revoked";
14
+ export interface MemoryEventScope {
15
+ project?: string | undefined;
16
+ workspace?: string | undefined;
17
+ visibility: MemoryEventVisibility;
18
+ }
19
+ export interface MemoryEventProvenance {
20
+ source: string;
21
+ actor: string;
22
+ method: string;
23
+ sourceIds?: string[] | undefined;
24
+ }
25
+ export interface MemoryEventPrivacy {
26
+ redactionState: RedactionState;
27
+ containsSensitiveContent: boolean;
28
+ policy?: string | undefined;
29
+ redactedFields?: string[] | undefined;
30
+ }
31
+ export interface MemoryEventConsent {
32
+ status: ConsentStatus;
33
+ scopes: string[];
34
+ grantedAt?: Date | string | undefined;
35
+ expiresAt?: Date | string | undefined;
36
+ }
37
+ export interface MemoryEventCausality {
38
+ parentEventIds: string[];
39
+ supersedesEventIds: string[];
40
+ relatedEventIds: string[];
41
+ }
42
+ export interface MemoryEventIntegrity {
43
+ algorithm: "sha256";
44
+ payloadHash: string;
45
+ envelopeHash: string;
46
+ }
47
+ export interface MemoryEventCreateParams {
48
+ schemaVersion?: 2 | undefined;
49
+ eventId?: string | undefined;
50
+ machineId: string;
51
+ sequence: number;
52
+ kind: MemoryEventKind;
53
+ operation: MemoryEventOperation;
54
+ occurredAt: Date;
55
+ observedAt: Date;
56
+ scope: MemoryEventScope;
57
+ provenance: MemoryEventProvenance;
58
+ privacy: MemoryEventPrivacy;
59
+ consent: MemoryEventConsent;
60
+ causality: MemoryEventCausality;
61
+ payload: Record<string, unknown>;
62
+ }
63
+ export interface MemoryEventEnvelopeJson {
64
+ schemaVersion: 2;
65
+ eventId: string;
66
+ machineId: string;
67
+ sequence: number;
68
+ kind: MemoryEventKind;
69
+ operation: MemoryEventOperation;
70
+ occurredAt: string;
71
+ observedAt: string;
72
+ scope: MemoryEventScope;
73
+ provenance: MemoryEventProvenance;
74
+ privacy: MemoryEventPrivacy;
75
+ consent: MemoryEventConsent;
76
+ causality: MemoryEventCausality;
77
+ payload: Record<string, unknown>;
78
+ integrity: MemoryEventIntegrity;
79
+ }
80
+ export declare class MemoryEventEnvelope {
81
+ private readonly record;
82
+ private constructor();
83
+ static create(params: MemoryEventCreateParams): MemoryEventEnvelope;
84
+ static fromJSON(value: unknown): MemoryEventEnvelope;
85
+ get schemaVersion(): 2;
86
+ get eventId(): string;
87
+ get machineId(): string;
88
+ get sequence(): number;
89
+ get kind(): MemoryEventKind;
90
+ get operation(): MemoryEventOperation;
91
+ get occurredAt(): Date;
92
+ get observedAt(): Date;
93
+ get scope(): MemoryEventScope;
94
+ get provenance(): MemoryEventProvenance;
95
+ get privacy(): MemoryEventPrivacy;
96
+ get consent(): MemoryEventConsent;
97
+ get causality(): MemoryEventCausality;
98
+ get payload(): Record<string, unknown>;
99
+ get integrity(): MemoryEventIntegrity;
100
+ toJSON(): MemoryEventEnvelopeJson;
101
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Memory governance domain model.
3
+ *
4
+ * Tracks whether derived memory may be used on a given surface and preserves
5
+ * the provenance/consent/redaction state needed to explain that decision.
6
+ */
7
+ import type { ConsentStatus, MemoryEventScope, MemoryEventVisibility, RedactionState } from "./memory-event.js";
8
+ export declare const MEMORY_GOVERNANCE_SURFACES: readonly ["fact", "context", "provider_egress", "remote_sync", "friction", "evaluation", "persona", "graph", "ranking", "dream", "projection"];
9
+ export type MemoryGovernanceSurface = (typeof MEMORY_GOVERNANCE_SURFACES)[number];
10
+ export declare const MEMORY_GOVERNANCE_STATUSES: readonly ["active", "pending_review", "suppressed", "invalidated", "expired"];
11
+ export type MemoryGovernanceStatus = (typeof MEMORY_GOVERNANCE_STATUSES)[number];
12
+ export declare const MEMORY_GOVERNANCE_CONTROLS: readonly ["register", "suppress", "unsuppress", "invalidate", "expire", "review", "consent_grant", "consent_revoke"];
13
+ export type MemoryGovernanceControl = (typeof MEMORY_GOVERNANCE_CONTROLS)[number];
14
+ export interface MemoryGovernanceEntryParams {
15
+ id?: number | undefined;
16
+ surface: MemoryGovernanceSurface;
17
+ targetId: string;
18
+ project?: string | undefined;
19
+ visibility: MemoryEventVisibility;
20
+ sourceEventIds: string[];
21
+ transformationMethod: string;
22
+ actor: string;
23
+ confidence: number;
24
+ redactionState: RedactionState;
25
+ consentStatus: ConsentStatus;
26
+ consentScopes: string[];
27
+ scope: MemoryEventScope;
28
+ status?: MemoryGovernanceStatus | undefined;
29
+ statusReason?: string | undefined;
30
+ createdAt?: Date | undefined;
31
+ updatedAt?: Date | undefined;
32
+ reviewedAt?: Date | null | undefined;
33
+ expiresAt?: Date | null | undefined;
34
+ lastEventId?: string | undefined;
35
+ }
36
+ export interface GovernanceControlParams {
37
+ control: MemoryGovernanceControl;
38
+ actor: string;
39
+ reason?: string | undefined;
40
+ occurredAt: Date;
41
+ expiresAt?: Date | null | undefined;
42
+ consentStatus?: ConsentStatus | undefined;
43
+ consentScopes?: string[] | undefined;
44
+ lastEventId?: string | undefined;
45
+ }
46
+ export interface MemoryGovernanceEntryJson {
47
+ id?: number | undefined;
48
+ surface: MemoryGovernanceSurface;
49
+ target_id: string;
50
+ project?: string | undefined;
51
+ visibility: MemoryEventVisibility;
52
+ source_event_ids: string[];
53
+ transformation_method: string;
54
+ actor: string;
55
+ confidence: number;
56
+ redaction_state: RedactionState;
57
+ consent_status: ConsentStatus;
58
+ consent_scopes: string[];
59
+ scope: MemoryEventScope;
60
+ status: MemoryGovernanceStatus;
61
+ status_reason?: string | undefined;
62
+ created_at: string;
63
+ updated_at: string;
64
+ reviewed_at: string | null;
65
+ expires_at: string | null;
66
+ last_event_id?: string | undefined;
67
+ blocked: boolean;
68
+ }
69
+ export declare class MemoryGovernanceEntry {
70
+ private readonly params;
71
+ private constructor();
72
+ static create(params: MemoryGovernanceEntryParams): MemoryGovernanceEntry;
73
+ get id(): number | undefined;
74
+ get surface(): MemoryGovernanceSurface;
75
+ get targetId(): string;
76
+ get project(): string | undefined;
77
+ get visibility(): MemoryEventVisibility;
78
+ get sourceEventIds(): string[];
79
+ get transformationMethod(): string;
80
+ get actor(): string;
81
+ get confidence(): number;
82
+ get redactionState(): RedactionState;
83
+ get consentStatus(): ConsentStatus;
84
+ get consentScopes(): string[];
85
+ get scope(): MemoryEventScope;
86
+ get status(): MemoryGovernanceStatus;
87
+ get statusReason(): string | undefined;
88
+ get createdAt(): Date;
89
+ get updatedAt(): Date;
90
+ get reviewedAt(): Date | null;
91
+ get expiresAt(): Date | null;
92
+ get lastEventId(): string | undefined;
93
+ withId(id: number): MemoryGovernanceEntry;
94
+ withControl(params: GovernanceControlParams): MemoryGovernanceEntry;
95
+ isBlocked(now?: Date): boolean;
96
+ toJSON(now?: Date): MemoryGovernanceEntryJson;
97
+ toParams(): MemoryGovernanceEntryParams;
98
+ }
99
+ export declare function assertMemoryGovernanceSurface(value: string): MemoryGovernanceSurface;
100
+ export declare function assertMemoryGovernanceControl(value: string): MemoryGovernanceControl;
@@ -0,0 +1,65 @@
1
+ export declare const MEMORY_UTILITY_SURFACES: readonly ["fact", "persona", "graph", "link", "dream"];
2
+ export type MemoryUtilitySurface = (typeof MEMORY_UTILITY_SURFACES)[number];
3
+ export declare const MEMORY_UTILITY_CONTROLS: readonly ["record_access", "rank", "pin", "mark_evergreen"];
4
+ export type MemoryUtilityControl = (typeof MEMORY_UTILITY_CONTROLS)[number];
5
+ export interface MemoryUtilityMetricParams {
6
+ id?: number | undefined;
7
+ surface: MemoryUtilitySurface;
8
+ targetId: string;
9
+ project?: string | undefined;
10
+ accessCount?: number | undefined;
11
+ lastAccessedAt?: Date | null | undefined;
12
+ lastRankedAt?: Date | null | undefined;
13
+ utilityScore?: number | undefined;
14
+ importanceScore?: number | undefined;
15
+ evergreen?: boolean | undefined;
16
+ pinned?: boolean | undefined;
17
+ halfLifeDays?: number | null | undefined;
18
+ metadata?: Record<string, unknown> | undefined;
19
+ createdAt?: Date | undefined;
20
+ updatedAt?: Date | undefined;
21
+ }
22
+ export interface MemoryUtilityMetricJson {
23
+ id?: number | undefined;
24
+ surface: MemoryUtilitySurface;
25
+ target_id: string;
26
+ project?: string | undefined;
27
+ access_count: number;
28
+ last_accessed_at: string | null;
29
+ last_ranked_at: string | null;
30
+ utility_score: number;
31
+ importance_score: number;
32
+ evergreen: boolean;
33
+ pinned: boolean;
34
+ half_life_days: number | null;
35
+ metadata?: Record<string, unknown> | undefined;
36
+ controls: MemoryUtilityControl[];
37
+ created_at: string;
38
+ updated_at: string;
39
+ }
40
+ export declare class MemoryUtilityMetric {
41
+ private readonly params;
42
+ private constructor();
43
+ static create(params: MemoryUtilityMetricParams): MemoryUtilityMetric;
44
+ get id(): number | undefined;
45
+ get surface(): MemoryUtilitySurface;
46
+ get targetId(): string;
47
+ get project(): string | undefined;
48
+ get accessCount(): number;
49
+ get lastAccessedAt(): Date | null;
50
+ get lastRankedAt(): Date | null;
51
+ get utilityScore(): number;
52
+ get importanceScore(): number;
53
+ get evergreen(): boolean;
54
+ get pinned(): boolean;
55
+ get halfLifeDays(): number | null;
56
+ get metadata(): Record<string, unknown> | undefined;
57
+ get controls(): MemoryUtilityControl[];
58
+ get createdAt(): Date;
59
+ get updatedAt(): Date;
60
+ withId(id: number): MemoryUtilityMetric;
61
+ recordAccess(accessedAt: Date): MemoryUtilityMetric;
62
+ markRanked(rankedAt: Date): MemoryUtilityMetric;
63
+ toParams(): MemoryUtilityMetricParams;
64
+ toJSON(): MemoryUtilityMetricJson;
65
+ }
@@ -0,0 +1,67 @@
1
+ import type { MemoryEventScope, MemoryEventVisibility } from "./memory-event.js";
2
+ export declare const PERSONA_ENTRY_KINDS: readonly ["preference", "procedure", "correction", "decision_pattern", "friction_pattern"];
3
+ export type PersonaEntryKind = (typeof PERSONA_ENTRY_KINDS)[number];
4
+ export type PersonaReviewStatus = "pending_review" | "reviewed";
5
+ export declare const PERSONA_ENTRY_CONTROLS: readonly ["suppress", "invalidate", "expire", "review"];
6
+ export interface PersonaEntryParams {
7
+ id?: number | undefined;
8
+ entryId: string;
9
+ kind: PersonaEntryKind;
10
+ content: string;
11
+ project?: string | undefined;
12
+ visibility: MemoryEventVisibility;
13
+ sourceEventIds: string[];
14
+ sourceKinds: string[];
15
+ confidence: number;
16
+ scope: MemoryEventScope;
17
+ reviewStatus: PersonaReviewStatus;
18
+ reviewAfter: Date;
19
+ expiresAt?: Date | null | undefined;
20
+ why: string;
21
+ createdAt?: Date | undefined;
22
+ updatedAt?: Date | undefined;
23
+ }
24
+ export interface PersonaEntryJson {
25
+ id?: number | undefined;
26
+ entry_id: string;
27
+ kind: PersonaEntryKind;
28
+ content: string;
29
+ project?: string | undefined;
30
+ visibility: MemoryEventVisibility;
31
+ source_event_ids: string[];
32
+ source_kinds: string[];
33
+ confidence: number;
34
+ scope: MemoryEventScope;
35
+ review_status: PersonaReviewStatus;
36
+ review_after: string;
37
+ expires_at: string | null;
38
+ why: string;
39
+ controls: string[];
40
+ created_at: string;
41
+ updated_at: string;
42
+ }
43
+ export declare class PersonaEntry {
44
+ private readonly params;
45
+ private constructor();
46
+ static create(params: PersonaEntryParams): PersonaEntry;
47
+ get id(): number | undefined;
48
+ get entryId(): string;
49
+ get kind(): PersonaEntryKind;
50
+ get content(): string;
51
+ get project(): string | undefined;
52
+ get visibility(): MemoryEventVisibility;
53
+ get sourceEventIds(): string[];
54
+ get sourceKinds(): string[];
55
+ get confidence(): number;
56
+ get scope(): MemoryEventScope;
57
+ get reviewStatus(): PersonaReviewStatus;
58
+ get reviewAfter(): Date;
59
+ get expiresAt(): Date | null;
60
+ get why(): string;
61
+ get controls(): string[];
62
+ get createdAt(): Date;
63
+ get updatedAt(): Date;
64
+ withId(id: number): PersonaEntry;
65
+ toJSON(): PersonaEntryJson;
66
+ toParams(): PersonaEntryParams;
67
+ }
@@ -0,0 +1,35 @@
1
+ export type CapabilitySignal = "env-injection" | "masked-metadata" | "proofs" | "fingerprints";
2
+ export type CapabilityProviderStatusValue = "available" | "optional_unavailable" | "reference_only";
3
+ export type CapabilityReferenceStatus = "env_available" | "reference_only" | "plaintext_config_deprecated";
4
+ export type CapabilitySecretSource = "environment" | "plaintext-config" | "missing";
5
+ export interface MaskedCapabilityReference {
6
+ scheme: string;
7
+ provider: string;
8
+ maskedReference: string;
9
+ fingerprint: string;
10
+ }
11
+ export interface CapabilityProviderStatus {
12
+ provider: string;
13
+ optional: boolean;
14
+ available: boolean;
15
+ status: CapabilityProviderStatusValue;
16
+ statusSource: "path" | "reference";
17
+ allowedSignals: CapabilitySignal[];
18
+ rawSecretAccess: "forbidden";
19
+ warnings: string[];
20
+ }
21
+ export interface CapabilityReferenceStatusReport extends MaskedCapabilityReference {
22
+ source: "embedding.apiKeyRef";
23
+ runtimeSecretSource: CapabilitySecretSource;
24
+ status: CapabilityReferenceStatus;
25
+ envVar?: string | undefined;
26
+ note: string;
27
+ }
28
+ export interface CapabilityInteropStatus {
29
+ providers: CapabilityProviderStatus[];
30
+ references: CapabilityReferenceStatusReport[];
31
+ warnings: string[];
32
+ }
33
+ export interface ICapabilityStatusProvider {
34
+ getStatus(): CapabilityInteropStatus;
35
+ }
@@ -9,6 +9,27 @@
9
9
  * value objects and primitive types.
10
10
  */
11
11
  import type { EmbeddingResult } from "../value-objects/embedding-result.js";
12
+ /**
13
+ * Stable provider error categories the application layer can react to without
14
+ * knowing provider-specific transport details.
15
+ */
16
+ export type EmbeddingProviderErrorKind = "payload_too_large" | "provider_error";
17
+ export interface EmbeddingProviderErrorOptions {
18
+ kind: EmbeddingProviderErrorKind;
19
+ message: string;
20
+ status?: number | undefined;
21
+ retryable?: boolean | undefined;
22
+ metadata?: Record<string, string | number | boolean | null> | undefined;
23
+ cause?: unknown;
24
+ }
25
+ export declare class EmbeddingProviderError extends Error {
26
+ readonly kind: EmbeddingProviderErrorKind;
27
+ readonly status?: number | undefined;
28
+ readonly retryable: boolean;
29
+ readonly metadata: Record<string, string | number | boolean | null>;
30
+ constructor(options: EmbeddingProviderErrorOptions);
31
+ }
32
+ export declare function isEmbeddingProviderError(error: unknown, kind?: EmbeddingProviderErrorKind): error is EmbeddingProviderError;
12
33
  /**
13
34
  * Progress update during model download or initialization.
14
35
  */
@@ -7,6 +7,7 @@
7
7
  export type { ISessionRepository, IMessageRepository, IToolUseRepository, ILinkRepository, IExtractionStateRepository, IEmbeddingRepository, IMemoryFileRepository, IFrictionRepository, IBackfillStateRepository, BackfillStatusCounts, FrictionStats, UnembeddedMessage, EmbeddingBatchItem, EmbeddingServiceConfig, IFactRepository, IExtractionLogRepository, ExtractionLogEntry, } from "./repositories.js";
8
8
  export type { IEmbeddingProvider, DownloadProgress, EmbeddingModelInfo, } from "./embedding.js";
9
9
  export type { IExtractionProvider, } from "./extraction.js";
10
+ export type { CapabilityInteropStatus, CapabilityProviderStatus, CapabilityProviderStatusValue, CapabilityReferenceStatus, CapabilityReferenceStatusReport, CapabilitySecretSource, CapabilitySignal, ICapabilityStatusProvider, MaskedCapabilityReference, } from "./capability.js";
10
11
  export type { IRedactor, JsonRedactionResult, RedactionFinding, RedactionKind, RedactionResult, } from "./redactor.js";
11
12
  export type { ISearchService, SearchOptions, SearchMode, HybridSearchOptions, IStatsService, StatsResult, ProjectStats, ISummaryGenerator, QmdSearchResult, QmdHealthInfo, IExternalSearchProvider, IAmbientContextWriter, } from "./services.js";
12
13
  export type { ISessionSource, IEventParser, IProjectNameResolver, IMemoryFileScanner, SessionFileInfo, MemoryFileInfo, } from "./sources.js";
@@ -2,6 +2,9 @@ export type RedactionKind = "api_key" | "aws_access_key" | "bearer_token" | "env
2
2
  export interface RedactionFinding {
3
3
  kind: RedactionKind;
4
4
  placeholder: string;
5
+ hash?: string | undefined;
6
+ ruleVersion?: string | undefined;
7
+ path?: string | undefined;
5
8
  }
6
9
  export interface RedactionResult {
7
10
  text: string;
@@ -20,6 +20,11 @@ import type { FrictionEntry, FrictionSeverity, FrictionStatus } from "../entitie
20
20
  import type { BackfillState } from "../entities/backfill-state.js";
21
21
  import type { ProjectPath } from "../value-objects/project-path.js";
22
22
  import type { Fact } from "../entities/fact.js";
23
+ import type { PersonaEntry, PersonaEntryKind } from "../entities/persona-entry.js";
24
+ import type { GraphEdge } from "../entities/graph-edge.js";
25
+ import type { MemoryUtilityMetric, MemoryUtilitySurface } from "../entities/memory-utility-metric.js";
26
+ import type { MemoryGovernanceEntry, MemoryGovernanceStatus, MemoryGovernanceSurface } from "../entities/memory-governance.js";
27
+ import type { MemoryEventEnvelope } from "../entities/memory-event.js";
23
28
  /**
24
29
  * Options for filtering session list.
25
30
  */
@@ -342,6 +347,38 @@ export interface EmbeddingBatchItem {
342
347
  /** The embedding vector */
343
348
  embedding: Float32Array;
344
349
  }
350
+ export type EmbeddingSkipReason = "payload_too_large";
351
+ /**
352
+ * Durable model-scoped record for messages the current provider/model cannot
353
+ * embed safely. It deliberately stores a content hash and byte size instead of
354
+ * raw content so skip state remains useful without becoming a leakage surface.
355
+ */
356
+ export interface EmbeddingSkipRecordInput {
357
+ /** The integer rowid matching messages_meta.rowid */
358
+ messageId: number;
359
+ /** Hash identifying the provider/model/dimension configuration */
360
+ modelHash: string;
361
+ /** Human-readable model name */
362
+ modelName: string;
363
+ /** Provider identifier */
364
+ provider: string;
365
+ /** Stable skip reason */
366
+ reason: EmbeddingSkipReason;
367
+ /** Whether retrying the exact same item/model is expected to help */
368
+ retryable: boolean;
369
+ /** SHA-256 hash of the original message content */
370
+ contentHash: string;
371
+ /** UTF-8 byte size of the original message content */
372
+ contentBytes: number;
373
+ /** Sanitized provider/application error context */
374
+ safeError?: string | undefined;
375
+ /** Optional explicit skip timestamp */
376
+ skippedAt?: Date | string | undefined;
377
+ }
378
+ export interface EmbeddingSkipRecord extends EmbeddingSkipRecordInput {
379
+ id: number;
380
+ skippedAt: string;
381
+ }
345
382
  /**
346
383
  * Domain-layer configuration contract for the embedding service.
347
384
  *
@@ -359,6 +396,8 @@ export interface EmbeddingServiceConfig {
359
396
  dimensions: number;
360
397
  /** Number of messages to process per batch */
361
398
  batchSize: number;
399
+ /** Maximum estimated JSON payload bytes to send in a provider request */
400
+ maxBatchBytes?: number | undefined;
362
401
  }
363
402
  /**
364
403
  * Repository port for embedding data access.
@@ -381,7 +420,18 @@ export interface IEmbeddingRepository {
381
420
  * @param limit Maximum number of messages to return
382
421
  * @returns Array of unembedded messages ordered by rowid ASC
383
422
  */
384
- findUnembedded(limit: number): UnembeddedMessage[];
423
+ findUnembedded(limit: number, modelHash?: string): UnembeddedMessage[];
424
+ /**
425
+ * Persist a model-scoped skipped message without storing raw message content.
426
+ * @param record Sanitized skip metadata
427
+ */
428
+ markSkipped(record: EmbeddingSkipRecordInput): void;
429
+ /**
430
+ * Count skipped messages, optionally for a specific model hash.
431
+ * @param modelHash Optional model hash filter
432
+ * @returns Number of skipped message records
433
+ */
434
+ getSkippedCount(modelHash?: string): number;
385
435
  /**
386
436
  * Store a batch of embeddings in a single transaction.
387
437
  * @param items Array of embedding batch items (rowid + vector)
@@ -493,6 +543,79 @@ export interface FrictionPattern {
493
543
  count: number;
494
544
  entries: FrictionEntry[];
495
545
  }
546
+ /**
547
+ * Durable friction query options.
548
+ */
549
+ export interface FrictionQueryOptions {
550
+ status?: FrictionStatus | undefined;
551
+ severity?: FrictionSeverity | undefined;
552
+ category?: string | undefined;
553
+ tool?: string | undefined;
554
+ sourceProject?: string | undefined;
555
+ since?: Date | undefined;
556
+ descriptionContains?: string | undefined;
557
+ contextContains?: string | undefined;
558
+ limit?: number | undefined;
559
+ }
560
+ /**
561
+ * Durable friction query result.
562
+ */
563
+ export interface FrictionQueryResult {
564
+ entries: FrictionEntry[];
565
+ totalCount: number;
566
+ }
567
+ export interface PersonaListOptions {
568
+ project?: string | undefined;
569
+ visibility?: "project" | "workspace" | "global" | undefined;
570
+ kind?: PersonaEntryKind | undefined;
571
+ limit?: number | undefined;
572
+ }
573
+ export interface PersonaContextOptions {
574
+ includeGlobal?: boolean | undefined;
575
+ limit?: number | undefined;
576
+ }
577
+ export interface IPersonaRepository {
578
+ save(entry: PersonaEntry): Promise<PersonaEntry>;
579
+ saveMany(entries: PersonaEntry[]): Promise<PersonaEntry[]>;
580
+ findByEntryId(entryId: string): Promise<PersonaEntry | null>;
581
+ findAll(options?: PersonaListOptions): Promise<PersonaEntry[]>;
582
+ findForContext(project: string, options?: PersonaContextOptions): Promise<PersonaEntry[]>;
583
+ deleteByProject(project: string): Promise<void>;
584
+ clearAll(): Promise<void>;
585
+ }
586
+ export interface GraphEdgeQueryOptions {
587
+ project?: string | undefined;
588
+ includeGlobal?: boolean | undefined;
589
+ asOf?: Date | undefined;
590
+ minConfidence?: number | undefined;
591
+ nodeId?: string | undefined;
592
+ relationship?: string | undefined;
593
+ limit?: number | undefined;
594
+ }
595
+ export interface IGraphRepository {
596
+ save(edge: GraphEdge): Promise<GraphEdge>;
597
+ saveMany(edges: GraphEdge[]): Promise<GraphEdge[]>;
598
+ findByEdgeId(edgeId: string): Promise<GraphEdge | null>;
599
+ findCurrent(options?: GraphEdgeQueryOptions): Promise<GraphEdge[]>;
600
+ pruneStale(cutoff: Date): Promise<number>;
601
+ deleteByProject(project: string): Promise<void>;
602
+ clearAll(): Promise<void>;
603
+ }
604
+ /**
605
+ * Repository for utility/ranking metrics across governed memory surfaces.
606
+ *
607
+ * Metrics are keyed by surface + target id so ranking can work for existing
608
+ * facts/persona/graph entries and future dream/link projections without adding
609
+ * per-surface coupling to context assembly.
610
+ */
611
+ export interface IMemoryUtilityRepository {
612
+ save(metric: MemoryUtilityMetric): Promise<MemoryUtilityMetric>;
613
+ findByTarget(surface: MemoryUtilitySurface, targetId: string): Promise<MemoryUtilityMetric | null>;
614
+ findByTargetIds(surface: MemoryUtilitySurface, targetIds: string[]): Promise<MemoryUtilityMetric[]>;
615
+ recordAccess(surface: MemoryUtilitySurface, targetId: string, accessedAt: Date): Promise<MemoryUtilityMetric>;
616
+ deleteByProject(project: string): Promise<void>;
617
+ clearAll(): Promise<void>;
618
+ }
496
619
  /**
497
620
  * Repository for FrictionEntry entities.
498
621
  *
@@ -529,6 +652,13 @@ export interface IFrictionRepository {
529
652
  sourceProject?: string;
530
653
  limit?: number;
531
654
  }): Promise<FrictionEntry[]>;
655
+ /**
656
+ * Query friction entries with stable durable contract semantics.
657
+ * Returns totalCount before limit is applied.
658
+ * @param options Durable query filters
659
+ * @returns Matching entries and total matching count
660
+ */
661
+ query(options?: FrictionQueryOptions): Promise<FrictionQueryResult>;
532
662
  /**
533
663
  * Resolve a friction entry with a resolution description.
534
664
  * @param id The entry database ID
@@ -656,3 +786,27 @@ export interface IExtractionLogRepository {
656
786
  findAll(): Promise<ExtractionLogEntry[]>;
657
787
  clearAll(): Promise<void>;
658
788
  }
789
+ /**
790
+ * Options for listing governed derived memory entries.
791
+ */
792
+ export interface MemoryGovernanceListOptions {
793
+ surface?: MemoryGovernanceSurface | undefined;
794
+ targetId?: string | undefined;
795
+ project?: string | undefined;
796
+ status?: MemoryGovernanceStatus | undefined;
797
+ limit?: number | undefined;
798
+ }
799
+ /**
800
+ * Repository for consent/provenance governance state.
801
+ *
802
+ * This stores the current projection of control events. Canonical event logs
803
+ * remain the source of truth; this projection makes policy checks cheap.
804
+ */
805
+ export interface IMemoryGovernanceRepository {
806
+ save(entry: MemoryGovernanceEntry): Promise<MemoryGovernanceEntry>;
807
+ findByTarget(surface: MemoryGovernanceSurface, targetId: string): Promise<MemoryGovernanceEntry | null>;
808
+ findByTargetIds(surface: MemoryGovernanceSurface, targetIds: string[]): Promise<MemoryGovernanceEntry[]>;
809
+ findAll(options?: MemoryGovernanceListOptions): Promise<MemoryGovernanceEntry[]>;
810
+ applyMemoryEvent(event: MemoryEventEnvelope): Promise<MemoryGovernanceEntry | null>;
811
+ clearAll(): Promise<void>;
812
+ }
@@ -79,7 +79,7 @@ export interface IProjectNameResolver {
79
79
  /**
80
80
  * Resolve a project name from a full encoded path.
81
81
  *
82
- * @param encodedPath The encoded directory path (e.g., "C--Users-Destiny-Projects-memory-nexus")
82
+ * @param encodedPath The encoded directory path (e.g., "C--Projects-memory-nexus")
83
83
  * @returns The resolved project name (e.g., "memory-nexus")
84
84
  */
85
85
  resolveFromEncodedPath(encodedPath: string): string;
@@ -13,7 +13,7 @@ import { ProjectPath } from "../value-objects/index.js";
13
13
  export declare class PathDecoder {
14
14
  /**
15
15
  * Decode an encoded project directory name to a ProjectPath value object.
16
- * @param encoded The encoded directory name (e.g., "C--Users-Destiny-Projects-foo")
16
+ * @param encoded The encoded directory name (e.g., "C--Projects-foo")
17
17
  * @returns ProjectPath value object with decoded path
18
18
  */
19
19
  static decodeProjectDirectory(encoded: string): ProjectPath;
@@ -34,13 +34,13 @@ export declare class ProjectPath {
34
34
  private constructor();
35
35
  /**
36
36
  * Create ProjectPath from a decoded (original) path.
37
- * @param path The original filesystem path (e.g., "C:\Users\Destiny\Projects\foo")
37
+ * @param path The original filesystem path (e.g., "C:\Projects\foo")
38
38
  * @throws Error if path is empty or whitespace-only
39
39
  */
40
40
  static fromDecoded(path: string): ProjectPath;
41
41
  /**
42
42
  * Create ProjectPath from an encoded path.
43
- * @param encoded The encoded path (e.g., "C--Users-Destiny-Projects-foo")
43
+ * @param encoded The encoded path (e.g., "C--Projects-foo")
44
44
  * @throws Error if path is empty or whitespace-only
45
45
  */
46
46
  static fromEncoded(encoded: string): ProjectPath;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,6 @@
10
10
  */
11
11
  export * from "./domain/index.js";
12
12
  export * from "./application/index.js";
13
- export { executeSyncCommand, executeSearchCommand, executeListCommand, executeStatsCommand, executeContextCommand, executeRelatedCommand, executeShowCommand, executeBrowseCommand, executeQueryCommand, executeInstallCommand, executeUninstallCommand, executeStatusCommand, executeDoctorCommand, executePurgeCommand, executeExportCommand, executeImportCommand, executeCompletionCommand, executeFrictionCommand, } from "./presentation/cli/commands/index.js";
13
+ export { executeSyncCommand, executeSearchCommand, executeListCommand, executeStatsCommand, executeContextCommand, executeRelatedCommand, executeShowCommand, executeBrowseCommand, executeQueryCommand, executeInstallCommand, executeUninstallCommand, executeStatusCommand, executeDoctorCommand, executeAuditSecretsCommand, executePurgeCommand, executeExportCommand, executeImportCommand, executeCompletionCommand, executeFrictionCommand, } from "./presentation/cli/commands/index.js";
14
14
  export type { CommandResult } from "./presentation/cli/commands/index.js";
15
- export type { SyncCommandOptions, EmbeddingPassDeps, BackgroundModeDeps, SearchCommandOptions, ListCommandOptions, StatsCommandOptions, ContextCommandOptions, RelatedCommandOptions, ShowCommandOptions, QueryCommandOptions, BrowseCommandOptions, InstallOptions, UninstallOptions, DoctorOptions, PurgeCommandOptions, PurgeResult, ExportOptions, ImportOptions, ShellType, StatusInfo, EmbeddingStatus, StatusOptions, GatherStatusOptions, FrictionCommandOptions, FrictionLogOptions, FrictionListOptions, FrictionResolveOptions, FrictionExecuteOptions, } from "./presentation/cli/commands/index.js";
15
+ export type { SyncCommandOptions, EmbeddingPassDeps, BackgroundModeDeps, SearchCommandOptions, ListCommandOptions, StatsCommandOptions, ContextCommandOptions, RelatedCommandOptions, ShowCommandOptions, QueryCommandOptions, BrowseCommandOptions, InstallOptions, UninstallOptions, DoctorOptions, AuditSecretsOptions, PurgeCommandOptions, PurgeResult, ExportOptions, ImportOptions, ShellType, StatusInfo, EmbeddingStatus, StatusOptions, GatherStatusOptions, FrictionCommandOptions, FrictionLogOptions, FrictionListOptions, FrictionResolveOptions, FrictionExecuteOptions, } from "./presentation/cli/commands/index.js";