@sentropic/cluster-mesh 0.24.0 → 0.25.0

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 (97) hide show
  1. package/README.md +5 -0
  2. package/dist/engram-memory/wire-adaptation.d.ts +1 -1
  3. package/dist/engram-memory/wire-adaptation.d.ts.map +1 -1
  4. package/dist/engram-memory/wire-adaptation.js +24 -8
  5. package/dist/engram-memory/wire-adaptation.js.map +1 -1
  6. package/dist/identity-contracts/access.d.ts +54 -0
  7. package/dist/identity-contracts/access.d.ts.map +1 -0
  8. package/dist/identity-contracts/access.js +168 -0
  9. package/dist/identity-contracts/access.js.map +1 -0
  10. package/dist/identity-contracts/accounts.d.ts +44 -0
  11. package/dist/identity-contracts/accounts.d.ts.map +1 -0
  12. package/dist/identity-contracts/accounts.js +149 -0
  13. package/dist/identity-contracts/accounts.js.map +1 -0
  14. package/dist/identity-contracts/descriptors.d.ts +12 -0
  15. package/dist/identity-contracts/descriptors.d.ts.map +1 -0
  16. package/dist/identity-contracts/descriptors.js +57 -0
  17. package/dist/identity-contracts/descriptors.js.map +1 -0
  18. package/dist/identity-contracts/doubles.d.ts +115 -0
  19. package/dist/identity-contracts/doubles.d.ts.map +1 -0
  20. package/dist/identity-contracts/doubles.js +340 -0
  21. package/dist/identity-contracts/doubles.js.map +1 -0
  22. package/dist/identity-contracts/enforcement.d.ts +27 -0
  23. package/dist/identity-contracts/enforcement.d.ts.map +1 -0
  24. package/dist/identity-contracts/enforcement.js +155 -0
  25. package/dist/identity-contracts/enforcement.js.map +1 -0
  26. package/dist/identity-contracts/errors.d.ts +71 -0
  27. package/dist/identity-contracts/errors.d.ts.map +1 -0
  28. package/dist/identity-contracts/errors.js +129 -0
  29. package/dist/identity-contracts/errors.js.map +1 -0
  30. package/dist/identity-contracts/index.d.ts +12 -0
  31. package/dist/identity-contracts/index.d.ts.map +1 -0
  32. package/dist/identity-contracts/index.js +13 -0
  33. package/dist/identity-contracts/index.js.map +1 -0
  34. package/dist/identity-contracts/ports.d.ts +116 -0
  35. package/dist/identity-contracts/ports.d.ts.map +1 -0
  36. package/dist/identity-contracts/ports.js +7 -0
  37. package/dist/identity-contracts/ports.js.map +1 -0
  38. package/dist/identity-contracts/resolution.d.ts +56 -0
  39. package/dist/identity-contracts/resolution.d.ts.map +1 -0
  40. package/dist/identity-contracts/resolution.js +87 -0
  41. package/dist/identity-contracts/resolution.js.map +1 -0
  42. package/dist/identity-contracts/tenancy.d.ts +52 -0
  43. package/dist/identity-contracts/tenancy.d.ts.map +1 -0
  44. package/dist/identity-contracts/tenancy.js +171 -0
  45. package/dist/identity-contracts/tenancy.js.map +1 -0
  46. package/dist/identity-contracts/types.d.ts +253 -0
  47. package/dist/identity-contracts/types.d.ts.map +1 -0
  48. package/dist/identity-contracts/types.js +7 -0
  49. package/dist/identity-contracts/types.js.map +1 -0
  50. package/dist/identity-contracts/workspaces.d.ts +37 -0
  51. package/dist/identity-contracts/workspaces.d.ts.map +1 -0
  52. package/dist/identity-contracts/workspaces.js +118 -0
  53. package/dist/identity-contracts/workspaces.js.map +1 -0
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -0
  57. package/dist/index.js.map +1 -1
  58. package/dist/integrations/mcp/memory-compose.d.ts +11 -0
  59. package/dist/integrations/mcp/memory-compose.d.ts.map +1 -0
  60. package/dist/integrations/mcp/memory-compose.js +79 -0
  61. package/dist/integrations/mcp/memory-compose.js.map +1 -0
  62. package/dist/integrations/mcp/memory-definition.d.ts +28 -0
  63. package/dist/integrations/mcp/memory-definition.d.ts.map +1 -0
  64. package/dist/integrations/mcp/memory-definition.js +2 -0
  65. package/dist/integrations/mcp/memory-definition.js.map +1 -0
  66. package/dist/integrations/mcp/memory-manifest.d.ts +4 -0
  67. package/dist/integrations/mcp/memory-manifest.d.ts.map +1 -0
  68. package/dist/integrations/mcp/memory-manifest.js +9 -0
  69. package/dist/integrations/mcp/memory-manifest.js.map +1 -0
  70. package/dist/integrations/mcp/memory-transport.d.ts +21 -0
  71. package/dist/integrations/mcp/memory-transport.d.ts.map +1 -0
  72. package/dist/integrations/mcp/memory-transport.js +47 -0
  73. package/dist/integrations/mcp/memory-transport.js.map +1 -0
  74. package/dist/integrations/mcp/memory.d.ts +19 -0
  75. package/dist/integrations/mcp/memory.d.ts.map +1 -0
  76. package/dist/integrations/mcp/memory.js +40 -0
  77. package/dist/integrations/mcp/memory.js.map +1 -0
  78. package/dist/loaders/mcp/index.d.ts +1 -0
  79. package/dist/loaders/mcp/index.d.ts.map +1 -1
  80. package/dist/loaders/mcp/index.js +1 -0
  81. package/dist/loaders/mcp/index.js.map +1 -1
  82. package/dist/loaders/mcp/memory.d.ts +6 -0
  83. package/dist/loaders/mcp/memory.d.ts.map +1 -0
  84. package/dist/loaders/mcp/memory.js +9 -0
  85. package/dist/loaders/mcp/memory.js.map +1 -0
  86. package/dist/modules/catalog.d.ts +2 -0
  87. package/dist/modules/catalog.d.ts.map +1 -1
  88. package/dist/modules/catalog.js +15 -1
  89. package/dist/modules/catalog.js.map +1 -1
  90. package/dist/modules/contracts.d.ts +1 -1
  91. package/dist/modules/contracts.d.ts.map +1 -1
  92. package/dist/modules/contracts.js +2 -0
  93. package/dist/modules/contracts.js.map +1 -1
  94. package/docs/memory-mcp-candidate.md +46 -0
  95. package/docs/memory-mcp.md +98 -0
  96. package/examples/memory-mcp-stdio.mjs +42 -0
  97. package/package.json +11 -2
@@ -0,0 +1,155 @@
1
+ // Identity core contracts: cascading person revocation (F14) and the fresh
2
+ // per-request authorisation decision (F09 inputs, F15 decision).
3
+ // A refusal yields a stable reason; consumers map it to an empty tool set,
4
+ // never to a partial catalogue.
5
+ import { IdentityNotFoundError, MembershipTransitionError } from './errors.js';
6
+ import { systemIdentityClock, } from './types.js';
7
+ /** §2.7: one session authority per input kind; the mapping is total. */
8
+ const SESSION_AUTHORITY_BY_INPUT_KIND = {
9
+ first_party_http: 'login_session',
10
+ conversation_turn: 'conversation_session',
11
+ agent_plane: 'agent_session',
12
+ runtime_pty: 'runtime_registration',
13
+ };
14
+ export function createPersonCascade(input) {
15
+ const clock = input.clock ?? systemIdentityClock;
16
+ return {
17
+ async revokePerson(userId, mode, options) {
18
+ const now = clock();
19
+ const steps = [];
20
+ try {
21
+ const revoked = await input.sessions.revokeAllSessionsForUser(userId, now);
22
+ steps.push({ step: 'login_sessions', outcome: 'applied', detail: `${revoked} sessions revoked` });
23
+ }
24
+ catch (error) {
25
+ steps.push({ step: 'login_sessions', outcome: 'queued', detail: String(error) });
26
+ }
27
+ steps.push({
28
+ step: 'remote_reader_sessions',
29
+ outcome: 'not_applicable',
30
+ detail: 'remote/reader session plane not bound in this contract stage',
31
+ });
32
+ steps.push({
33
+ step: 'connector_grants',
34
+ outcome: 'not_applicable',
35
+ detail: 'connector grant plane not bound in this contract stage',
36
+ });
37
+ try {
38
+ const memberships = await input.memberships.listMembershipsForUser(userId);
39
+ let suspended = 0;
40
+ for (const membership of memberships) {
41
+ if (membership.status !== 'approved')
42
+ continue;
43
+ try {
44
+ await input.memberships.setMembershipState(userId, membership.tenantId, {
45
+ status: 'suspended',
46
+ tenantRole: membership.tenantRole,
47
+ decidedBy: options.actorId,
48
+ decidedAt: now,
49
+ updatedAt: now,
50
+ });
51
+ suspended += 1;
52
+ }
53
+ catch (error) {
54
+ if (!(error instanceof MembershipTransitionError))
55
+ throw error;
56
+ }
57
+ }
58
+ steps.push({ step: 'tenant_memberships', outcome: 'applied', detail: `${suspended} memberships suspended` });
59
+ }
60
+ catch (error) {
61
+ steps.push({ step: 'tenant_memberships', outcome: 'queued', detail: String(error) });
62
+ }
63
+ if (input.agentPlane) {
64
+ try {
65
+ const closed = await input.agentPlane.closeAgentSessionsForUser(userId);
66
+ steps.push({ step: 'agent_plane', outcome: 'applied', detail: `${closed} agent sessions closed` });
67
+ }
68
+ catch (error) {
69
+ steps.push({ step: 'agent_plane', outcome: 'queued', detail: String(error) });
70
+ }
71
+ }
72
+ else {
73
+ steps.push({ step: 'agent_plane', outcome: 'queued', detail: 'agent-plane hook not bound; M4 fills this step' });
74
+ }
75
+ steps.push({
76
+ step: 'purpose_grants',
77
+ outcome: 'not_applicable',
78
+ detail: 'purpose grants are agent-plane records; M4 fills this step',
79
+ });
80
+ steps.push({
81
+ step: 'catalogue',
82
+ outcome: 'not_applicable',
83
+ detail: 'tool catalogue surface not bound in this contract stage; §2.7 invalidation applies from the first landed catalogue',
84
+ });
85
+ try {
86
+ const account = await input.accounts.findAccount(userId);
87
+ if (!account)
88
+ throw new IdentityNotFoundError('user', userId);
89
+ if (mode === 'delete') {
90
+ await input.accounts.deleteAccount(userId, now);
91
+ steps.push({ step: 'account', outcome: 'applied', detail: 'account deleted' });
92
+ }
93
+ else {
94
+ await input.accounts.setAccountStatus(userId, 'disabled', now);
95
+ steps.push({ step: 'account', outcome: 'applied', detail: 'account disabled' });
96
+ }
97
+ }
98
+ catch (error) {
99
+ steps.push({ step: 'account', outcome: 'queued', detail: String(error) });
100
+ }
101
+ const receipt = { userId, mode, steps, at: now };
102
+ await input.audit.append({
103
+ at: now,
104
+ kind: `person.revoked.${mode}`,
105
+ actorId: options.actorId,
106
+ subjectId: userId,
107
+ });
108
+ return receipt;
109
+ },
110
+ };
111
+ }
112
+ export function createFreshDecision(input) {
113
+ return {
114
+ async decide(lookup, now) {
115
+ const sessionAuthority = SESSION_AUTHORITY_BY_INPUT_KIND[lookup.inputKind];
116
+ const account = await input.accounts.findAccount(lookup.userId);
117
+ if (!account || account.accountStatus !== 'active') {
118
+ return { allow: false, sessionAuthority, reason: 'account_not_active' };
119
+ }
120
+ if (lookup.inputKind !== 'first_party_http') {
121
+ // The conversation, agent and runtime authority stores land with their
122
+ // planes (A2.3, M4); until they are bound these kinds fail closed.
123
+ return { allow: false, sessionAuthority, reason: 'session_authority_unavailable' };
124
+ }
125
+ const session = await input.sessions.findSession(lookup.sessionId);
126
+ if (!session || session.userId !== lookup.userId || session.status !== 'active' || session.expiresAt <= now) {
127
+ return { allow: false, sessionAuthority, reason: 'session_invalid' };
128
+ }
129
+ const workspace = await input.workspaces.findWorkspace(lookup.workspaceId);
130
+ if (!workspace)
131
+ return { allow: false, sessionAuthority, reason: 'workspace_membership_missing' };
132
+ const membership = await input.memberships.findApprovedMembership(lookup.userId, workspace.tenantId);
133
+ if (!membership || membership.status !== 'approved') {
134
+ return { allow: false, sessionAuthority, reason: 'membership_not_approved' };
135
+ }
136
+ const tenant = await input.tenants.findTenant(workspace.tenantId);
137
+ if (!tenant || tenant.status !== 'active') {
138
+ return { allow: false, sessionAuthority, reason: 'tenant_not_active' };
139
+ }
140
+ const workspaceMember = await input.workspaceMembers.findWorkspaceMember(lookup.workspaceId, lookup.userId);
141
+ if (!workspaceMember)
142
+ return { allow: false, sessionAuthority, reason: 'workspace_membership_missing' };
143
+ return {
144
+ allow: true,
145
+ sessionAuthority,
146
+ tenantId: tenant.tenantId,
147
+ tid: tenant.slug,
148
+ tenantRole: membership.tenantRole,
149
+ workspaceRole: workspaceMember.role,
150
+ scopes: [account.globalRole, `tenant:${membership.tenantRole}`, `workspace:${workspaceMember.role}`],
151
+ };
152
+ },
153
+ };
154
+ }
155
+ //# sourceMappingURL=enforcement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforcement.js","sourceRoot":"","sources":["../../src/identity-contracts/enforcement.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iEAAiE;AACjE,2EAA2E;AAC3E,gCAAgC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAW/E,OAAO,EACL,mBAAmB,GASpB,MAAM,YAAY,CAAC;AAEpB,wEAAwE;AACxE,MAAM,+BAA+B,GAAoD;IACvF,gBAAgB,EAAE,eAAe;IACjC,iBAAiB,EAAE,sBAAsB;IACzC,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,sBAAsB;CACpC,CAAC;AAUF,MAAM,UAAU,mBAAmB,CAAC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ACX,gBAAgB;gBAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,GAAG,EAAE,MAAM,CAAC,IAAI;gBAChB,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,aAAa,EAAE,eAAe,CAAC,IAAI;gBACnC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,UAAU,CAAC,UAAU,EAAE,EAAE,aAAa,eAAe,CAAC,IAAI,EAAE,CAAC;aACrG,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,71 @@
1
+ export declare class IdentityNotFoundError extends Error {
2
+ readonly entity: 'user' | 'tenant' | 'invitation' | 'session' | 'membership' | 'workspace';
3
+ readonly id?: string | undefined;
4
+ readonly code: "identity_not_found";
5
+ constructor(entity: 'user' | 'tenant' | 'invitation' | 'session' | 'membership' | 'workspace', id?: string | undefined);
6
+ }
7
+ export declare class IdentityConflictError extends Error {
8
+ readonly conflict: 'email' | 'slug' | 'duplicate' | 'last_admin';
9
+ readonly code: "identity_conflict";
10
+ constructor(conflict: 'email' | 'slug' | 'duplicate' | 'last_admin', message?: string);
11
+ }
12
+ export declare class AccountNotActiveError extends Error {
13
+ readonly userId?: string | undefined;
14
+ readonly code: "account_not_active";
15
+ constructor(userId?: string | undefined);
16
+ }
17
+ export declare class AccountTransitionError extends Error {
18
+ readonly code: "invalid_account_transition";
19
+ constructor(message?: string);
20
+ }
21
+ export declare class TenantNotActiveError extends Error {
22
+ readonly tenantId?: string | undefined;
23
+ readonly code: "tenant_not_active";
24
+ constructor(tenantId?: string | undefined);
25
+ }
26
+ export declare class TenantOffboardBlockedError extends Error {
27
+ readonly tenantId: string;
28
+ readonly liveSessions: number;
29
+ readonly code: "tenant_offboard_blocked";
30
+ constructor(tenantId: string, liveSessions: number);
31
+ }
32
+ export declare class MembershipTransitionError extends Error {
33
+ readonly code: "invalid_membership_transition";
34
+ constructor(message?: string);
35
+ }
36
+ export declare class InvitationError extends Error {
37
+ readonly reason: 'not_found' | 'expired' | 'consumed' | 'revoked';
38
+ readonly code: "invitation_invalid";
39
+ constructor(reason: 'not_found' | 'expired' | 'consumed' | 'revoked');
40
+ }
41
+ export declare class LoginSessionError extends Error {
42
+ readonly reason: 'not_found' | 'expired' | 'revoked';
43
+ readonly code: "login_session_invalid";
44
+ constructor(reason: 'not_found' | 'expired' | 'revoked');
45
+ }
46
+ export declare class DeviceCodeError extends Error {
47
+ readonly reason: 'not_found' | 'expired' | 'already_resolved';
48
+ readonly code: "device_code_invalid";
49
+ constructor(reason: 'not_found' | 'expired' | 'already_resolved');
50
+ }
51
+ export declare class WorkspaceAlreadyEnrolledError extends Error {
52
+ readonly workspaceId: string;
53
+ readonly code: "workspace_already_enrolled";
54
+ constructor(workspaceId: string);
55
+ }
56
+ export declare class SelfActionForbiddenError extends Error {
57
+ readonly action: 'approve' | 'disable' | 'reactivate' | 'delete';
58
+ readonly code: "self_action_forbidden";
59
+ constructor(action: 'approve' | 'disable' | 'reactivate' | 'delete');
60
+ }
61
+ export declare class AdminUserProtectedError extends Error {
62
+ readonly action: 'disable' | 'delete';
63
+ readonly code: "admin_user_protected";
64
+ constructor(action: 'disable' | 'delete');
65
+ }
66
+ export declare class ProofVerificationError extends Error {
67
+ readonly reason: 'not_found' | 'expired' | 'consumed' | 'revoked' | 'mismatch';
68
+ readonly code: "proof_verification_failed";
69
+ constructor(reason: 'not_found' | 'expired' | 'consumed' | 'revoked' | 'mismatch');
70
+ }
71
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/errors.ts"],"names":[],"mappings":"AAGA,qBAAa,qBAAsB,SAAQ,KAAK;IAI5C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW;IAC1F,QAAQ,CAAC,EAAE,CAAC;IAJd,QAAQ,CAAC,IAAI,uBA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// and tests can match on `code` without parsing messages.
3
+ export class IdentityNotFoundError extends Error {
4
+ entity;
5
+ id;
6
+ code = 'identity_not_found';
7
+ constructor(entity, id) {
8
+ super(`Identity ${entity} not found${id ? `: ${id}` : ''}`);
9
+ this.entity = entity;
10
+ this.id = id;
11
+ this.name = 'IdentityNotFoundError';
12
+ }
13
+ }
14
+ export class IdentityConflictError extends Error {
15
+ conflict;
16
+ code = 'identity_conflict';
17
+ constructor(conflict, message) {
18
+ super(message ?? `Identity conflict: ${conflict}`);
19
+ this.conflict = conflict;
20
+ this.name = 'IdentityConflictError';
21
+ }
22
+ }
23
+ export class AccountNotActiveError extends Error {
24
+ userId;
25
+ code = 'account_not_active';
26
+ constructor(userId) {
27
+ super(`Account is not active${userId ? `: ${userId}` : ''}`);
28
+ this.userId = userId;
29
+ this.name = 'AccountNotActiveError';
30
+ }
31
+ }
32
+ export class AccountTransitionError extends Error {
33
+ code = 'invalid_account_transition';
34
+ constructor(message = 'Account status transition is not allowed') {
35
+ super(message);
36
+ this.name = 'AccountTransitionError';
37
+ }
38
+ }
39
+ export class TenantNotActiveError extends Error {
40
+ tenantId;
41
+ code = 'tenant_not_active';
42
+ constructor(tenantId) {
43
+ super(`Tenant is not active${tenantId ? `: ${tenantId}` : ''}`);
44
+ this.tenantId = tenantId;
45
+ this.name = 'TenantNotActiveError';
46
+ }
47
+ }
48
+ export class TenantOffboardBlockedError extends Error {
49
+ tenantId;
50
+ liveSessions;
51
+ code = 'tenant_offboard_blocked';
52
+ constructor(tenantId, liveSessions) {
53
+ super(`Tenant ${tenantId} keeps ${liveSessions} live sessions; offboard is blocked without force`);
54
+ this.tenantId = tenantId;
55
+ this.liveSessions = liveSessions;
56
+ this.name = 'TenantOffboardBlockedError';
57
+ }
58
+ }
59
+ export class MembershipTransitionError extends Error {
60
+ code = 'invalid_membership_transition';
61
+ constructor(message = 'Tenant membership transition is not allowed') {
62
+ super(message);
63
+ this.name = 'MembershipTransitionError';
64
+ }
65
+ }
66
+ export class InvitationError extends Error {
67
+ reason;
68
+ code = 'invitation_invalid';
69
+ constructor(reason) {
70
+ super(`Invitation is invalid: ${reason}`);
71
+ this.reason = reason;
72
+ this.name = 'InvitationError';
73
+ }
74
+ }
75
+ export class LoginSessionError extends Error {
76
+ reason;
77
+ code = 'login_session_invalid';
78
+ constructor(reason) {
79
+ super(`Login session is invalid: ${reason}`);
80
+ this.reason = reason;
81
+ this.name = 'LoginSessionError';
82
+ }
83
+ }
84
+ export class DeviceCodeError extends Error {
85
+ reason;
86
+ code = 'device_code_invalid';
87
+ constructor(reason) {
88
+ super(`Device code is invalid: ${reason}`);
89
+ this.reason = reason;
90
+ this.name = 'DeviceCodeError';
91
+ }
92
+ }
93
+ export class WorkspaceAlreadyEnrolledError extends Error {
94
+ workspaceId;
95
+ code = 'workspace_already_enrolled';
96
+ constructor(workspaceId) {
97
+ super(`Workspace already enrolled for this repo: ${workspaceId}`);
98
+ this.workspaceId = workspaceId;
99
+ this.name = 'WorkspaceAlreadyEnrolledError';
100
+ }
101
+ }
102
+ export class SelfActionForbiddenError extends Error {
103
+ action;
104
+ code = 'self_action_forbidden';
105
+ constructor(action) {
106
+ super(`Admin action on self is forbidden, use self-service: ${action}`);
107
+ this.action = action;
108
+ this.name = 'SelfActionForbiddenError';
109
+ }
110
+ }
111
+ export class AdminUserProtectedError extends Error {
112
+ action;
113
+ code = 'admin_user_protected';
114
+ constructor(action) {
115
+ super(`Cannot ${action} admin users`);
116
+ this.action = action;
117
+ this.name = 'AdminUserProtectedError';
118
+ }
119
+ }
120
+ export class ProofVerificationError extends Error {
121
+ reason;
122
+ code = 'proof_verification_failed';
123
+ constructor(reason) {
124
+ super(`Identity proof verification failed: ${reason}`);
125
+ this.reason = reason;
126
+ this.name = 'ProofVerificationError';
127
+ }
128
+ }
129
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/identity-contracts/errors.ts"],"names":[],"mappings":"AAA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ACvC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export * from './types.js';
2
+ export * from './errors.js';
3
+ export * from './descriptors.js';
4
+ export * from './ports.js';
5
+ export * from './accounts.js';
6
+ export * from './access.js';
7
+ export * from './tenancy.js';
8
+ export * from './workspaces.js';
9
+ export * from './resolution.js';
10
+ export * from './enforcement.js';
11
+ export * from './doubles.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Identity core contracts (contract-only): public barrel.
2
+ export * from './types.js';
3
+ export * from './errors.js';
4
+ export * from './descriptors.js';
5
+ export * from './ports.js';
6
+ export * from './accounts.js';
7
+ export * from './access.js';
8
+ export * from './tenancy.js';
9
+ export * from './workspaces.js';
10
+ export * from './resolution.js';
11
+ export * from './enforcement.js';
12
+ export * from './doubles.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity-contracts/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,116 @@
1
+ import type { DeviceCodeRecord, DivergenceSample, DivergenceSummary, IdentityAuditEvent, IdentityProof, InvitationRecord, LoginSession, OAuthConsentRecord, ServiceClientBinding, TenantMembershipRecord, TenantRecord, TenantStatus, UserAccount, WorkspaceMembershipRecord, WorkspaceRecord } from './types.js';
2
+ export interface TenantRegistryStore {
3
+ createTenant(record: TenantRecord): Promise<void>;
4
+ findTenant(tenantId: string): Promise<TenantRecord | null>;
5
+ findTenantBySlug(slug: string): Promise<TenantRecord | null>;
6
+ listTenants(): Promise<readonly TenantRecord[]>;
7
+ setTenantStatus(tenantId: string, status: TenantStatus, at: string): Promise<TenantRecord>;
8
+ }
9
+ export interface UserAccountStore {
10
+ createAccount(record: UserAccount): Promise<void>;
11
+ findAccount(userId: string): Promise<UserAccount | null>;
12
+ findAccountByEmail(email: string): Promise<UserAccount | null>;
13
+ listAccounts(): Promise<readonly UserAccount[]>;
14
+ setAccountStatus(userId: string, status: UserAccount['accountStatus'], at: string): Promise<UserAccount>;
15
+ setGlobalRole(userId: string, role: UserAccount['globalRole'], at: string): Promise<UserAccount>;
16
+ deleteAccount(userId: string, at: string): Promise<void>;
17
+ }
18
+ export interface IdentityProofStore {
19
+ addProof(record: IdentityProof): Promise<void>;
20
+ findProof(proofId: string): Promise<IdentityProof | null>;
21
+ listProofsForUser(userId: string): Promise<readonly IdentityProof[]>;
22
+ markProofConsumed(proofId: string, at: string): Promise<IdentityProof>;
23
+ revokeProof(proofId: string, at: string): Promise<IdentityProof>;
24
+ }
25
+ export interface InvitationStore {
26
+ saveInvitation(record: InvitationRecord): Promise<void>;
27
+ findInvitation(invitationId: string): Promise<InvitationRecord | null>;
28
+ findInvitationByToken(token: string): Promise<InvitationRecord | null>;
29
+ /** Atomically consumes a pending invitation; false when already consumed. */
30
+ markInvitationConsumed(token: string, at: string): Promise<boolean>;
31
+ revokeInvitation(invitationId: string): Promise<InvitationRecord>;
32
+ }
33
+ export interface DeviceCodeStore {
34
+ saveDeviceCode(record: DeviceCodeRecord): Promise<void>;
35
+ findDeviceCode(deviceCode: string): Promise<DeviceCodeRecord | null>;
36
+ findDeviceCodeByUser(userCode: string): Promise<DeviceCodeRecord | null>;
37
+ /** Atomically approves a pending device code; false when already resolved. */
38
+ approveDeviceCode(userCode: string, approvedUserId: string, at: string): Promise<boolean>;
39
+ }
40
+ export interface LoginSessionStore {
41
+ createSession(record: LoginSession): Promise<void>;
42
+ findSession(sessionId: string): Promise<LoginSession | null>;
43
+ touchSession(sessionId: string, update: Pick<LoginSession, 'expiresAt' | 'refreshCount'>): Promise<LoginSession>;
44
+ revokeSession(sessionId: string, at: string): Promise<LoginSession>;
45
+ revokeAllSessionsForUser(userId: string, at: string): Promise<number>;
46
+ listSessionsForUser(userId: string): Promise<readonly LoginSession[]>;
47
+ }
48
+ export interface TenantMembershipStore {
49
+ upsertMembershipRequest(record: TenantMembershipRecord): Promise<TenantMembershipRecord>;
50
+ findMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
51
+ setMembershipState(userId: string, tenantId: string, state: Pick<TenantMembershipRecord, 'status' | 'tenantRole'> & {
52
+ readonly decidedBy: string;
53
+ readonly decidedAt: string;
54
+ readonly updatedAt: string;
55
+ }): Promise<TenantMembershipRecord>;
56
+ listMembershipsForTenant(tenantId: string): Promise<readonly TenantMembershipRecord[]>;
57
+ listMembershipsForUser(userId: string): Promise<readonly TenantMembershipRecord[]>;
58
+ findApprovedMembership(userId: string, tenantId: string): Promise<TenantMembershipRecord | null>;
59
+ }
60
+ export interface WorkspaceDirectoryStore {
61
+ enrolWorkspace(record: WorkspaceRecord): Promise<void>;
62
+ findWorkspace(workspaceId: string): Promise<WorkspaceRecord | null>;
63
+ /** Uniqueness read for one workspace per repo (tenant x repoIdentity). */
64
+ findWorkspaceByRepoIdentity(tenantId: string, repoIdentity: string): Promise<WorkspaceRecord | null>;
65
+ listWorkspacesForTenant(tenantId: string): Promise<readonly WorkspaceRecord[]>;
66
+ approveWorkspaceAlias(workspaceId: string, alias: string): Promise<WorkspaceRecord>;
67
+ }
68
+ export interface WorkspaceMembershipStore {
69
+ putWorkspaceMember(record: WorkspaceMembershipRecord): Promise<WorkspaceMembershipRecord>;
70
+ removeWorkspaceMember(workspaceId: string, userId: string): Promise<boolean>;
71
+ findWorkspaceMember(workspaceId: string, userId: string): Promise<WorkspaceMembershipRecord | null>;
72
+ listWorkspaceMembers(workspaceId: string): Promise<readonly WorkspaceMembershipRecord[]>;
73
+ }
74
+ export interface OAuthTenantStore {
75
+ grantConsent(record: OAuthConsentRecord): Promise<void>;
76
+ revokeConsent(consentId: string, at: string): Promise<boolean>;
77
+ bindServiceClient(record: ServiceClientBinding): Promise<void>;
78
+ listTenantServiceClients(tenantId: string): Promise<readonly ServiceClientBinding[]>;
79
+ }
80
+ export interface IdentityAuditPort {
81
+ append(event: IdentityAuditEvent): Promise<void>;
82
+ }
83
+ export interface DivergenceMetricsPort {
84
+ record(sample: Omit<DivergenceSample, 'at'> & {
85
+ readonly at?: string;
86
+ }): void;
87
+ summary(): DivergenceSummary;
88
+ }
89
+ export interface AgentPlaneRevocationPort {
90
+ closeAgentSessionsForUser(userId: string): Promise<number>;
91
+ }
92
+ export interface InvitationTokenPort {
93
+ issue(): string;
94
+ }
95
+ export interface IdentityStores {
96
+ readonly tenants: TenantRegistryStore;
97
+ readonly accounts: UserAccountStore;
98
+ readonly proofs: IdentityProofStore;
99
+ readonly invitations: InvitationStore;
100
+ readonly deviceCodes: DeviceCodeStore;
101
+ readonly sessions: LoginSessionStore;
102
+ readonly memberships: TenantMembershipStore;
103
+ readonly workspaces: WorkspaceDirectoryStore;
104
+ readonly workspaceMembers: WorkspaceMembershipStore;
105
+ readonly oauth: OAuthTenantStore;
106
+ readonly audit: IdentityAuditPort;
107
+ }
108
+ export type IdentityPersistenceBinding = {
109
+ readonly mode: 'LOCAL_ONLY';
110
+ readonly local: IdentityStores;
111
+ } | {
112
+ readonly mode: 'DURABLE';
113
+ readonly durable: IdentityStores;
114
+ };
115
+ export declare function selectIdentityStores(binding: IdentityPersistenceBinding): IdentityStores;
116
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/ports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EAEZ,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,eAAe,EAEhB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC3D,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC7D,WAAW,IAAI,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAAC;IAChD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5F;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzD,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC/D,YAA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,MAAM,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,IAAI,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;CACnC;AAED,MAAM,MAAM,0BAA0B,GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,0BAA0B,GAAG,cAAc,CAExF"}
@@ -0,0 +1,7 @@
1
+ // Identity core contracts: storage ports. One port per record class; backends
2
+ // (PostgreSQL hosted profile, SQLite local profile) implement these ports in
3
+ // later lots. Domains orchestrate through ports only, never through a driver.
4
+ export function selectIdentityStores(binding) {
5
+ return binding.mode === 'LOCAL_ONLY' ? binding.local : binding.durable;
6
+ }
7
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/identity-contracts/ports.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AA4J9E,MAAM,UAAU,oBAAoB,CAAC,OAAmC;IACtE,OAAO,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACzE,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { DivergenceMetricsPort, OAuthTenantStore, TenantMembershipStore, TenantRegistryStore, WorkspaceDirectoryStore } from './ports.js';
2
+ import { type AuthoritativeResolution, type IdentityClock, type OAuthConsentRecord, type ServiceClientBinding, type ShadowComparison, type TenantResolutionMode, type TidClaim } from './types.js';
3
+ export interface TenantResolver {
4
+ resolveAuthoritatively(input: {
5
+ readonly workspaceId: string;
6
+ readonly userId: string;
7
+ }): Promise<AuthoritativeResolution>;
8
+ resolveWithMode(input: {
9
+ readonly workspaceId: string;
10
+ readonly userId: string;
11
+ }, mode: TenantResolutionMode, options: {
12
+ readonly legacyResolve: (input: {
13
+ readonly workspaceId: string;
14
+ readonly userId: string;
15
+ }) => Promise<string>;
16
+ }): Promise<AuthoritativeResolution | {
17
+ readonly tid: string;
18
+ readonly mode: 'alias';
19
+ } | ShadowComparison>;
20
+ }
21
+ export declare function createTenantResolver(input: {
22
+ readonly workspaces: WorkspaceDirectoryStore;
23
+ readonly tenants: TenantRegistryStore;
24
+ readonly memberships: TenantMembershipStore;
25
+ readonly metrics: DivergenceMetricsPort;
26
+ readonly clock?: IdentityClock;
27
+ }): TenantResolver;
28
+ export interface TidIssuer {
29
+ issueTid(input: {
30
+ readonly userId: string;
31
+ readonly tenantId: string;
32
+ }, now: string): Promise<TidClaim>;
33
+ }
34
+ export declare function createTidIssuer(input: {
35
+ readonly memberships: TenantMembershipStore;
36
+ readonly tenants: TenantRegistryStore;
37
+ }): TidIssuer;
38
+ export interface TenantOAuthDomain {
39
+ grantConsent(input: {
40
+ readonly consentId: string;
41
+ readonly tenantId: string;
42
+ readonly userId: string;
43
+ readonly clientId: string;
44
+ }): Promise<OAuthConsentRecord>;
45
+ revokeConsent(consentId: string, actorId: string): Promise<boolean>;
46
+ bindServiceClient(input: {
47
+ readonly clientId: string;
48
+ readonly tenantId: string;
49
+ }): Promise<ServiceClientBinding>;
50
+ listTenantOAuthClients(tenantId: string): Promise<readonly ServiceClientBinding[]>;
51
+ }
52
+ export declare function createTenantOAuth(input: {
53
+ readonly oauth: OAuthTenantStore;
54
+ readonly clock?: IdentityClock;
55
+ }): TenantOAuthDomain;
56
+ //# sourceMappingURL=resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/identity-contracts/resolution.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,sBAAsB,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3H,eAAe,CACb,KAAK,EAAE;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAChE,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE;QAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE;YAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,MAA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