instar 1.3.1978 → 1.3.1979
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/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +7 -5
- package/dist/commands/server.js.map +1 -1
- package/dist/core/AppConversationService.d.ts +2 -1
- package/dist/core/AppConversationService.d.ts.map +1 -1
- package/dist/core/AppConversationService.js +24 -7
- package/dist/core/AppConversationService.js.map +1 -1
- package/dist/core/AppConversationStore.d.ts +34 -0
- package/dist/core/AppConversationStore.d.ts.map +1 -1
- package/dist/core/AppConversationStore.js +232 -5
- package/dist/core/AppConversationStore.js.map +1 -1
- package/dist/core/AppConversationsReplicatedStore.js +1 -1
- package/dist/core/AppConversationsReplicatedStore.js.map +1 -1
- package/dist/core/AppCreationContext.d.ts +23 -0
- package/dist/core/AppCreationContext.d.ts.map +1 -0
- package/dist/core/AppCreationContext.js +80 -0
- package/dist/core/AppCreationContext.js.map +1 -0
- package/dist/core/ChiefOfStaffLoop.d.ts +6 -17
- package/dist/core/ChiefOfStaffLoop.d.ts.map +1 -1
- package/dist/core/ChiefOfStaffLoop.js +6 -0
- package/dist/core/ChiefOfStaffLoop.js.map +1 -1
- package/dist/core/ConversationRegistry.d.ts +2 -0
- package/dist/core/ConversationRegistry.d.ts.map +1 -1
- package/dist/core/ConversationRegistry.js +5 -0
- package/dist/core/ConversationRegistry.js.map +1 -1
- package/dist/core/CreationPlacementSnapshot.d.ts +24 -0
- package/dist/core/CreationPlacementSnapshot.d.ts.map +1 -0
- package/dist/core/CreationPlacementSnapshot.js +85 -0
- package/dist/core/CreationPlacementSnapshot.js.map +1 -0
- package/dist/core/WorkBoardRuntime.d.ts +25 -1
- package/dist/core/WorkBoardRuntime.d.ts.map +1 -1
- package/dist/core/WorkBoardRuntime.js +80 -3
- package/dist/core/WorkBoardRuntime.js.map +1 -1
- package/dist/data/standards-guard-index.json +1 -1
- package/dist/data/standards-guard-index.meta.json +2 -2
- package/dist/data/standards-registry.meta.json +1 -1
- package/dist/monitoring/contextBudgetMetrics.d.ts +1 -1
- package/dist/monitoring/contextLayers/h3Builder.d.ts +1 -1
- package/dist/native/InstarWedgeCanary.app/Contents/MacOS/InstarWedgeCanary +0 -0
- package/dist/native/instar-desktop-host +0 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +31 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/appCreationHierarchy.d.ts +64 -0
- package/dist/server/appCreationHierarchy.d.ts.map +1 -0
- package/dist/server/appCreationHierarchy.js +273 -0
- package/dist/server/appCreationHierarchy.js.map +1 -0
- package/dist/server/mobileConversationRoutes.d.ts +9 -0
- package/dist/server/mobileConversationRoutes.d.ts.map +1 -1
- package/dist/server/mobileConversationRoutes.js +99 -6
- package/dist/server/mobileConversationRoutes.js.map +1 -1
- package/dist/server/mobilePairingRoutes.d.ts.map +1 -1
- package/dist/server/mobilePairingRoutes.js +3 -0
- package/dist/server/mobilePairingRoutes.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +31 -5
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/awareness/conversation-creation-context.md +6 -0
- package/src/data/builtin-manifest.json +47 -47
- package/src/data/standards-guard-index.json +1 -1
- package/src/data/standards-guard-index.meta.json +2 -2
- package/src/data/standards-registry.meta.json +1 -1
- package/upgrades/1.3.1979.md +22 -0
- package/upgrades/side-effects/conversation-creation-context.md +63 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AppCreationContext } from '../core/AppCreationContext.js';
|
|
2
|
+
import type { AppConversationStore } from '../core/AppConversationStore.js';
|
|
3
|
+
export interface CreationCardEvidence {
|
|
4
|
+
conversationKey: string;
|
|
5
|
+
cardId: string;
|
|
6
|
+
creationContext: AppCreationContext;
|
|
7
|
+
conflict: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CreationHierarchySource {
|
|
10
|
+
version: string;
|
|
11
|
+
complete: boolean;
|
|
12
|
+
parents: ReadonlyMap<string, string | null>;
|
|
13
|
+
confirmedProjects: ReadonlySet<string>;
|
|
14
|
+
cardEvidence: ReadonlyArray<CreationCardEvidence>;
|
|
15
|
+
resolveRef: (raw: string, originMachineId?: string) => string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface PublicCreationSource {
|
|
18
|
+
v: 1;
|
|
19
|
+
kind: 'person' | 'work-board-card' | 'session';
|
|
20
|
+
evidence: 'created-event' | 'card-binding';
|
|
21
|
+
cardId?: string;
|
|
22
|
+
sourceConversationKey?: string;
|
|
23
|
+
projectKey?: string;
|
|
24
|
+
originMachineId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AppHierarchyFields {
|
|
27
|
+
parentConversationKey?: string | null;
|
|
28
|
+
creationSource?: PublicCreationSource;
|
|
29
|
+
hierarchyState: 'root' | 'child' | 'unplaced' | 'unknown';
|
|
30
|
+
}
|
|
31
|
+
export interface ParentPreviewRow {
|
|
32
|
+
conversationRef: string;
|
|
33
|
+
currentParentConversationKey?: string | null;
|
|
34
|
+
proposedParentConversationKey?: string | null;
|
|
35
|
+
creationSource?: PublicCreationSource;
|
|
36
|
+
action: 'would-place' | 'keep-current' | 'unresolved';
|
|
37
|
+
reason: string;
|
|
38
|
+
}
|
|
39
|
+
export interface CreationHierarchyScope {
|
|
40
|
+
key: string;
|
|
41
|
+
authorizationVersion: string;
|
|
42
|
+
/** One source snapshot captured for this response; null preserves unavailable evidence. */
|
|
43
|
+
source?: CreationHierarchySource | null;
|
|
44
|
+
/** Current existence and authorization, not historical permission. */
|
|
45
|
+
mayRead: (ref: string) => boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Cache invalidation is source/generation/scope based, never a TTL. Refresh yields between pages. */
|
|
48
|
+
export declare class AppCreationHierarchyProjection {
|
|
49
|
+
private readonly store;
|
|
50
|
+
private readonly source;
|
|
51
|
+
private readonly cache;
|
|
52
|
+
private readonly pending;
|
|
53
|
+
private cardKinds;
|
|
54
|
+
constructor(store: AppConversationStore, source: () => CreationHierarchySource | null | undefined);
|
|
55
|
+
private readSource;
|
|
56
|
+
private signature;
|
|
57
|
+
private known;
|
|
58
|
+
schedule(scope: CreationHierarchyScope): void;
|
|
59
|
+
settled(scope: CreationHierarchyScope): Promise<void>;
|
|
60
|
+
refresh(scope: CreationHierarchyScope): Promise<void>;
|
|
61
|
+
fields(key: string, scope: CreationHierarchyScope): AppHierarchyFields;
|
|
62
|
+
preview(key: string, scope: CreationHierarchyScope): ParentPreviewRow;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=appCreationHierarchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appCreationHierarchy.d.ts","sourceRoot":"","sources":["../../src/server/appCreationHierarchy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,iCAAiC,CAAC;AAE1F,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,kBAAkB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,YAAY,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAClD,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACtE;AACD,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EA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B,MAAM,EAAE,MAAM,uBAAuB,GAAG,IAAI,GAAG,SAAS,EAAI;IAEvI,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,SAAS;IAGjB,OAAO,CAAC,KAAK;IAQb,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAK5C;IACK,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IACK,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0E1D;IACD,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,kBAAkB,CAqBrE;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,gBAAgB,CAQpE;CACF"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/** Reader-scoped, read-only projection of supported local creation evidence.
|
|
2
|
+
* Historical context never overrides explicit current Chief placement.
|
|
3
|
+
*/
|
|
4
|
+
import { setImmediate as nextTurn } from 'node:timers/promises';
|
|
5
|
+
const own = (o, key) => Object.prototype.hasOwnProperty.call(o, key);
|
|
6
|
+
const childRef = (key) => key.startsWith('app:') ? key : `app:${key}`;
|
|
7
|
+
const keyOf = (ref) => ref.startsWith('app:') ? ref.slice(4) : ref;
|
|
8
|
+
function readable(source, scope, raw, origin) {
|
|
9
|
+
if (typeof raw !== 'string')
|
|
10
|
+
return null;
|
|
11
|
+
const ref = source.resolveRef(raw, origin);
|
|
12
|
+
return ref && scope.mayRead(ref) ? ref : null;
|
|
13
|
+
}
|
|
14
|
+
function sourceFor(context, evidence, card, source, scope) {
|
|
15
|
+
const raw = context.source;
|
|
16
|
+
const result = { v: 1, kind: raw.kind, evidence };
|
|
17
|
+
// These are provenance references, not inferred placement or new read grants.
|
|
18
|
+
if (raw.kind === 'work-board-card' && card && !card.conflict && raw.cardId === card.cardId && scope.mayRead(childRef(card.conversationKey)))
|
|
19
|
+
result.cardId = card.cardId;
|
|
20
|
+
const from = readable(source, scope, raw.sourceConversationKey, raw.originMachineId);
|
|
21
|
+
if (from)
|
|
22
|
+
result.sourceConversationKey = from;
|
|
23
|
+
const project = readable(source, scope, raw.projectKey, raw.originMachineId);
|
|
24
|
+
if (project && source.confirmedProjects.has(project))
|
|
25
|
+
result.projectKey = project;
|
|
26
|
+
if (raw.originMachineId)
|
|
27
|
+
result.originMachineId = raw.originMachineId;
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function candidate(context, source, scope) {
|
|
31
|
+
if (own(context, 'parentConversationKey')) {
|
|
32
|
+
if (context.parentConversationKey === null)
|
|
33
|
+
return { parent: null, reason: 'explicit-root' };
|
|
34
|
+
const parent = readable(source, scope, context.parentConversationKey, context.source.originMachineId);
|
|
35
|
+
if (!parent)
|
|
36
|
+
return { reason: 'parent-unavailable' };
|
|
37
|
+
if (context.parentBasis === 'project' && !source.confirmedProjects.has(parent))
|
|
38
|
+
return { reason: 'project-unconfirmed' };
|
|
39
|
+
return { parent, reason: 'recorded-parent' };
|
|
40
|
+
}
|
|
41
|
+
const from = readable(source, scope, context.source.sourceConversationKey, context.source.originMachineId);
|
|
42
|
+
const project = readable(source, scope, context.source.projectKey, context.source.originMachineId);
|
|
43
|
+
const candidates = new Set();
|
|
44
|
+
if (from)
|
|
45
|
+
candidates.add(from);
|
|
46
|
+
if (project && source.confirmedProjects.has(project))
|
|
47
|
+
candidates.add(project);
|
|
48
|
+
if (candidates.size > 1)
|
|
49
|
+
return { reason: 'ambiguous-recorded-parent' };
|
|
50
|
+
if (candidates.size === 1)
|
|
51
|
+
return { parent: [...candidates][0], reason: 'recorded-source' };
|
|
52
|
+
return { reason: 'recorded-parent-unresolved' };
|
|
53
|
+
}
|
|
54
|
+
/** Remove only historical fallback edges that take part in a cycle, across the full relation. */
|
|
55
|
+
function cyclicFallbacks(edges, fallbacks) {
|
|
56
|
+
const done = new Set();
|
|
57
|
+
const suppressed = new Set();
|
|
58
|
+
for (const start of edges.keys()) {
|
|
59
|
+
if (done.has(start))
|
|
60
|
+
continue;
|
|
61
|
+
const path = [];
|
|
62
|
+
const at = new Map();
|
|
63
|
+
let current = start;
|
|
64
|
+
while (current && edges.has(current) && !done.has(current)) {
|
|
65
|
+
const repeated = at.get(current);
|
|
66
|
+
if (repeated !== undefined) {
|
|
67
|
+
for (const ref of path.slice(repeated))
|
|
68
|
+
if (fallbacks.has(ref))
|
|
69
|
+
suppressed.add(ref);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
at.set(current, path.length);
|
|
73
|
+
path.push(current);
|
|
74
|
+
current = edges.get(current);
|
|
75
|
+
}
|
|
76
|
+
for (const ref of path)
|
|
77
|
+
done.add(ref);
|
|
78
|
+
}
|
|
79
|
+
return suppressed;
|
|
80
|
+
}
|
|
81
|
+
/** Cache invalidation is source/generation/scope based, never a TTL. Refresh yields between pages. */
|
|
82
|
+
export class AppCreationHierarchyProjection {
|
|
83
|
+
store;
|
|
84
|
+
source;
|
|
85
|
+
cache = new Map();
|
|
86
|
+
pending = new Map();
|
|
87
|
+
cardKinds = null;
|
|
88
|
+
constructor(store, source) {
|
|
89
|
+
this.store = store;
|
|
90
|
+
this.source = source;
|
|
91
|
+
}
|
|
92
|
+
readSource() {
|
|
93
|
+
try {
|
|
94
|
+
return this.source();
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null; /* @silent-fallback-ok: the response exposes unknown hierarchy, never an asserted empty tree. */
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
signature(source, scope) {
|
|
101
|
+
return JSON.stringify([source?.complete === true, source?.version ?? null, this.store.getCreationGeneration(), scope.authorizationVersion]);
|
|
102
|
+
}
|
|
103
|
+
known(scope) {
|
|
104
|
+
const source = own(scope, 'source') ? scope.source : this.readSource();
|
|
105
|
+
const cached = this.cache.get(scope.key);
|
|
106
|
+
if (!source?.complete || !cached || cached.signature !== this.signature(source, scope)) {
|
|
107
|
+
this.schedule(scope);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return cached;
|
|
111
|
+
}
|
|
112
|
+
schedule(scope) {
|
|
113
|
+
if (this.pending.has(scope.key))
|
|
114
|
+
return;
|
|
115
|
+
const task = nextTurn().then(() => this.refresh(scope)).finally(() => this.pending.delete(scope.key));
|
|
116
|
+
// A failed source stays uncertain; no request receives an asserted empty tree.
|
|
117
|
+
this.pending.set(scope.key, task.catch(() => { this.cache.delete(scope.key); /* @silent-fallback-ok: invalidation exposes unknown placement; no fabricated fallback or self-retry. */ }));
|
|
118
|
+
}
|
|
119
|
+
async settled(scope) {
|
|
120
|
+
this.schedule(scope);
|
|
121
|
+
await this.pending.get(scope.key);
|
|
122
|
+
}
|
|
123
|
+
async refresh(scope) {
|
|
124
|
+
const source = this.readSource();
|
|
125
|
+
if (own(scope, 'source') && (scope.source?.version !== source?.version || scope.source?.complete !== source?.complete)) {
|
|
126
|
+
this.cache.delete(scope.key);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (source)
|
|
130
|
+
this.cardKinds = { version: source.version, generated: new Set(source.cardEvidence.map((item) => childRef(item.conversationKey))) };
|
|
131
|
+
if (!source?.complete) {
|
|
132
|
+
this.cache.delete(scope.key);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const signature = this.signature(source, scope);
|
|
136
|
+
const records = new Map();
|
|
137
|
+
let cursor = null;
|
|
138
|
+
do {
|
|
139
|
+
const page = this.store.creationInventoryPage({ limit: 500, cursor });
|
|
140
|
+
for (const row of page.conversations)
|
|
141
|
+
records.set(childRef(row.conversationKey), this.store.getCreationRecord(row.conversationKey));
|
|
142
|
+
cursor = page.nextCursor;
|
|
143
|
+
await nextTurn();
|
|
144
|
+
} while (cursor !== null);
|
|
145
|
+
const cards = new Map(source.cardEvidence.map((item) => [childRef(item.conversationKey), item]));
|
|
146
|
+
const entries = new Map();
|
|
147
|
+
const edges = new Map(source.parents);
|
|
148
|
+
const fallbacks = new Set();
|
|
149
|
+
const proposals = new Map();
|
|
150
|
+
for (const [ref, record] of records) {
|
|
151
|
+
const card = cards.get(ref);
|
|
152
|
+
const conflict = this.store.hasCreationConflict(keyOf(ref)) || card?.conflict === true;
|
|
153
|
+
const context = conflict ? null : record?.creationContext ?? null;
|
|
154
|
+
const generated = conflict || !!card || context?.source.kind === 'work-board-card' || context?.source.kind === 'session';
|
|
155
|
+
const legacyContext = !record?.creationContext && !conflict ? card?.creationContext : null;
|
|
156
|
+
const evidenceContext = context ?? legacyContext ?? null;
|
|
157
|
+
const creationSource = evidenceContext ? sourceFor(evidenceContext, context ? 'created-event' : 'card-binding', card, source, scope) : undefined;
|
|
158
|
+
const base = { hierarchyState: generated ? 'unplaced' : 'unknown', ...(creationSource ? { creationSource } : {}) };
|
|
159
|
+
const preview = { conversationRef: ref, action: 'unresolved', reason: conflict ? 'creation-evidence-conflict' : 'creation-evidence-unavailable', ...(creationSource ? { creationSource } : {}) };
|
|
160
|
+
if (source.parents.has(ref)) {
|
|
161
|
+
const parent = source.parents.get(ref);
|
|
162
|
+
if (parent === null) {
|
|
163
|
+
base.parentConversationKey = null;
|
|
164
|
+
base.hierarchyState = 'root';
|
|
165
|
+
preview.currentParentConversationKey = null;
|
|
166
|
+
}
|
|
167
|
+
else if (scope.mayRead(parent)) {
|
|
168
|
+
base.parentConversationKey = parent;
|
|
169
|
+
base.hierarchyState = 'child';
|
|
170
|
+
preview.currentParentConversationKey = parent;
|
|
171
|
+
}
|
|
172
|
+
else
|
|
173
|
+
base.hierarchyState = 'unplaced';
|
|
174
|
+
preview.action = 'keep-current';
|
|
175
|
+
preview.reason = 'explicit-current-placement';
|
|
176
|
+
}
|
|
177
|
+
else if (evidenceContext) {
|
|
178
|
+
const proposed = candidate(evidenceContext, source, scope);
|
|
179
|
+
if (context && own(proposed, 'parent')) {
|
|
180
|
+
base.parentConversationKey = proposed.parent;
|
|
181
|
+
base.hierarchyState = proposed.parent === null ? 'root' : 'child';
|
|
182
|
+
edges.set(ref, proposed.parent);
|
|
183
|
+
fallbacks.add(ref);
|
|
184
|
+
preview.currentParentConversationKey = proposed.parent;
|
|
185
|
+
preview.action = 'keep-current';
|
|
186
|
+
preview.reason = 'recorded-current-placement';
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
preview.reason = proposed.reason;
|
|
190
|
+
if (context && own(context, 'parentConversationKey') && context.parentConversationKey !== null)
|
|
191
|
+
base.hierarchyState = 'unplaced';
|
|
192
|
+
if (own(proposed, 'parent'))
|
|
193
|
+
proposals.set(ref, proposed);
|
|
194
|
+
}
|
|
195
|
+
if (context && context.source.kind === 'person' && !own(context, 'parentConversationKey'))
|
|
196
|
+
base.hierarchyState = 'unknown';
|
|
197
|
+
}
|
|
198
|
+
entries.set(ref, { context, generated, fields: base, preview });
|
|
199
|
+
}
|
|
200
|
+
const cycles = cyclicFallbacks(edges, fallbacks);
|
|
201
|
+
for (const ref of cycles) {
|
|
202
|
+
edges.delete(ref);
|
|
203
|
+
const entry = entries.get(ref);
|
|
204
|
+
delete entry.fields.parentConversationKey;
|
|
205
|
+
entry.fields.hierarchyState = 'unplaced';
|
|
206
|
+
delete entry.preview.currentParentConversationKey;
|
|
207
|
+
entry.preview.action = 'unresolved';
|
|
208
|
+
entry.preview.reason = 'cyclic-recorded-placement';
|
|
209
|
+
}
|
|
210
|
+
// Legacy proposals are assessed against the fixed effective relation. Rejected proposals
|
|
211
|
+
// never remove the existing edge that revealed the cycle.
|
|
212
|
+
const proposedEdges = new Map(edges);
|
|
213
|
+
for (const [ref, proposed] of proposals)
|
|
214
|
+
proposedEdges.set(ref, proposed.parent);
|
|
215
|
+
const proposalCycles = cyclicFallbacks(proposedEdges, new Set(proposals.keys()));
|
|
216
|
+
for (const [ref, proposed] of proposals) {
|
|
217
|
+
const entry = entries.get(ref);
|
|
218
|
+
if (proposalCycles.has(ref)) {
|
|
219
|
+
entry.preview.reason = 'cyclic-proposed-placement';
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
entry.preview.proposedParentConversationKey = proposed.parent;
|
|
223
|
+
entry.preview.action = 'would-place';
|
|
224
|
+
entry.preview.reason = proposed.reason;
|
|
225
|
+
}
|
|
226
|
+
if (this.signature(this.readSource(), scope) !== signature) {
|
|
227
|
+
this.cache.delete(scope.key);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.cache.set(scope.key, { signature, entries });
|
|
231
|
+
}
|
|
232
|
+
fields(key, scope) {
|
|
233
|
+
const cached = this.known(scope);
|
|
234
|
+
const entry = cached?.entries.get(childRef(key));
|
|
235
|
+
if (!entry) {
|
|
236
|
+
const record = this.store.getCreationRecord(keyOf(key));
|
|
237
|
+
const kind = record?.creationContext?.source.kind;
|
|
238
|
+
const source = own(scope, 'source') ? scope.source : this.readSource();
|
|
239
|
+
const cardGenerated = source?.version === this.cardKinds?.version && this.cardKinds?.generated.has(childRef(key));
|
|
240
|
+
return { hierarchyState: this.store.hasCreationConflict(keyOf(key)) || kind === 'session' || kind === 'work-board-card' || cardGenerated ? 'unplaced' : 'unknown' };
|
|
241
|
+
}
|
|
242
|
+
const fields = { ...entry.fields };
|
|
243
|
+
if (typeof fields.parentConversationKey === 'string' && !scope.mayRead(fields.parentConversationKey)) {
|
|
244
|
+
delete fields.parentConversationKey;
|
|
245
|
+
fields.hierarchyState = 'unplaced';
|
|
246
|
+
}
|
|
247
|
+
if (fields.creationSource) {
|
|
248
|
+
fields.creationSource = { ...fields.creationSource };
|
|
249
|
+
for (const name of ['sourceConversationKey', 'projectKey']) {
|
|
250
|
+
const ref = fields.creationSource[name];
|
|
251
|
+
if (ref && !scope.mayRead(ref))
|
|
252
|
+
delete fields.creationSource[name];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return fields;
|
|
256
|
+
}
|
|
257
|
+
preview(key, scope) {
|
|
258
|
+
const entry = this.known(scope)?.entries.get(childRef(key));
|
|
259
|
+
if (!entry)
|
|
260
|
+
return { conversationRef: childRef(key), action: 'unresolved', reason: 'hierarchy-evidence-not-ready' };
|
|
261
|
+
const row = { ...entry.preview, ...(this.fields(key, scope).creationSource ? { creationSource: this.fields(key, scope).creationSource } : {}) };
|
|
262
|
+
for (const name of ['currentParentConversationKey', 'proposedParentConversationKey']) {
|
|
263
|
+
const ref = row[name];
|
|
264
|
+
if (typeof ref === 'string' && !scope.mayRead(ref)) {
|
|
265
|
+
delete row[name];
|
|
266
|
+
row.action = name === 'currentParentConversationKey' ? 'keep-current' : 'unresolved';
|
|
267
|
+
row.reason = 'parent-unavailable';
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return row;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=appCreationHierarchy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appCreationHierarchy.js","sourceRoot":"","sources":["../../src/server/appCreationHierarchy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA0DhE,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,GAAW,EAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9F,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC;AACtF,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAEnF,SAAS,QAAQ,CAAC,MAA+B,EAAE,KAA6B,EAAE,GAAY,EAAE,MAAe;IAC7G,IAAI,OAAO,GAAG,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AAK,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAChJ,KAAK,MAAM,IAAI,IAAI,CAAC,8BAA8B,EAAE,+BAA+B,CAAU,EAAE,CAAC;YAC9F,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;YAAC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;gBAAC,GAAG,CAAC,MAAM,GAAG,IAAI,KAAK,8BAA8B,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC;gBAAC,GAAG,CAAC,MAAM,GAAG,oBAAoB,CAAC;YAAC,CAAC;QAC3N,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -12,6 +12,7 @@ import type { RouteOutcome } from '../core/SessionRouter.js';
|
|
|
12
12
|
import type { RouteContext } from './routes.js';
|
|
13
13
|
import { ConversationUnreadService } from '../core/ConversationUnreadService.js';
|
|
14
14
|
import { type ConversationListPinStore } from '../core/ConversationListPins.js';
|
|
15
|
+
import { AppCreationHierarchyProjection, type AppHierarchyFields, type CreationHierarchySource } from './appCreationHierarchy.js';
|
|
15
16
|
/**
|
|
16
17
|
* One row of the unified conversation list. The list order is total and the same on every
|
|
17
18
|
* machine: newest `lastActivity` first (a missing one sorts last as ''), ties broken by the
|
|
@@ -37,6 +38,8 @@ export interface ConversationListRow {
|
|
|
37
38
|
} | null;
|
|
38
39
|
/** Chief of Staff tree (docs/specs/chief-of-staff-topic.md §1.4): the parent conversation key; owner-role callers only. Older apps ignore it. */
|
|
39
40
|
parentConversationKey?: string | null;
|
|
41
|
+
creationSource?: AppHierarchyFields['creationSource'];
|
|
42
|
+
hierarchyState?: AppHierarchyFields['hierarchyState'];
|
|
40
43
|
}
|
|
41
44
|
export declare function conversationSortKey(r: Pick<ConversationListRow, 'id' | 'platform'>): string;
|
|
42
45
|
/** Descending list order (negative ⇒ a comes first). */
|
|
@@ -84,6 +87,12 @@ export interface MobileConversationRouteDeps {
|
|
|
84
87
|
pinnedKey: string | null;
|
|
85
88
|
parents: Map<string, string | null>;
|
|
86
89
|
} | null;
|
|
90
|
+
/** Complete cached placement/card/registry view; absence is unknown, never an empty tree. */
|
|
91
|
+
creationHierarchySource?: () => CreationHierarchySource | null | undefined;
|
|
92
|
+
/** Optional extra permission-source version; default derives the actual current admitted device/person. */
|
|
93
|
+
creationAuthorizationVersion?: (req: Request) => string;
|
|
94
|
+
/** Focused tests may supply the same substantive projector they prime before reading. */
|
|
95
|
+
creationHierarchyProjection?: AppCreationHierarchyProjection;
|
|
87
96
|
/** Chief of Staff §4: the owner's phone checks in; absent where the feature is off. */
|
|
88
97
|
chiefOfStaffCheckIn?: (principal: string) => {
|
|
89
98
|
ok: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobileConversationRoutes.d.ts","sourceRoot":"","sources":["../../src/server/mobileConversationRoutes.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAG/G,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAiB,MAAM,SAAS,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAgD,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC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,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GACxG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgDhC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,sBAAsB,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAWhC"}
|
|
@@ -61,6 +61,8 @@ import { ConversationUnreadService } from '../core/ConversationUnreadService.js'
|
|
|
61
61
|
import { isMessagePosition, isReaderKey, CATCH_UP_PAGE, accessRefOf, canonicalConversationRef, readerKeyFor } from '../core/ConversationReadMarkers.js';
|
|
62
62
|
import { isConversationListPinsEnabled, MAX_LIST_PINS_PER_READER } from '../core/ConversationListPins.js';
|
|
63
63
|
import { mediaOffBody } from './mobileMediaOff.js';
|
|
64
|
+
import { AppCreationHierarchyProjection } from './appCreationHierarchy.js';
|
|
65
|
+
import { normalizeCreationParentRef } from '../core/AppCreationContext.js';
|
|
64
66
|
import { checkSignedFiles, claimMediaUploads, mediaRecordTooLarge, preflightMediaAttachments, publishMediaMessage, signedFileHashParts, } from './mobileMediaSend.js';
|
|
65
67
|
/** The unread fields of a row as the app receives them (§3.5). */
|
|
66
68
|
function unreadOut(f) {
|
|
@@ -353,6 +355,46 @@ export function createMobileConversationRouter(deps) {
|
|
|
353
355
|
const sendRate = new Map();
|
|
354
356
|
const mutationRate = new Map();
|
|
355
357
|
const svc = deps.service;
|
|
358
|
+
const creationProjection = deps.creationHierarchyProjection ?? (svc ? new AppCreationHierarchyProjection(svc.store, () => deps.creationHierarchySource?.()) : null);
|
|
359
|
+
const ownerMetadata = (req) => {
|
|
360
|
+
const principal = principalOf(req);
|
|
361
|
+
return principal.kind === 'token' || (principal.kind === 'device' && devicePersonOf(req)?.role === 'owner');
|
|
362
|
+
};
|
|
363
|
+
const readableCreationRef = (req, raw, capturedSource) => {
|
|
364
|
+
try {
|
|
365
|
+
const source = capturedSource === undefined ? deps.creationHierarchySource?.() : capturedSource;
|
|
366
|
+
let resolved = source?.resolveRef(raw) ?? null;
|
|
367
|
+
// Native App existence is directly verifiable even when Chief sources are unavailable.
|
|
368
|
+
const appKey = raw.startsWith('app:') ? raw.slice(4) : raw;
|
|
369
|
+
if (!resolved && isAppConversationKey(appKey) && svc?.liveConversation(appKey))
|
|
370
|
+
resolved = `app:${appKey}`;
|
|
371
|
+
if (!resolved && /^telegram:[1-9][0-9]*$/.test(raw) && deps.telegramTopics?.().some((t) => `telegram:${t.topicId}` === raw))
|
|
372
|
+
resolved = raw;
|
|
373
|
+
return !!resolved && deviceMayUse(deps.pairing, req, resolved);
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
return false; /* @silent-fallback-ok: identity failure suppresses parent metadata and exposes unplaced/unknown; it cannot grant access. */
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
const creationScope = (req) => {
|
|
380
|
+
let source = null;
|
|
381
|
+
try {
|
|
382
|
+
source = deps.creationHierarchySource?.() ?? null;
|
|
383
|
+
}
|
|
384
|
+
catch { /* @silent-fallback-ok: unavailable hierarchy is explicitly unknown in the response, never empty authority. */ }
|
|
385
|
+
const principal = principalOf(req);
|
|
386
|
+
const person = devicePersonOf(req);
|
|
387
|
+
const device = principal.kind === 'device' ? deps.pairing.devices.get(principal.deviceId) : null;
|
|
388
|
+
return {
|
|
389
|
+
key: principal.kind === 'token' ? 'bearer' : `device:${principal.deviceId}`,
|
|
390
|
+
source,
|
|
391
|
+
authorizationVersion: deps.creationAuthorizationVersion?.(req) ?? JSON.stringify([
|
|
392
|
+
principal.kind, person?.role, person?.userId, person?.tier, person?.grants,
|
|
393
|
+
device?.status, device?.role, device?.userId,
|
|
394
|
+
]),
|
|
395
|
+
mayRead: (ref) => readableCreationRef(req, ref, source),
|
|
396
|
+
};
|
|
397
|
+
};
|
|
356
398
|
/** Sends and conversation mutations keep separate buckets, so renames can never starve sends. */
|
|
357
399
|
const rateIn = (bucket, deviceId) => {
|
|
358
400
|
const t = now();
|
|
@@ -486,15 +528,40 @@ export function createMobileConversationRouter(deps) {
|
|
|
486
528
|
res.status(400).json({ error: 'bad-title', detail: 'A title of 1-80 characters is required.' });
|
|
487
529
|
return;
|
|
488
530
|
}
|
|
489
|
-
|
|
531
|
+
const hasParent = Object.prototype.hasOwnProperty.call(body, 'parentConversationKey');
|
|
532
|
+
const parent = body.parentConversationKey === null ? null : normalizeCreationParentRef(body.parentConversationKey);
|
|
533
|
+
if (hasParent && body.parentConversationKey !== null && parent === null) {
|
|
534
|
+
res.status(400).json({ error: 'bad-parent' });
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
// Preserve old no-parent hashes. Resolve intent identity before checking current existence,
|
|
538
|
+
// so completed retries never rederive historical context from today's placement.
|
|
539
|
+
const hash = hasParent ? hashOf('create', title, 'parent', JSON.stringify(parent)) : hashOf('create', title);
|
|
540
|
+
const previous = svc.deps.requests.lookup(deviceId, body.requestId, hash);
|
|
541
|
+
if (previous.kind === 'done') {
|
|
542
|
+
const child = previous.body.conversationKey;
|
|
543
|
+
if (typeof child === 'string' && (!svc.liveConversation(child) || !deviceMayUse(deps.pairing, req, child))) {
|
|
544
|
+
res.status(404).json({ error: 'unknown-conversation' });
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (answerLookup(res, previous))
|
|
549
|
+
return;
|
|
550
|
+
if (typeof parent === 'string' && !readableCreationRef(req, parent)) {
|
|
551
|
+
res.status(404).json({ error: 'unknown-parent' });
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
490
554
|
const conversationKey = newAppConversationKey();
|
|
491
|
-
// People and roles §3.4: a conversation an MSP phone creates is theirs (machine-namespaced).
|
|
492
555
|
const creator = devicePersonOf(req);
|
|
493
556
|
const ownerPerson = creator ? conversationOwnerFor(creator, deps.pairing.machineId()) : null;
|
|
494
|
-
|
|
557
|
+
const context = {
|
|
558
|
+
v: 1, source: { kind: 'person' },
|
|
559
|
+
parentConversationKey: hasParent ? parent : null, parentBasis: 'explicit',
|
|
560
|
+
};
|
|
561
|
+
mutation(res, deviceId, body.requestId, hash, { op: 'create', conversationKey, title, creationContext: JSON.stringify(context), ...(ownerPerson ? { ownerMachine: ownerPerson.machineId, ownerUser: ownerPerson.userId } : {}) }, () => {
|
|
495
562
|
if (creator?.role === 'team' && creator.userId)
|
|
496
563
|
deps.pairing.confineOwnConversation(conversationKey, creator.userId);
|
|
497
|
-
return svc.applyCreate(deviceId, body.requestId, conversationKey, title, ownerPerson);
|
|
564
|
+
return svc.applyCreate(deviceId, body.requestId, conversationKey, title, ownerPerson, context);
|
|
498
565
|
});
|
|
499
566
|
});
|
|
500
567
|
// ── List ──
|
|
@@ -588,6 +655,25 @@ export function createMobileConversationRouter(deps) {
|
|
|
588
655
|
};
|
|
589
656
|
/** The access ref the shared check takes for a canonical ref (Slack: the `slack:` grant). */
|
|
590
657
|
const pinAccessRef = (ref) => (ref.startsWith('slack:') ? 'slack:' : accessRefOf(ref));
|
|
658
|
+
router.get('/mobile/conversations/parent-preview', (req, res) => {
|
|
659
|
+
if (!readGate(req, res))
|
|
660
|
+
return;
|
|
661
|
+
if (!ownerMetadata(req)) {
|
|
662
|
+
res.status(403).json({ error: 'owner-only' });
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if ((req.query.cursor !== undefined && typeof req.query.cursor !== 'string')
|
|
666
|
+
|| (req.query.limit !== undefined && (typeof req.query.limit !== 'string' || !/^[1-9][0-9]*$/.test(req.query.limit)))) {
|
|
667
|
+
res.status(400).json({ error: 'bad-preview-page' });
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const limit = Math.max(1, Math.min(200, Number(req.query.limit) || 50));
|
|
671
|
+
const cursor = typeof req.query.cursor === 'string' ? req.query.cursor : null;
|
|
672
|
+
const page = svc.store.listConversations({ limit, cursor });
|
|
673
|
+
const scope = creationScope(req);
|
|
674
|
+
const rows = page.conversations.filter((c) => deviceMayUse(deps.pairing, req, c.conversationKey)).map((c) => creationProjection?.preview(c.conversationKey, scope) ?? { conversationRef: `app:${c.conversationKey}`, action: 'unresolved', reason: 'hierarchy-evidence-not-ready' });
|
|
675
|
+
res.json({ dryRun: true, canApply: false, rows, nextCursor: page.nextCursor });
|
|
676
|
+
});
|
|
591
677
|
router.get('/mobile/conversations', async (req, res) => {
|
|
592
678
|
if (!readGate(req, res))
|
|
593
679
|
return;
|
|
@@ -663,7 +749,14 @@ export function createMobileConversationRouter(deps) {
|
|
|
663
749
|
// (no cursor), a separate `pinned` row; everyone else gets neither. A Bearer read is the operator's own.
|
|
664
750
|
const cosView = (person === null || person.role === 'owner') ? (deps.chiefOfStaff?.() ?? null) : null;
|
|
665
751
|
const rowKey = (r) => (r.platform === 'app' ? `app:${String(r.id)}` : `${r.platform}:${String(r.id)}`);
|
|
666
|
-
const
|
|
752
|
+
const scope = ownerMetadata(req) ? creationScope(req) : null;
|
|
753
|
+
const withTree = (rows) => rows.map((r) => {
|
|
754
|
+
if (r.platform === 'app') {
|
|
755
|
+
const { parentConversationKey: _parent, creationSource: _source, hierarchyState: _state, ...ordinary } = r;
|
|
756
|
+
return scope && creationProjection ? { ...ordinary, ...creationProjection.fields(String(r.id), scope) } : ordinary;
|
|
757
|
+
}
|
|
758
|
+
return cosView?.parents.has(rowKey(r)) ? { ...r, parentConversationKey: cosView.parents.get(rowKey(r)) ?? null } : r;
|
|
759
|
+
});
|
|
667
760
|
const pinnedOut = (rows) => {
|
|
668
761
|
if (!cosView || !cosView.pinnedKey || cursor !== null)
|
|
669
762
|
return {};
|
|
@@ -1457,7 +1550,7 @@ export function createMobileConversationRouter(deps) {
|
|
|
1457
1550
|
return false;
|
|
1458
1551
|
return deps.pairing.mayReadMessageId(devicePersonOf(req), key, about);
|
|
1459
1552
|
}).map((e) => {
|
|
1460
|
-
const { origin: _origin, receipt: _receipt, ingestSeq: _seq, ...rest } = e;
|
|
1553
|
+
const { origin: _origin, receipt: _receipt, ingestSeq: _seq, creationContext: _creationContext, ...rest } = e;
|
|
1461
1554
|
return {
|
|
1462
1555
|
...rest,
|
|
1463
1556
|
...(e.kind === 'message' || e.kind === 'media-message' ? (() => {
|