@productbrain/cli 0.1.0-beta.11174 → 0.1.0-beta.11180
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/__tests__/capture.test.js +104 -632
- package/dist/__tests__/capture.test.js.map +1 -1
- package/dist/__tests__/reply-commands-registered.test.js +1 -1
- package/dist/__tests__/reply-commands-registered.test.js.map +1 -1
- package/dist/commands/capture.d.ts +4 -4
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +13 -33
- package/dist/commands/capture.js.map +1 -1
- package/dist/formatters/capture.d.ts +4 -2
- package/dist/formatters/capture.d.ts.map +1 -1
- package/dist/formatters/capture.js +4 -5
- package/dist/formatters/capture.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/captureLink.d.ts +6 -30
- package/dist/lib/captureLink.d.ts.map +1 -1
- package/dist/lib/captureLink.js +21 -117
- package/dist/lib/captureLink.js.map +1 -1
- package/dist/registerEntryCommands.js +2 -2
- package/dist/registerEntryCommands.js.map +1 -1
- package/package.json +1 -1
- package/dist/generated/relationTypes.generated.d.ts +0 -12
- package/dist/generated/relationTypes.generated.d.ts.map +0 -1
- package/dist/generated/relationTypes.generated.js +0 -11
- package/dist/generated/relationTypes.generated.js.map +0 -1
- package/dist/lib/__tests__/legalRelationTypes.test.d.ts +0 -2
- package/dist/lib/__tests__/legalRelationTypes.test.d.ts.map +0 -1
- package/dist/lib/__tests__/legalRelationTypes.test.js +0 -61
- package/dist/lib/__tests__/legalRelationTypes.test.js.map +0 -1
- package/dist/lib/legalRelationTypes.d.ts +0 -19
- package/dist/lib/legalRelationTypes.d.ts.map +0 -1
- package/dist/lib/legalRelationTypes.js +0 -64
- package/dist/lib/legalRelationTypes.js.map +0 -1
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** The pre-relation coaching verdict — the post-relation re-eval below overwrites it only
|
|
8
|
-
* on a genuinely written relation (fail-open on a re-eval failure keeps this one). */
|
|
9
|
-
coaching: CoachingResult | null | undefined;
|
|
10
|
-
/** TASK-898 (DEC-2113): the kernel replayed a re-sent capture. Its first send may have timed out before the
|
|
11
|
-
* link, so the link is resent if-missing; nothing model-driven (the re-eval) runs again. */
|
|
12
|
-
replayed?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface CaptureLinkResult {
|
|
15
|
-
actualLinkedTo: string | undefined;
|
|
16
|
-
actualRelationType: string | undefined;
|
|
17
|
-
linkTypeRefusal: CLIError | null;
|
|
18
|
-
coaching: CoachingResult | null | undefined;
|
|
19
|
-
/** TASK-898: on a replay, the requested link was already there from the first send (success, nothing written). */
|
|
20
|
-
linkAlreadyThere?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* WP-475 E1 fix: the pre-relation verdict predates this relation, so relation-dependent rubric
|
|
24
|
-
* criteria read falsely-failed; re-run AFTER the relation lands and render THAT verdict.
|
|
25
|
-
* Fail-open (BR-144): a re-eval failure keeps the pre-relation verdict. WP-688 S4 (TASK-105,
|
|
26
|
-
* element 11): what was ACTUALLY written — never guessed, never defaulted; `--link` without
|
|
27
|
-
* `--link-type` is refused with no default, ever, and the refusal is DEFERRED (returned, not
|
|
28
|
-
* thrown) so the caller can still render the successful capture/version receipt first.
|
|
29
|
-
*/
|
|
30
|
-
export declare function applyCaptureLink(params: CaptureLinkParams): Promise<CaptureLinkResult>;
|
|
1
|
+
export type CaptureLinkArg = {
|
|
2
|
+
toEntryId: string;
|
|
3
|
+
type: string;
|
|
4
|
+
};
|
|
5
|
+
/** Pairs each --link with the --link-type given in the same position; a bare or empty flag is refused up front. */
|
|
6
|
+
export declare function pairCaptureLinks(links: readonly string[], types: readonly string[]): CaptureLinkArg[];
|
|
31
7
|
//# sourceMappingURL=captureLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captureLink.d.ts","sourceRoot":"","sources":["../../src/lib/captureLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"captureLink.d.ts","sourceRoot":"","sources":["../../src/lib/captureLink.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,mHAAmH;AACnH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,EAAE,CAoBrG"}
|
package/dist/lib/captureLink.js
CHANGED
|
@@ -1,125 +1,29 @@
|
|
|
1
|
-
import { kernelCallWithSession } from './client.js';
|
|
2
|
-
import { CLIError, ErrorCode } from './errors.js';
|
|
3
|
-
import { resolveCreatableRelationTypes } from './legalRelationTypes.js';
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* element 11): what was ACTUALLY written — never guessed, never defaulted; `--link` without
|
|
9
|
-
* `--link-type` is refused with no default, ever, and the refusal is DEFERRED (returned, not
|
|
10
|
-
* thrown) so the caller can still render the successful capture/version receipt first.
|
|
2
|
+
* `pb capture --link`: the flag pairs become the `links[]` the one chain.createEntry request carries (TASK-897,
|
|
3
|
+
* DEC-2113). The kernel resolves each target, judges the verb and answers per link; this file only pairs the flags
|
|
4
|
+
* and refuses, before anything is sent, a pair the kernel could never judge. No default verb, ever (WP-688 S4).
|
|
11
5
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let coaching = params.coaching;
|
|
19
|
-
if (link === undefined)
|
|
20
|
-
return { actualLinkedTo, actualRelationType, linkTypeRefusal, coaching };
|
|
21
|
-
const linkTarget = link.trim();
|
|
22
|
-
if (!linkTarget) {
|
|
23
|
-
// bcRUML/bcRpJQ: an empty or whitespace-only --link must not silently no-op.
|
|
24
|
-
linkTypeRefusal = new CLIError('--link requires a non-empty entry ID.', { code: ErrorCode.VALIDATION_FAILED, category: 'validation', guidance: `${entryId} was captured — only the link was refused. Re-run with a valid --link <entry-id>.` });
|
|
25
|
-
}
|
|
26
|
-
else if (!linkType) {
|
|
27
|
-
// No default, ever (element 11). Legal verbs = the workspace type row's declared valid_relation_types
|
|
28
|
-
// (matched like loadTypeMap: data.canonical_key, never a guessed entryId), filtered to what `pb relate` can create (bdB5K, cQFZ_).
|
|
29
|
-
let declaredTypes;
|
|
30
|
-
let targetMissing = false;
|
|
31
|
-
try {
|
|
32
|
-
const [created, target] = await Promise.all([
|
|
33
|
-
kernelCallWithSession('chain.getEntry', { entryId }),
|
|
34
|
-
kernelCallWithSession('chain.getEntry', { entryId: linkTarget }),
|
|
35
|
-
]);
|
|
36
|
-
targetMissing = target === null; // bcRUMR: never recommend `pb relate ... <missing-id>`
|
|
37
|
-
const canonicalKey = created?.canonicalKey;
|
|
38
|
-
if (canonicalKey) {
|
|
39
|
-
const typeRows = await kernelCallWithSession('chain.listEntries', { collectionSlug: 'semantic-types' });
|
|
40
|
-
declaredTypes = resolveCreatableRelationTypes(typeRows, canonicalKey, target?.canonicalKey === 'domain');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// Advisory read only — a failure here still refuses the link, just without the list.
|
|
45
|
-
}
|
|
46
|
-
const verbHint = declaredTypes && declaredTypes.length > 0 ? `Legal relation types for this entry: ${declaredTypes.join(', ')}.` : `No relation types are declared valid for this entry's type.`;
|
|
47
|
-
linkTypeRefusal = new CLIError(`--link requires --link-type — no default is written. ${verbHint}`, {
|
|
48
|
-
code: ErrorCode.VALIDATION_FAILED,
|
|
49
|
-
category: 'validation',
|
|
50
|
-
guidance: targetMissing
|
|
51
|
-
? `${entryId} was captured — the link was refused, and target "${linkTarget}" was not found. Verify the target entry ID.`
|
|
52
|
-
: `${entryId} was captured — only the link was refused. Re-run: pb relate ${entryId} <verb> ${linkTarget}`,
|
|
6
|
+
import { CLIError, ErrorCode } from './errors.js';
|
|
7
|
+
/** Pairs each --link with the --link-type given in the same position; a bare or empty flag is refused up front. */
|
|
8
|
+
export function pairCaptureLinks(links, types) {
|
|
9
|
+
if (types.length > links.length) {
|
|
10
|
+
throw new CLIError(`${types.length} --link-type for ${links.length} --link; each --link-type belongs to one --link.`, {
|
|
11
|
+
code: ErrorCode.VALIDATION_FAILED, category: 'validation', guidance: 'Nothing was captured. Re-run with one --link <entry-id> --link-type <type> per link.',
|
|
53
12
|
});
|
|
54
13
|
}
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const relateResult = await kernelCallWithSession('chain.createEntryRelation', {
|
|
61
|
-
fromEntryId: entryId, toEntryId: linkTarget, type: relationType,
|
|
62
|
-
});
|
|
63
|
-
// WP-753 O4 (TEN-3651) / this PR's P1 fix (same class as packages/mcp-server/src/tools/relations.ts's
|
|
64
|
-
// handleCreate): chain.createEntryRelation RETURNS `{outcome:'refused', refusal}` on an
|
|
65
|
-
// organisational-authority refusal — it never throws for this case, so the `catch` below
|
|
66
|
-
// never saw it and `linkTypeRefusal` stayed null, silently dropping the refusal reason from
|
|
67
|
-
// the capture receipt (the receipt itself was still correct — `relationWritten` already reads
|
|
68
|
-
// `false` off the missing `relationId` — but the caller learned nothing about WHY).
|
|
69
|
-
if (relateResult && 'outcome' in relateResult && relateResult.outcome === 'refused') {
|
|
70
|
-
const { refusal } = relateResult;
|
|
71
|
-
throw new CLIError(refusal.reason ?? `Relating ${entryId} to ${linkTarget} was refused.`, {
|
|
72
|
-
code: refusal.category === 'auth' ? ErrorCode.AUTH_DENIED : ErrorCode.VALIDATION_FAILED,
|
|
73
|
-
category: refusal.category === 'auth' ? 'auth' : 'validation',
|
|
74
|
-
guidance: refusal.requiredAction ?? 'Route this change to the accountable role or Team Lead.',
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// relationId is the ONLY "a row was inserted" marker (relations.ts:94-291) — a proposal diversion or the DEC-1399 auto-link gate return WITHOUT one.
|
|
78
|
-
relationWritten = Boolean(relateResult?.relationId);
|
|
79
|
-
if (relationWritten) {
|
|
80
|
-
actualLinkedTo = linkTarget;
|
|
81
|
-
actualRelationType = relationType;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (err) { // WP-745 review: a relate-door refusal must not escape uncaught — entryId above was ALREADY written.
|
|
85
|
-
// TASK-898: the relation door refuses an existing (from, to, type) row; on a replay that is the first send's link, so success.
|
|
86
|
-
if (replayed && /Duplicate relation/.test(err instanceof Error ? err.message : String(err))) {
|
|
87
|
-
linkAlreadyThere = true;
|
|
88
|
-
actualLinkedTo = linkTarget;
|
|
89
|
-
actualRelationType = relationType;
|
|
90
|
-
}
|
|
91
|
-
else
|
|
92
|
-
relateErr = err;
|
|
14
|
+
return links.map((raw, i) => {
|
|
15
|
+
const toEntryId = raw.trim();
|
|
16
|
+
if (!toEntryId) {
|
|
17
|
+
throw new CLIError('--link requires a non-empty entry ID.', { code: ErrorCode.VALIDATION_FAILED, category: 'validation', guidance: 'Nothing was captured. Re-run with --link <entry-id> --link-type <type>.' });
|
|
93
18
|
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const reEval = await kernelCallWithSession('quality.evaluateHeuristicAndSchedule', { entryId, context: 'capture' });
|
|
101
|
-
if (relationWritten && reEval?.verdict)
|
|
102
|
-
coaching = reEval;
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
// Advisory — keep the pre-relation verdict rather than fail the capture.
|
|
19
|
+
const type = types[i]?.trim();
|
|
20
|
+
if (!type) {
|
|
21
|
+
throw new CLIError(`--link ${toEntryId} requires --link-type; no default is written.`, {
|
|
22
|
+
code: ErrorCode.VALIDATION_FAILED, category: 'validation',
|
|
23
|
+
guidance: `Nothing was captured. Re-run with --link ${toEntryId} --link-type <type>; a verb the kernel refuses comes back with the legal ones.`,
|
|
24
|
+
});
|
|
106
25
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
return { actualLinkedTo, actualRelationType, linkTypeRefusal, coaching, linkAlreadyThere };
|
|
111
|
-
}
|
|
112
|
-
/** The deferred refusal for a relate that did not land; the capture itself already did. */
|
|
113
|
-
function refusalFor(relateErr, entryId, linkTarget) {
|
|
114
|
-
if (relateErr instanceof CLIError && relateErr.code === ErrorCode.NETWORK_TIMEOUT) {
|
|
115
|
-
// WP-745 round 3 (PRRT_...h0VPP): NETWORK_TIMEOUT is outcome-UNKNOWN, not a refusal (the relate call may have landed server-side) — never buried under a contradictory blind-retry claim.
|
|
116
|
-
return new CLIError(relateErr.message, { code: relateErr.code, category: relateErr.category, guidance: `${entryId} was captured. The link's outcome is UNKNOWN (not refused) — check before retrying: pb get ${entryId}. ${relateErr.guidance ?? ''}` });
|
|
117
|
-
}
|
|
118
|
-
const guidance = `${entryId} was captured — only the link was refused. Re-run: pb relate ${entryId} <verb> ${linkTarget}`;
|
|
119
|
-
if (relateErr instanceof CLIError && relateErr.code !== ErrorCode.VALIDATION_FAILED) {
|
|
120
|
-
// WP-745 round 3 (PRRT_...h0CCc): preserve a real CLIError/McpError's own code/category (auth, rate limit) — only REL-LEGAL-2 VALIDATION (or a non-CLIError) gets the generic "was refused, re-run" guidance.
|
|
121
|
-
return new CLIError(relateErr.message, { code: relateErr.code, category: relateErr.category, guidance: relateErr.guidance ? `${guidance} (${relateErr.guidance})` : guidance });
|
|
122
|
-
}
|
|
123
|
-
return new CLIError(relateErr instanceof Error ? relateErr.message : String(relateErr), { code: ErrorCode.VALIDATION_FAILED, category: 'validation', guidance });
|
|
26
|
+
return { toEntryId, type };
|
|
27
|
+
});
|
|
124
28
|
}
|
|
125
29
|
//# sourceMappingURL=captureLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captureLink.js","sourceRoot":"","sources":["../../src/lib/captureLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"captureLink.js","sourceRoot":"","sources":["../../src/lib/captureLink.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIlD,mHAAmH;AACnH,MAAM,UAAU,gBAAgB,CAAC,KAAwB,EAAE,KAAwB;IACjF,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,QAAQ,CAAC,GAAG,KAAK,CAAC,MAAM,oBAAoB,KAAK,CAAC,MAAM,kDAAkD,EAAE;YACpH,IAAI,EAAE,SAAS,CAAC,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,sFAAsF;SAC5J,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAAC,uCAAuC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,yEAAyE,EAAE,CAAC,CAAC;QAClN,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,QAAQ,CAAC,UAAU,SAAS,+CAA+C,EAAE;gBACrF,IAAI,EAAE,SAAS,CAAC,iBAAiB,EAAE,QAAQ,EAAE,YAAY;gBACzD,QAAQ,EAAE,4CAA4C,SAAS,gFAAgF;aAChJ,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -24,8 +24,8 @@ export function registerEntryCommands(program) {
|
|
|
24
24
|
.option('-d, --description <desc>', 'Entry description, in Markdown (defaults to capture text)')
|
|
25
25
|
.option('-c, --collection <slug>', 'Explicit collection (skip auto-classification)')
|
|
26
26
|
.option('-f, --field <key=value>', 'Set a data field (repeatable; checklist: -f doneWhen="a" -f doneWhen="b", one item per flag)', (val, prev) => [...prev, val], [])
|
|
27
|
-
.option('-l, --link <entry-id>', 'Link
|
|
28
|
-
.option('-t, --link-type <relation-type>', 'Relation type for
|
|
27
|
+
.option('-l, --link <entry-id>', 'Link to an existing entry by id or name (repeatable; pairs with the -t in the same position)', (val, prev) => [...prev, val], [])
|
|
28
|
+
.option('-t, --link-type <relation-type>', 'Relation type for the -l in the same position; one per --link, no default (WP-688 S4)', (val, prev) => [...prev, val], [])
|
|
29
29
|
.option('--source-ref <ref>', 'Source reference URI (BET-240 E2)')
|
|
30
30
|
.option('--source-excerpt <text>', 'Verbatim source excerpt (BET-240 E2)')
|
|
31
31
|
.option('--draft', 'Force the entry to draft regardless of workspace governance mode (TEN-2226)')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerEntryCommands.js","sourceRoot":"","sources":["../src/registerEntryCommands.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9D,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OAAO,CAAC,iCAAiC,CAAC;SAC1C,WAAW,CAAC,oEAAoE,CAAC;SACjF,MAAM,CAAC,cAAc,EAAE,mDAAmD,CAAC;SAC3E,MAAM,CAAC,WAAW,EAAE,uFAAuF,CAAC;SAC5G,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAY,EAAE,IAAY,EAAE,IAA+C,EAAE,EAAE;QAC5G,MAAM,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,mCAAmC,CAAC;SAC5C,WAAW,CAAC,uEAAuE,CAAC;SACpF,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAY,EAAE,IAAY,EAAE,EAAE;QAC3D,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED — DO NOT EDIT BY HAND.
|
|
3
|
-
*
|
|
4
|
-
* Source of truth: `kernel/entries/relationTypes.ts` (ALLOWED_RELATION_TYPES_LIST).
|
|
5
|
-
* Regenerate via: `npm run codegen` from `packages/cli`.
|
|
6
|
-
*
|
|
7
|
-
* Drift guard: src/__tests__/kernel-value-sets-drift.test.ts re-extracts the
|
|
8
|
-
* members from the source and fails CI when this file is stale.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ALLOWED_RELATION_TYPES: readonly ["informs", "governs", "surfaces_tension_in", "defines_term_for", "belongs_to", "references", "related_to", "fills_slot", "commits_to", "informed_by", "depends_on", "conflicts_with", "confused_with", "do_not_confuse_with", "replaces", "part_of", "constrains", "validates", "invalidates", "governed_by", "alternative_to", "has_proposal", "requests_promotion_of", "resolves", "experiences", "addresses", "threatens", "tests", "produces", "realizes", "requires", "invests_in", "enables", "follows", "extracted_from", "part_of_workstream", "stated_by", "discussed_in", "specializes", "implements", "anchored_to"];
|
|
11
|
-
export type AllowedRelationType = (typeof ALLOWED_RELATION_TYPES)[number];
|
|
12
|
-
//# sourceMappingURL=relationTypes.generated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationTypes.generated.d.ts","sourceRoot":"","sources":["../../src/generated/relationTypes.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,sBAAsB,2mBAA4mB,CAAC;AAChpB,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GENERATED — DO NOT EDIT BY HAND.
|
|
3
|
-
*
|
|
4
|
-
* Source of truth: `kernel/entries/relationTypes.ts` (ALLOWED_RELATION_TYPES_LIST).
|
|
5
|
-
* Regenerate via: `npm run codegen` from `packages/cli`.
|
|
6
|
-
*
|
|
7
|
-
* Drift guard: src/__tests__/kernel-value-sets-drift.test.ts re-extracts the
|
|
8
|
-
* members from the source and fails CI when this file is stale.
|
|
9
|
-
*/
|
|
10
|
-
export const ALLOWED_RELATION_TYPES = ['informs', 'governs', 'surfaces_tension_in', 'defines_term_for', 'belongs_to', 'references', 'related_to', 'fills_slot', 'commits_to', 'informed_by', 'depends_on', 'conflicts_with', 'confused_with', 'do_not_confuse_with', 'replaces', 'part_of', 'constrains', 'validates', 'invalidates', 'governed_by', 'alternative_to', 'has_proposal', 'requests_promotion_of', 'resolves', 'experiences', 'addresses', 'threatens', 'tests', 'produces', 'realizes', 'requires', 'invests_in', 'enables', 'follows', 'extracted_from', 'part_of_workstream', 'stated_by', 'discussed_in', 'specializes', 'implements', 'anchored_to'];
|
|
11
|
-
//# sourceMappingURL=relationTypes.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relationTypes.generated.js","sourceRoot":"","sources":["../../src/generated/relationTypes.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,uBAAuB,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,CAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legalRelationTypes.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/legalRelationTypes.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WP-688 S4 review round 5 (bdB5K, cQFZ_): filterCreatableRelationTypes narrows a workspace's
|
|
3
|
-
* declared valid_relation_types down to verbs `pb relate`'s generic door can actually create.
|
|
4
|
-
* WP-688 S4 review round 5 (bcQiSg): resolveCreatableRelationTypes mirrors loadTypeMap's
|
|
5
|
-
* DB-first resolution — trust-accepted rows only, last-match-wins on duplicate canonical_key.
|
|
6
|
-
*/
|
|
7
|
-
import { describe, expect, it } from 'vitest';
|
|
8
|
-
import { filterCreatableRelationTypes, resolveCreatableRelationTypes } from '../legalRelationTypes.js';
|
|
9
|
-
describe('filterCreatableRelationTypes', () => {
|
|
10
|
-
it('returns an empty array when declared is not an array', () => {
|
|
11
|
-
expect(filterCreatableRelationTypes(undefined, false, true)).toEqual([]);
|
|
12
|
-
expect(filterCreatableRelationTypes(null, false, true)).toEqual([]);
|
|
13
|
-
expect(filterCreatableRelationTypes('informs', false, true)).toEqual([]);
|
|
14
|
-
});
|
|
15
|
-
it('excludes replaces and do_not_confuse_with regardless of target (direct-door-blocked)', () => {
|
|
16
|
-
expect(filterCreatableRelationTypes(['informs', 'replaces', 'do_not_confuse_with', 'governs'], false, true))
|
|
17
|
-
.toEqual(['informs', 'governs']);
|
|
18
|
-
});
|
|
19
|
-
it('excludes a verb outside the kernel ALLOWED_RELATION_TYPES allowlist (bdB5K)', () => {
|
|
20
|
-
expect(filterCreatableRelationTypes(['informs', 'depends_on', 'custom_hand_added'], false, true))
|
|
21
|
-
.toEqual(['informs', 'depends_on']);
|
|
22
|
-
});
|
|
23
|
-
it('excludes belongs_to only when the target is a domain (cQFZ_); authority_domain is no longer a legal verb at all (TASK-425)', () => {
|
|
24
|
-
const declared = ['informs', 'belongs_to', 'authority_domain'];
|
|
25
|
-
expect(filterCreatableRelationTypes(declared, true, true)).toEqual(['informs']);
|
|
26
|
-
expect(filterCreatableRelationTypes(declared, false, true)).toEqual(['informs', 'belongs_to']);
|
|
27
|
-
});
|
|
28
|
-
it('drops non-string entries in the declared array', () => {
|
|
29
|
-
expect(filterCreatableRelationTypes(['informs', 42, null, 'governs'], false, true)).toEqual(['informs', 'governs']);
|
|
30
|
-
});
|
|
31
|
-
it('excludes anchored_to unless the source is a strategy entry (bcRgRI)', () => {
|
|
32
|
-
const declared = ['informs', 'anchored_to'];
|
|
33
|
-
expect(filterCreatableRelationTypes(declared, false, false)).toEqual(['informs']);
|
|
34
|
-
expect(filterCreatableRelationTypes(declared, false, true)).toEqual(['informs', 'anchored_to']);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
// Minimal parsable fields every fixture row below needs to pass isParsableSemanticTypeRow
|
|
38
|
-
// (kernel/entries/semanticTypes.ts:65-77's validity rule) unless a test is deliberately
|
|
39
|
-
// exercising the malformed-row-skip path.
|
|
40
|
-
const PARSABLE = { description: 'x', cardinality_rule: 'multiple' };
|
|
41
|
-
describe('resolveCreatableRelationTypes', () => {
|
|
42
|
-
it('returns an empty array when no row matches the canonical key', () => {
|
|
43
|
-
const typeRows = [{ status: 'active', data: { canonical_key: 'other', valid_relation_types: ['informs'], ...PARSABLE } }];
|
|
44
|
-
expect(resolveCreatableRelationTypes(typeRows, 'goal', false)).toEqual([]);
|
|
45
|
-
});
|
|
46
|
-
it('handles a null/undefined typeRows list', () => {
|
|
47
|
-
expect(resolveCreatableRelationTypes(null, 'goal', false)).toEqual([]);
|
|
48
|
-
expect(resolveCreatableRelationTypes(undefined, 'goal', false)).toEqual([]);
|
|
49
|
-
});
|
|
50
|
-
it('still applies filterCreatableRelationTypes to the resolved row (bdB5K/cQFZ_ compose with bcQiSg)', () => {
|
|
51
|
-
const typeRows = [{ status: 'active', data: { canonical_key: 'insight', valid_relation_types: ['informs', 'belongs_to', 'custom_hand_added'], ...PARSABLE } }];
|
|
52
|
-
expect(resolveCreatableRelationTypes(typeRows, 'insight', true)).toEqual(['informs']);
|
|
53
|
-
});
|
|
54
|
-
it('excludes anchored_to for a non-strategy canonicalKey, includes it for strategy (bcRgRI)', () => {
|
|
55
|
-
const typeRows = [{ status: 'active', data: { canonical_key: 'goal', valid_relation_types: ['informs', 'anchored_to'], ...PARSABLE } }];
|
|
56
|
-
expect(resolveCreatableRelationTypes(typeRows, 'goal', false)).toEqual(['informs']);
|
|
57
|
-
const strategyRows = [{ status: 'active', data: { canonical_key: 'strategy', valid_relation_types: ['informs', 'anchored_to'], ...PARSABLE } }];
|
|
58
|
-
expect(resolveCreatableRelationTypes(strategyRows, 'strategy', false)).toEqual(['informs', 'anchored_to']);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=legalRelationTypes.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legalRelationTypes.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/legalRelationTypes.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAEvG,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,4BAA4B,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzE,MAAM,CAAC,4BAA4B,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpE,MAAM,CAAC,4BAA4B,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,CAAC,4BAA4B,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;aACzG,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,CAAC,4BAA4B,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;aAC9F,OAAO,CAAC,CAAC,SAAS,EAAE,YAA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AAI,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxI,MAAM,CAAC,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAEpF,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;QAChJ,MAAM,CAAC,6BAA6B,CAAC,YAAY,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7G,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Filters a workspace-declared `valid_relation_types` array down to verbs `pb relate`'s
|
|
2
|
-
* generic door can actually create toward the given target. `targetIsDomain` should be
|
|
3
|
-
* `true` when the link target entry's canonicalKey is 'domain'; `sourceIsStrategy` should be
|
|
4
|
-
* `true` when the entry being captured has canonicalKey 'strategy'. */
|
|
5
|
-
export declare function filterCreatableRelationTypes(declared: unknown, targetIsDomain: boolean, sourceIsStrategy: boolean): string[];
|
|
6
|
-
type TypeRow = {
|
|
7
|
-
data?: {
|
|
8
|
-
canonical_key?: unknown;
|
|
9
|
-
valid_relation_types?: unknown;
|
|
10
|
-
} | null;
|
|
11
|
-
};
|
|
12
|
-
/** Resolves the declared `valid_relation_types` for `canonicalKey` out of a semantic-types
|
|
13
|
-
* listEntries result. The server answers that read from its code catalog (DEC-1949,
|
|
14
|
-
* convex/chain/semanticTypes.ts typeCatalogRowsForWorkspace): one accepted, well-formed row per
|
|
15
|
-
* active type, so the row for the key is the one to read. Then filters to what `pb relate` can
|
|
16
|
-
* create. */
|
|
17
|
-
export declare function resolveCreatableRelationTypes(typeRows: readonly TypeRow[] | null | undefined, canonicalKey: string, targetIsDomain: boolean): string[];
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=legalRelationTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legalRelationTypes.d.ts","sourceRoot":"","sources":["../../src/lib/legalRelationTypes.ts"],"names":[],"mappings":"AA8CA;;;wEAGwE;AACxE,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,GAAG,MAAM,EAAE,CAS5H;AAED,KAAK,OAAO,GAAG;IACb,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC3E,CAAC;AAEF;;;;cAIc;AACd,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,EAC/C,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,OAAO,GACtB,MAAM,EAAE,CAGV"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WP-688 S4 review round 5 (bdB5K, cQFZ_): `pb capture`'s --link-type refusal door
|
|
3
|
-
* (commands/capture.ts) lists an entry's declared legal relation verbs as a `pb relate`
|
|
4
|
-
* recovery hint. "Declared" (the workspace's own semantic-type row, `valid_relation_types`)
|
|
5
|
-
* is NOT the same set as "creatable via pb relate's generic door" — guardRelation
|
|
6
|
-
* (convex/lib/guards.ts) hard-refuses some declared verbs outright:
|
|
7
|
-
* - replaces / do_not_confuse_with: always refused, routed to a different command
|
|
8
|
-
* (guards.ts:309-322).
|
|
9
|
-
* - Any verb outside the kernel ALLOWED_RELATION_TYPES set: refused regardless of what a
|
|
10
|
-
* type's declared `valid_relation_types` lists (guards.ts:302-307), so such a verb is never
|
|
11
|
-
* offered as a `pb relate` recovery verb.
|
|
12
|
-
* - belongs_to / authority_domain TOWARD a domain-tagged target (target canonicalKey ===
|
|
13
|
-
* 'domain'): requires ratification metadata (stagingEntryId + source) `pb relate` cannot
|
|
14
|
-
* supply (guards.ts:349-363).
|
|
15
|
-
* - anchored_to FROM a non-strategy source: its entire meaning is strategy-scope-anchor
|
|
16
|
-
* (WP-641 S2a) — predictStrategyAnchorViolation unconditionally rejects it whenever the
|
|
17
|
-
* source canonicalKey isn't 'strategy' (singletonCardinality.ts:339-341), regardless of
|
|
18
|
-
* target (round-5 finding bcRgRI).
|
|
19
|
-
* Centralized here so the filter isn't duplicated (or drifts) if another connector ever needs
|
|
20
|
-
* the same "legal AND creatable" list.
|
|
21
|
-
*
|
|
22
|
-
* WP-688 S4 review round 5 (bcQWqA): ALLOWED_RELATION_TYPES is read at RUNTIME (a filter, not a
|
|
23
|
-
* type check), so it cannot come from a bare `kernel/entries/relationTypes` value import —
|
|
24
|
-
* `kernel` is a devDependency-only, unpublished workspace package (present locally via monorepo
|
|
25
|
-
* linking, absent from the published `@productbrain/cli` npm package), so that import resolves
|
|
26
|
-
* here in dev/test but throws ERR_MODULE_NOT_FOUND for every real npm-installed `pb` command
|
|
27
|
-
* (index.ts statically imports capture.ts, which statically imports this file). Import the
|
|
28
|
-
* generated, CLI-owned copy instead — same pattern as sourceSurfaces.generated.ts (see
|
|
29
|
-
* scripts/generate-kernel-value-sets.mjs's header for the full rationale + retirement rule).
|
|
30
|
-
*/
|
|
31
|
-
import { ALLOWED_RELATION_TYPES as ALLOWED_RELATION_TYPES_LIST } from '../generated/relationTypes.generated.js';
|
|
32
|
-
const ALLOWED_RELATION_TYPES = new Set(ALLOWED_RELATION_TYPES_LIST);
|
|
33
|
-
/** Verbs guardRelation refuses outright regardless of ALLOWED_RELATION_TYPES membership — each
|
|
34
|
-
* routes to a different, specialized command instead of the generic relation door. */
|
|
35
|
-
const DIRECT_DOOR_BLOCKED = new Set(['replaces', 'do_not_confuse_with']);
|
|
36
|
-
/** Domain-tag verbs guardRelation only accepts via ratification metadata (guards.ts:349-363) —
|
|
37
|
-
* `pb relate` cannot supply it, so never recommend these toward a domain-tagged target. */
|
|
38
|
-
const DOMAIN_TAG_VERBS = new Set(['belongs_to', 'authority_domain']);
|
|
39
|
-
/** anchored_to only exists as a strategy-scope-anchor verb (WP-641 S2a) — never legal from a
|
|
40
|
-
* non-strategy source, regardless of target (bcRgRI). */
|
|
41
|
-
const STRATEGY_ONLY_VERBS = new Set(['anchored_to']);
|
|
42
|
-
/** Filters a workspace-declared `valid_relation_types` array down to verbs `pb relate`'s
|
|
43
|
-
* generic door can actually create toward the given target. `targetIsDomain` should be
|
|
44
|
-
* `true` when the link target entry's canonicalKey is 'domain'; `sourceIsStrategy` should be
|
|
45
|
-
* `true` when the entry being captured has canonicalKey 'strategy'. */
|
|
46
|
-
export function filterCreatableRelationTypes(declared, targetIsDomain, sourceIsStrategy) {
|
|
47
|
-
if (!Array.isArray(declared))
|
|
48
|
-
return [];
|
|
49
|
-
return declared.filter((t) => typeof t === 'string'
|
|
50
|
-
&& !DIRECT_DOOR_BLOCKED.has(t)
|
|
51
|
-
&& ALLOWED_RELATION_TYPES.has(t)
|
|
52
|
-
&& !(targetIsDomain && DOMAIN_TAG_VERBS.has(t))
|
|
53
|
-
&& !(!sourceIsStrategy && STRATEGY_ONLY_VERBS.has(t)));
|
|
54
|
-
}
|
|
55
|
-
/** Resolves the declared `valid_relation_types` for `canonicalKey` out of a semantic-types
|
|
56
|
-
* listEntries result. The server answers that read from its code catalog (DEC-1949,
|
|
57
|
-
* convex/chain/semanticTypes.ts typeCatalogRowsForWorkspace): one accepted, well-formed row per
|
|
58
|
-
* active type, so the row for the key is the one to read. Then filters to what `pb relate` can
|
|
59
|
-
* create. */
|
|
60
|
-
export function resolveCreatableRelationTypes(typeRows, canonicalKey, targetIsDomain) {
|
|
61
|
-
const row = (typeRows ?? []).find((r) => r.data?.canonical_key === canonicalKey);
|
|
62
|
-
return filterCreatableRelationTypes(row?.data?.valid_relation_types, targetIsDomain, canonicalKey === 'strategy');
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=legalRelationTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legalRelationTypes.js","sourceRoot":"","sources":["../../src/lib/legalRelationTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,sBAAsB,IAAI,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEhH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEzF;uFACuF;AACvF,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAE9F;4FAC4F;AAC5F,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE1F;0DAC0D;AAC1D,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAE1E;;;wEAGwE;AACxE,MAAM,UAAU,4BAA4B,CAAC,QAAiB,EAAE,cAAuB,EAAE,gBAAyB;IAChH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CACxC,OAAO,CAAC,KAAK,QAAQ;WAClB,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;WAC3B,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;WAC7B,CAAC,CAAC,cAAc,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAA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