@cat-factory/orchestration 0.264.0 → 0.265.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 (59) hide show
  1. package/dist/container/dependencies.d.ts +15 -2
  2. package/dist/container/dependencies.d.ts.map +1 -1
  3. package/dist/container/execution-service.d.ts.map +1 -1
  4. package/dist/container/execution-service.js +8 -0
  5. package/dist/container/execution-service.js.map +1 -1
  6. package/dist/container/module-shapes.d.ts +12 -1
  7. package/dist/container/module-shapes.d.ts.map +1 -1
  8. package/dist/container/modules.d.ts +8 -1
  9. package/dist/container/modules.d.ts.map +1 -1
  10. package/dist/container/modules.js +29 -4
  11. package/dist/container/modules.js.map +1 -1
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +3 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/modules/board/BoardService.d.ts +9 -2
  17. package/dist/modules/board/BoardService.d.ts.map +1 -1
  18. package/dist/modules/board/BoardService.js +13 -5
  19. package/dist/modules/board/BoardService.js.map +1 -1
  20. package/dist/modules/board/boardPolicyGuards.d.ts +34 -0
  21. package/dist/modules/board/boardPolicyGuards.d.ts.map +1 -0
  22. package/dist/modules/board/boardPolicyGuards.js +31 -0
  23. package/dist/modules/board/boardPolicyGuards.js.map +1 -0
  24. package/dist/modules/board/presetPinGuard.d.ts +17 -1
  25. package/dist/modules/board/presetPinGuard.d.ts.map +1 -1
  26. package/dist/modules/board/presetPinGuard.js +9 -3
  27. package/dist/modules/board/presetPinGuard.js.map +1 -1
  28. package/dist/modules/board/riskPolicySelectionGuard.d.ts +7 -2
  29. package/dist/modules/board/riskPolicySelectionGuard.d.ts.map +1 -1
  30. package/dist/modules/board/riskPolicySelectionGuard.js +2 -2
  31. package/dist/modules/board/riskPolicySelectionGuard.js.map +1 -1
  32. package/dist/modules/execution/ExecutionService.js +2 -2
  33. package/dist/modules/execution/ExecutionService.js.map +1 -1
  34. package/dist/modules/execution/ExecutionServiceDependencies.d.ts +6 -2
  35. package/dist/modules/execution/ExecutionServiceDependencies.d.ts.map +1 -1
  36. package/dist/modules/execution/RunLifecycleController.d.ts.map +1 -1
  37. package/dist/modules/execution/RunLifecycleController.js +13 -2
  38. package/dist/modules/execution/RunLifecycleController.js.map +1 -1
  39. package/dist/modules/execution/RunMergePolicy.d.ts +6 -2
  40. package/dist/modules/execution/RunMergePolicy.d.ts.map +1 -1
  41. package/dist/modules/execution/RunMergePolicy.js +1 -1
  42. package/dist/modules/execution/RunMergePolicy.js.map +1 -1
  43. package/dist/modules/merge/AccountRiskPolicyService.d.ts +57 -0
  44. package/dist/modules/merge/AccountRiskPolicyService.d.ts.map +1 -0
  45. package/dist/modules/merge/AccountRiskPolicyService.js +148 -0
  46. package/dist/modules/merge/AccountRiskPolicyService.js.map +1 -0
  47. package/dist/modules/merge/RiskPolicyService.d.ts +116 -10
  48. package/dist/modules/merge/RiskPolicyService.d.ts.map +1 -1
  49. package/dist/modules/merge/RiskPolicyService.js +208 -15
  50. package/dist/modules/merge/RiskPolicyService.js.map +1 -1
  51. package/dist/modules/merge/WorkspaceRiskPolicyLibrary.d.ts +100 -0
  52. package/dist/modules/merge/WorkspaceRiskPolicyLibrary.d.ts.map +1 -0
  53. package/dist/modules/merge/WorkspaceRiskPolicyLibrary.js +156 -0
  54. package/dist/modules/merge/WorkspaceRiskPolicyLibrary.js.map +1 -0
  55. package/dist/modules/merge/riskPolicyResolution.d.ts +8 -4
  56. package/dist/modules/merge/riskPolicyResolution.d.ts.map +1 -1
  57. package/dist/modules/merge/riskPolicyResolution.js +6 -2
  58. package/dist/modules/merge/riskPolicyResolution.js.map +1 -1
  59. package/package.json +11 -11
@@ -1,9 +1,21 @@
1
- import type { Clock, CreateRiskPolicyInput, GroupCacheHandle, IdGenerator, RiskPolicyRepository, RiskPolicy, RiskPolicyCacheValue, UpdateRiskPolicyInput, WorkspaceRepository } from '@cat-factory/kernel';
1
+ import type { Clock, CloneRiskPolicyInput, CreateRiskPolicyInput, GroupCacheHandle, IdGenerator, RiskPolicyRepository, RiskPolicyCacheValue, RiskPolicyLibraryEntry, RiskPolicySuppression, RiskPolicySuppressionRepository, UpdateRiskPolicyInput, WorkspaceRepository } from '@cat-factory/kernel';
2
+ import type { WorkspaceRiskPolicyLibrary } from './WorkspaceRiskPolicyLibrary.js';
2
3
  export interface RiskPolicyServiceDependencies {
3
4
  riskPolicyRepository: RiskPolicyRepository;
4
5
  workspaceRepository: WorkspaceRepository;
5
6
  idGenerator: IdGenerator;
6
7
  clock: Clock;
8
+ /**
9
+ * The board's merged library (ADR 0055): its own rows plus the account policies it inherits.
10
+ * Every READ below answers from it, so the editor lists exactly what the engine will resolve.
11
+ * Absent ⇒ the workspace tier alone, which is what a facade with no account tier wired sees.
12
+ */
13
+ library?: WorkspaceRiskPolicyLibrary;
14
+ /**
15
+ * Which inherited policies the board hides. Absent ⇒ suppression is unavailable, and the routes
16
+ * that need it refuse rather than reporting a hide that was never stored.
17
+ */
18
+ riskPolicySuppressionRepository?: RiskPolicySuppressionRepository;
7
19
  /**
8
20
  * Optional: the {@link AppCaches.riskPolicy} slice the engine reads a task's resolved preset
9
21
  * through. Every write below invalidates the workspace group so a preset edit is visible on the
@@ -15,7 +27,7 @@ export interface RiskPolicyServiceDependencies {
15
27
  * CRUD for a workspace's merge threshold presets (the library a task picks its auto-merge policy
16
28
  * from). Maintains the invariant that a workspace always has at least one preset, exactly one of
17
29
  * which is the default: the built-in catalog ({@link seedRiskPolicies}) is written when the board
18
- * is CREATED, `ensureSeeded` repairs a board that predates that, and the default cannot be
30
+ * is CREATED, {@link seedOwnTier} repairs a board that predates that, and the default cannot be
19
31
  * deleted. The single-default promotion is enforced in the repository. {@link reseed} restores a
20
32
  * built-in to the current catalog (adopting an update, repairing drift, or materialising a NEW
21
33
  * built-in that appeared after the workspace was created).
@@ -26,6 +38,8 @@ export declare class RiskPolicyService {
26
38
  private readonly idGenerator;
27
39
  private readonly clock;
28
40
  private readonly cache?;
41
+ private readonly library?;
42
+ private readonly suppressions?;
29
43
  constructor(deps: RiskPolicyServiceDependencies);
30
44
  /**
31
45
  * Drop the workspace's cached preset library after a write commits. Coarse (one group == one
@@ -33,12 +47,86 @@ export declare class RiskPolicyService {
33
47
  * radius is the whole library — over-invalidation is always safe (CLAUDE.md caching rule).
34
48
  */
35
49
  private invalidate;
36
- /** List a workspace's presets, repairing an empty library first (see `ensureSeeded`). */
37
- list(workspaceId: string): Promise<RiskPolicy[]>;
50
+ /**
51
+ * The board's visible library, repairing an empty own-tier on the way (see {@link seedOwnTier}):
52
+ * its own policies plus the account policies it inherits, each tagged with the tier that owns it.
53
+ *
54
+ * The MERGED view rather than the board's rows, because this list feeds the settings editor, the
55
+ * snapshot and therefore every picker — and the engine resolves a pin through the same merge. A
56
+ * read that showed only local rows would hide postures a task can legitimately be filed against.
57
+ *
58
+ * The seeding CHECK is read out of the merged list rather than made as its own query: an entry
59
+ * tagged `workspace` is a row the board owns, so its presence answers "has this tier been
60
+ * materialised" exactly. Asking separately made this — the board SNAPSHOT's read, the hottest in
61
+ * the app — pay a full own-tier list before the merge that lists the same rows again.
62
+ */
63
+ list(workspaceId: string): Promise<RiskPolicyLibraryEntry[]>;
64
+ /**
65
+ * Copy an inherited ACCOUNT policy into this board's own tier, under a FRESH id.
66
+ *
67
+ * The fresh id is the whole design (see `cloneRiskPolicySchema`): an override sharing the account
68
+ * id would re-point every task already filed against the account's posture the moment the board
69
+ * edited its copy. The copy claims neither default — promoting it is a separate, deliberate act,
70
+ * and a clone that silently became the board's default would change how every unpinned task lands.
71
+ *
72
+ * Refuses an id the board already owns (`risk_policy_not_inherited`): that is a duplicate, not a
73
+ * clone, and the two need different copy.
74
+ */
75
+ clone(workspaceId: string, presetId: string, input: CloneRiskPolicyInput): Promise<RiskPolicyLibraryEntry>;
76
+ /**
77
+ * HIDE an inherited account policy from this board: it leaves the merged library, so no task here
78
+ * can pin it and no picker offers it.
79
+ *
80
+ * A task that ALREADY pinned it falls back to the board's default for its scope, which is exactly
81
+ * what a deleted local policy does (`resolveRiskPolicy` documents the dangling pin). The two acts
82
+ * are deliberately alike: hiding is the opt-out a board has for a row it cannot delete.
83
+ *
84
+ * Refuses an id the board owns (`risk_policy_not_inherited`) — delete that instead — and an id
85
+ * nothing inherits, which would otherwise write a suppression that shadows nothing today and
86
+ * silently swallows whatever the account defines under it tomorrow.
87
+ */
88
+ suppress(workspaceId: string, presetId: string): Promise<void>;
89
+ /**
90
+ * Stop hiding an inherited policy, so the board offers it again.
91
+ *
92
+ * Deliberately permissive about what it lifts: a suppression whose account policy has since been
93
+ * withdrawn hides nothing, and clearing it is still the right answer (it is listed, so it has to
94
+ * be dismissable). The refusal that matters is the one above, at the moment the row is written.
95
+ */
96
+ restoreInherited(workspaceId: string, presetId: string): Promise<void>;
97
+ /**
98
+ * What this board is hiding, and whether each suppression still shadows anything.
99
+ *
100
+ * Gated on the same store the WRITES are, so an unwired facade REFUSES here rather than answering
101
+ * an empty list: "this board hides nothing" and "this deployment cannot say what it hides" are
102
+ * different facts, and only the refusal states the second one (CLAUDE.md's absent-≠-zero rule).
103
+ * Answering `[]` positively claimed the first while the very next `suppress` returned a 503.
104
+ */
105
+ listSuppressions(workspaceId: string): Promise<RiskPolicySuppression[]>;
106
+ /**
107
+ * The account policy this board INHERITS under an id, or a 404.
108
+ *
109
+ * Suppression-aware (see `WorkspaceRiskPolicyLibrary.inheritedPolicy`), so the three states that
110
+ * are not "the board may clone this" collapse into one refusal: nothing defines the id, the
111
+ * account withdrew it, or this board hid it. Cloning is the only caller, and none of the three
112
+ * leaves it anything to copy — a board that opted out of a posture asking for a copy of it is a
113
+ * stale screen, not a request to honour.
114
+ */
115
+ private requireInherited;
116
+ /**
117
+ * Everything hiding takes: the suppression store AND the merged library that names what it holds,
118
+ * or a 503 naming what is not wired.
119
+ *
120
+ * A total accessor rather than a silent no-op: reporting success for a hide that was never stored
121
+ * would leave the operator looking at a policy they had just been told was hidden. Both halves are
122
+ * checked together, and the reads gate on it as well as the writes, so no caller can end up
123
+ * answering from one of the two while the other is missing.
124
+ */
125
+ private requireSuppressionSupport;
38
126
  /** Create a new preset. The first one (or one flagged default) becomes the default. */
39
- create(workspaceId: string, input: CreateRiskPolicyInput): Promise<RiskPolicy>;
127
+ create(workspaceId: string, input: CreateRiskPolicyInput): Promise<RiskPolicyLibraryEntry>;
40
128
  /** Patch a preset. Demoting the only default is rejected (one must remain). */
41
- update(workspaceId: string, id: string, patch: UpdateRiskPolicyInput): Promise<RiskPolicy>;
129
+ update(workspaceId: string, id: string, patch: UpdateRiskPolicyInput): Promise<RiskPolicyLibraryEntry>;
42
130
  /** Remove a preset. Neither scope's default preset can be removed. */
43
131
  remove(workspaceId: string, id: string): Promise<void>;
44
132
  /**
@@ -53,9 +141,25 @@ export declare class RiskPolicyService {
53
141
  * `mp_balanced`) can never steal the default away from the user's chosen preset.
54
142
  * Rejects an id not in the catalog (a custom preset — delete it instead).
55
143
  */
56
- reseed(workspaceId: string, id: string): Promise<RiskPolicy>;
144
+ reseed(workspaceId: string, id: string): Promise<RiskPolicyLibraryEntry>;
145
+ /**
146
+ * Refuse a write aimed at a policy the ACCOUNT owns, naming the remedy (`risk_policy_inherited`).
147
+ *
148
+ * Checked BEFORE the board's own row is read, because the two failures need different copy and the
149
+ * bare 404 the read would produce is the misleading one: an inherited policy is visible in the
150
+ * board's editor and in every picker, so "no such policy" reads as a bug in the app rather than as
151
+ * "this one is not yours to change". The clone action is what leaves the board a row it can edit.
152
+ *
153
+ * Silent when no account tier is wired: there is nothing to inherit, so the caller's own 404 is
154
+ * then the honest answer.
155
+ *
156
+ * Takes the board's own row rather than re-reading it. The caller needs that row anyway (to patch,
157
+ * or to check the default flags before deleting), and the guard needs only to know whether it
158
+ * exists, so reading it here made every policy edit and delete pay two identical point queries.
159
+ */
160
+ private assertNotInherited;
57
161
  /**
58
- * REPAIR a workspace whose preset library is empty, by writing the built-in catalog.
162
+ * REPAIR a workspace whose own preset tier is empty, by writing the built-in catalog.
59
163
  *
60
164
  * Creating a board is what normally seeds the library ({@link WorkspaceService.create}), and
61
165
  * that is where the invariant belongs: the engine resolves a task's governing preset without
@@ -66,8 +170,10 @@ export declare class RiskPolicyService {
66
170
  * made before creation seeded presets, and one whose facade wired the preset repository only
67
171
  * later. Both currently resolve `FALLBACK_RISK_POLICY`, which auto-merges nothing, so the
68
172
  * repair can only move a workspace from refusing everything to its configured default.
69
- * Idempotent, and a no-op on every board created since.
173
+ *
174
+ * The emptiness TEST belongs to the caller, which has just read the library and therefore already
175
+ * knows the answer; this only writes.
70
176
  */
71
- private ensureSeeded;
177
+ private seedOwnTier;
72
178
  }
73
179
  //# sourceMappingURL=RiskPolicyService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RiskPolicyService.d.ts","sourceRoot":"","sources":["../../../src/modules/merge/RiskPolicyService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAW5B,MAAM,WAAW,6BAA6B;IAC5C,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;CACzD;AAED;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IACzD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAwC;I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AAgB;IAM9B;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAgBjC,uFAAuF;IACjF,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAqC/F;IAED,+EAA+E;IACzE,MAAM,CACV,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAoEjC;IAED,sEAAsE;IAChE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3D;IAED;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA8B7E;IAED;;;;;;;;;;;;;;OAcG;YACW,kBAAkB;IAehC;;;;;;;;;;;;;;;OAeG;YACW,WAAW;CAQ1B"}
@@ -1,9 +1,9 @@
1
- import { assertFound, ConflictError, requireWorkspace, riskPolicyFromSeed, riskPolicySeedRows, seedRiskPolicies, ValidationError, } from '@cat-factory/kernel';
1
+ import { assertFound, ConflictError, NotFoundError, requireWorkspace, riskPolicyFromSeed, riskPolicySeedRows, seedRiskPolicies, UnavailableError, ValidationError, } from '@cat-factory/kernel';
2
2
  /**
3
3
  * CRUD for a workspace's merge threshold presets (the library a task picks its auto-merge policy
4
4
  * from). Maintains the invariant that a workspace always has at least one preset, exactly one of
5
5
  * which is the default: the built-in catalog ({@link seedRiskPolicies}) is written when the board
6
- * is CREATED, `ensureSeeded` repairs a board that predates that, and the default cannot be
6
+ * is CREATED, {@link seedOwnTier} repairs a board that predates that, and the default cannot be
7
7
  * deleted. The single-default promotion is enforced in the repository. {@link reseed} restores a
8
8
  * built-in to the current catalog (adopting an update, repairing drift, or materialising a NEW
9
9
  * built-in that appeared after the workspace was created).
@@ -14,12 +14,16 @@ export class RiskPolicyService {
14
14
  idGenerator;
15
15
  clock;
16
16
  cache;
17
+ library;
18
+ suppressions;
17
19
  constructor(deps) {
18
20
  this.presets = deps.riskPolicyRepository;
19
21
  this.workspaceRepository = deps.workspaceRepository;
20
22
  this.idGenerator = deps.idGenerator;
21
23
  this.clock = deps.clock;
22
24
  this.cache = deps.riskPolicyCache;
25
+ this.library = deps.library;
26
+ this.suppressions = deps.riskPolicySuppressionRepository;
23
27
  }
24
28
  /**
25
29
  * Drop the workspace's cached preset library after a write commits. Coarse (one group == one
@@ -29,11 +33,164 @@ export class RiskPolicyService {
29
33
  async invalidate(workspaceId) {
30
34
  await this.cache?.invalidateGroup(workspaceId);
31
35
  }
32
- /** List a workspace's presets, repairing an empty library first (see `ensureSeeded`). */
36
+ /**
37
+ * The board's visible library, repairing an empty own-tier on the way (see {@link seedOwnTier}):
38
+ * its own policies plus the account policies it inherits, each tagged with the tier that owns it.
39
+ *
40
+ * The MERGED view rather than the board's rows, because this list feeds the settings editor, the
41
+ * snapshot and therefore every picker — and the engine resolves a pin through the same merge. A
42
+ * read that showed only local rows would hide postures a task can legitimately be filed against.
43
+ *
44
+ * The seeding CHECK is read out of the merged list rather than made as its own query: an entry
45
+ * tagged `workspace` is a row the board owns, so its presence answers "has this tier been
46
+ * materialised" exactly. Asking separately made this — the board SNAPSHOT's read, the hottest in
47
+ * the app — pay a full own-tier list before the merge that lists the same rows again.
48
+ */
33
49
  async list(workspaceId) {
34
50
  await requireWorkspace(this.workspaceRepository, workspaceId);
35
- await this.ensureSeeded(workspaceId);
36
- return this.presets.list(workspaceId);
51
+ if (!this.library) {
52
+ const own = await this.presets.list(workspaceId);
53
+ if (own.length > 0)
54
+ return own.map(ownEntry);
55
+ await this.seedOwnTier(workspaceId);
56
+ return (await this.presets.list(workspaceId)).map(ownEntry);
57
+ }
58
+ const merged = await this.library.list(workspaceId);
59
+ if (merged.some((entry) => entry.tier === 'workspace'))
60
+ return merged;
61
+ // Only ever the two states creation cannot reach backwards into, so the re-read costs nothing
62
+ // on any board made since.
63
+ await this.seedOwnTier(workspaceId);
64
+ return this.library.list(workspaceId);
65
+ }
66
+ /**
67
+ * Copy an inherited ACCOUNT policy into this board's own tier, under a FRESH id.
68
+ *
69
+ * The fresh id is the whole design (see `cloneRiskPolicySchema`): an override sharing the account
70
+ * id would re-point every task already filed against the account's posture the moment the board
71
+ * edited its copy. The copy claims neither default — promoting it is a separate, deliberate act,
72
+ * and a clone that silently became the board's default would change how every unpinned task lands.
73
+ *
74
+ * Refuses an id the board already owns (`risk_policy_not_inherited`): that is a duplicate, not a
75
+ * clone, and the two need different copy.
76
+ */
77
+ async clone(workspaceId, presetId, input) {
78
+ await requireWorkspace(this.workspaceRepository, workspaceId);
79
+ // The whole own tier in ONE read, because both questions below are about it: whether this id is
80
+ // already the board's, and whether the board holds anything at all.
81
+ const existing = await this.presets.list(workspaceId);
82
+ if (existing.some((policy) => policy.id === presetId)) {
83
+ throw new ConflictError(`Risk policy '${presetId}' already belongs to this board, so there is nothing to clone in.`, 'risk_policy_not_inherited', { presetId });
84
+ }
85
+ const source = await this.requireInherited(workspaceId, presetId);
86
+ // The FIRST own policy must claim both defaults, exactly as in `create` and for the same reason:
87
+ // a scope with no default resolves `FALLBACK_RISK_POLICY`, which merges nothing. A board whose
88
+ // own tier was never materialised (the population {@link seedOwnTier} repairs) can reach this as
89
+ // its first own row, and hard-coding false there left it holding a library it could land nothing
90
+ // through, with no badge on screen and nothing explaining why.
91
+ const isFirstOwnPolicy = existing.length === 0;
92
+ const preset = {
93
+ ...source,
94
+ id: this.idGenerator.next('mp'),
95
+ name: input.name ?? source.name,
96
+ // A CLONE is a new policy, never a reseedable built-in: dropping the catalog version is what
97
+ // stops the copy of an account policy that happens to carry a built-in id being offered a
98
+ // reseed that would overwrite it with catalog values it never came from.
99
+ version: undefined,
100
+ isDefault: isFirstOwnPolicy,
101
+ isUnattendedDefault: isFirstOwnPolicy,
102
+ createdAt: this.clock.now(),
103
+ };
104
+ await this.presets.upsert(workspaceId, preset);
105
+ await this.invalidate(workspaceId);
106
+ return ownEntry(preset);
107
+ }
108
+ /**
109
+ * HIDE an inherited account policy from this board: it leaves the merged library, so no task here
110
+ * can pin it and no picker offers it.
111
+ *
112
+ * A task that ALREADY pinned it falls back to the board's default for its scope, which is exactly
113
+ * what a deleted local policy does (`resolveRiskPolicy` documents the dangling pin). The two acts
114
+ * are deliberately alike: hiding is the opt-out a board has for a row it cannot delete.
115
+ *
116
+ * Refuses an id the board owns (`risk_policy_not_inherited`) — delete that instead — and an id
117
+ * nothing inherits, which would otherwise write a suppression that shadows nothing today and
118
+ * silently swallows whatever the account defines under it tomorrow.
119
+ */
120
+ async suppress(workspaceId, presetId) {
121
+ await requireWorkspace(this.workspaceRepository, workspaceId);
122
+ const { suppressions, library } = this.requireSuppressionSupport();
123
+ const own = await this.presets.get(workspaceId, presetId);
124
+ if (own) {
125
+ throw new ConflictError(`Risk policy '${presetId}' belongs to this board, so hiding it would only be an obscure way to delete it.`, 'risk_policy_not_inherited', { presetId });
126
+ }
127
+ // What the ACCOUNT defines, not what this board currently inherits: hiding is idempotent, and
128
+ // asking the suppression-aware question would 404 the second click on the grounds that the first
129
+ // one worked.
130
+ if (!(await library.accountPolicy(workspaceId, presetId))) {
131
+ throw new NotFoundError('RiskPolicy', presetId);
132
+ }
133
+ await suppressions.add(workspaceId, presetId, this.clock.now());
134
+ await this.invalidate(workspaceId);
135
+ }
136
+ /**
137
+ * Stop hiding an inherited policy, so the board offers it again.
138
+ *
139
+ * Deliberately permissive about what it lifts: a suppression whose account policy has since been
140
+ * withdrawn hides nothing, and clearing it is still the right answer (it is listed, so it has to
141
+ * be dismissable). The refusal that matters is the one above, at the moment the row is written.
142
+ */
143
+ async restoreInherited(workspaceId, presetId) {
144
+ await requireWorkspace(this.workspaceRepository, workspaceId);
145
+ const { suppressions } = this.requireSuppressionSupport();
146
+ await suppressions.remove(workspaceId, presetId);
147
+ await this.invalidate(workspaceId);
148
+ }
149
+ /**
150
+ * What this board is hiding, and whether each suppression still shadows anything.
151
+ *
152
+ * Gated on the same store the WRITES are, so an unwired facade REFUSES here rather than answering
153
+ * an empty list: "this board hides nothing" and "this deployment cannot say what it hides" are
154
+ * different facts, and only the refusal states the second one (CLAUDE.md's absent-≠-zero rule).
155
+ * Answering `[]` positively claimed the first while the very next `suppress` returned a 503.
156
+ */
157
+ async listSuppressions(workspaceId) {
158
+ await requireWorkspace(this.workspaceRepository, workspaceId);
159
+ const { library } = this.requireSuppressionSupport();
160
+ return library.listSuppressions(workspaceId);
161
+ }
162
+ /**
163
+ * The account policy this board INHERITS under an id, or a 404.
164
+ *
165
+ * Suppression-aware (see `WorkspaceRiskPolicyLibrary.inheritedPolicy`), so the three states that
166
+ * are not "the board may clone this" collapse into one refusal: nothing defines the id, the
167
+ * account withdrew it, or this board hid it. Cloning is the only caller, and none of the three
168
+ * leaves it anything to copy — a board that opted out of a posture asking for a copy of it is a
169
+ * stale screen, not a request to honour.
170
+ */
171
+ async requireInherited(workspaceId, presetId) {
172
+ const inherited = await this.library?.inheritedPolicy(workspaceId, presetId);
173
+ if (!inherited)
174
+ throw new NotFoundError('RiskPolicy', presetId);
175
+ return inherited;
176
+ }
177
+ /**
178
+ * Everything hiding takes: the suppression store AND the merged library that names what it holds,
179
+ * or a 503 naming what is not wired.
180
+ *
181
+ * A total accessor rather than a silent no-op: reporting success for a hide that was never stored
182
+ * would leave the operator looking at a policy they had just been told was hidden. Both halves are
183
+ * checked together, and the reads gate on it as well as the writes, so no caller can end up
184
+ * answering from one of the two while the other is missing.
185
+ */
186
+ requireSuppressionSupport() {
187
+ if (!this.suppressions || !this.library) {
188
+ // Its OWN reason rather than the `risk_policies_unwired` the pin guard raises: the policies
189
+ // ARE configured here, and sending an operator to wire a library they can already see would
190
+ // be the misattribution that reason exists to avoid.
191
+ throw new UnavailableError('Hiding an inherited risk policy is not configured', 'risk_policy_suppressions_unwired');
192
+ }
193
+ return { suppressions: this.suppressions, library: this.library };
37
194
  }
38
195
  /** Create a new preset. The first one (or one flagged default) becomes the default. */
39
196
  async create(workspaceId, input) {
@@ -72,12 +229,14 @@ export class RiskPolicyService {
72
229
  };
73
230
  await this.presets.upsert(workspaceId, preset);
74
231
  await this.invalidate(workspaceId);
75
- return preset;
232
+ return ownEntry(preset);
76
233
  }
77
234
  /** Patch a preset. Demoting the only default is rejected (one must remain). */
78
235
  async update(workspaceId, id, patch) {
79
236
  await requireWorkspace(this.workspaceRepository, workspaceId);
80
- const existing = assertFound(await this.presets.get(workspaceId, id), 'RiskPolicy', id);
237
+ const own = await this.presets.get(workspaceId, id);
238
+ await this.assertNotInherited(workspaceId, id, own);
239
+ const existing = assertFound(own, 'RiskPolicy', id);
81
240
  if (existing.isDefault && patch.isDefault === false) {
82
241
  throw new ConflictError('Cannot unset the default preset; promote another preset instead.');
83
242
  }
@@ -138,12 +297,13 @@ export class RiskPolicyService {
138
297
  };
139
298
  await this.presets.upsert(workspaceId, updated);
140
299
  await this.invalidate(workspaceId);
141
- return updated;
300
+ return ownEntry(updated);
142
301
  }
143
302
  /** Remove a preset. Neither scope's default preset can be removed. */
144
303
  async remove(workspaceId, id) {
145
304
  await requireWorkspace(this.workspaceRepository, workspaceId);
146
305
  const existing = await this.presets.get(workspaceId, id);
306
+ await this.assertNotInherited(workspaceId, id, existing);
147
307
  if (existing?.isDefault) {
148
308
  throw new ConflictError('Cannot delete the default preset; promote another preset first.');
149
309
  }
@@ -192,10 +352,33 @@ export class RiskPolicyService {
192
352
  };
193
353
  await this.presets.upsert(workspaceId, preset);
194
354
  await this.invalidate(workspaceId);
195
- return preset;
355
+ return ownEntry(preset);
196
356
  }
197
357
  /**
198
- * REPAIR a workspace whose preset library is empty, by writing the built-in catalog.
358
+ * Refuse a write aimed at a policy the ACCOUNT owns, naming the remedy (`risk_policy_inherited`).
359
+ *
360
+ * Checked BEFORE the board's own row is read, because the two failures need different copy and the
361
+ * bare 404 the read would produce is the misleading one: an inherited policy is visible in the
362
+ * board's editor and in every picker, so "no such policy" reads as a bug in the app rather than as
363
+ * "this one is not yours to change". The clone action is what leaves the board a row it can edit.
364
+ *
365
+ * Silent when no account tier is wired: there is nothing to inherit, so the caller's own 404 is
366
+ * then the honest answer.
367
+ *
368
+ * Takes the board's own row rather than re-reading it. The caller needs that row anyway (to patch,
369
+ * or to check the default flags before deleting), and the guard needs only to know whether it
370
+ * exists, so reading it here made every policy edit and delete pay two identical point queries.
371
+ */
372
+ async assertNotInherited(workspaceId, id, own) {
373
+ if (own)
374
+ return;
375
+ const inherited = await this.library?.inheritedPolicy(workspaceId, id);
376
+ if (!inherited)
377
+ return;
378
+ throw new ConflictError(`Risk policy '${id}' is defined by the account, so this board cannot change it. Clone it to edit a copy here.`, 'risk_policy_inherited', { presetId: id });
379
+ }
380
+ /**
381
+ * REPAIR a workspace whose own preset tier is empty, by writing the built-in catalog.
199
382
  *
200
383
  * Creating a board is what normally seeds the library ({@link WorkspaceService.create}), and
201
384
  * that is where the invariant belongs: the engine resolves a task's governing preset without
@@ -206,12 +389,11 @@ export class RiskPolicyService {
206
389
  * made before creation seeded presets, and one whose facade wired the preset repository only
207
390
  * later. Both currently resolve `FALLBACK_RISK_POLICY`, which auto-merges nothing, so the
208
391
  * repair can only move a workspace from refusing everything to its configured default.
209
- * Idempotent, and a no-op on every board created since.
392
+ *
393
+ * The emptiness TEST belongs to the caller, which has just read the library and therefore already
394
+ * knows the answer; this only writes.
210
395
  */
211
- async ensureSeeded(workspaceId) {
212
- const current = await this.presets.list(workspaceId);
213
- if (current.length > 0)
214
- return;
396
+ async seedOwnTier(workspaceId) {
215
397
  for (const preset of riskPolicySeedRows(this.clock.now())) {
216
398
  await this.presets.upsert(workspaceId, preset);
217
399
  }
@@ -220,4 +402,15 @@ export class RiskPolicyService {
220
402
  await this.invalidate(workspaceId);
221
403
  }
222
404
  }
405
+ /**
406
+ * A row this board OWNS → the library entry the wire carries.
407
+ *
408
+ * Every write on this service lands in the workspace tier by construction, so the tier is stated
409
+ * here rather than re-derived: a response that echoed a just-written policy without it would leave
410
+ * the SPA upserting an untagged row into a tier-tagged list, and the editor would render the board's
411
+ * own new policy with the inherited tier's read-only affordances until the next full reload.
412
+ */
413
+ function ownEntry(preset) {
414
+ return { ...preset, tier: 'workspace' };
415
+ }
223
416
  //# sourceMappingURL=RiskPolicyService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RiskPolicyService.js","sourceRoot":"","sources":["../../../src/modules/merge/RiskPolicyService.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAe5B;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IACX,OAAO,CAAsB;IAC7B,mBAAmB,CAAqB;IACxC,WAAW,CAAa;IACxB,KAAK,CAAO;IACZ,KAAK,CAAyC;IAE/D,YAAY,IAAmC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAA;QACxC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,UAAU,CAAC,WAAmB;QAC1C,MAAM,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;IAChD,CAAC;IAED,yFAAyF;IACzF,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,MAAM,gBAAgB,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;QAC7D,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;QACpC,OAAO,IAAI,CAAC,OAAO,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C,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAChD,CAAC;QACD,iFAAiF;QACjF,0FAA0F;QAC1F,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,MAAkB;IAClC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;AACzC,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { AccountRiskPolicy, AccountRiskPolicyRepository, RiskPolicy, RiskPolicyLibraryEntry, RiskPolicyRepository, RiskPolicySuppression, RiskPolicySuppressionRepository, RunDefaultScope, WorkspaceRepository, WorkspaceRiskPolicyReader } from '@cat-factory/kernel';
2
+ export interface WorkspaceRiskPolicyLibraryDeps {
3
+ /** The board's own policies: the built-in catalog copied in at creation, plus whatever it authored. */
4
+ riskPolicyRepository: RiskPolicyRepository;
5
+ /**
6
+ * The account tier. Optional, and its absence is a PASS-THROUGH rather than a hole to guard: with
7
+ * no account tier wired every read below answers exactly what the workspace repository answers,
8
+ * which is byte-for-byte the behaviour before ADR 0055.
9
+ */
10
+ accountRiskPolicyRepository?: AccountRiskPolicyRepository;
11
+ /**
12
+ * What the board hides from the account tier. Optional for the same reason, and absent it hides
13
+ * nothing — the direction that OFFERS a posture rather than silently withdrawing one, so a facade
14
+ * mid-migration can only ever show too much, never resolve a policy the editor called hidden.
15
+ */
16
+ riskPolicySuppressionRepository?: RiskPolicySuppressionRepository;
17
+ /** Resolves the board's account, which is what makes an inherited tier addressable. */
18
+ workspaceRepository: WorkspaceRepository;
19
+ }
20
+ /**
21
+ * A board's risk-policy library: its OWN policies merged with the account policies it inherits
22
+ * (ADR 0055), behind the same three reads every consumer already made of the workspace tier.
23
+ *
24
+ * It is the {@link WorkspaceRiskPolicyReader} the engine's `resolveRiskPolicy`, the board's two
25
+ * selection guards, the settings editor and the snapshot all hold, and that is the point: a
26
+ * resolution that admitted an id the editor calls hidden — or refused one a picker offered — would
27
+ * decide how much oversight a task's merge takes by a rule nobody can see. The PRECEDENCE itself
28
+ * lives in kernel (`mergeRiskPolicyTiers` / `resolveRiskPolicyTier`), so this class is only the I/O
29
+ * around it and the two cannot drift.
30
+ */
31
+ /**
32
+ * Build the library from a container's dependency bag, or `undefined` when no board tier is wired.
33
+ *
34
+ * Every consumer composes it through THIS factory rather than reaching for the repositories itself:
35
+ * the board guards, the engine's wiring and the risk-policy module each need the same three-store
36
+ * composition, and the one that assembled it by hand would be the one that forgot the suppression
37
+ * store and quietly resolved a policy the editor calls hidden. Instances hold no state, so building
38
+ * one per consumer costs nothing.
39
+ */
40
+ export declare function createWorkspaceRiskPolicyLibrary(deps: {
41
+ riskPolicyRepository?: RiskPolicyRepository;
42
+ accountRiskPolicyRepository?: AccountRiskPolicyRepository;
43
+ riskPolicySuppressionRepository?: RiskPolicySuppressionRepository;
44
+ workspaceRepository: WorkspaceRepository;
45
+ }): WorkspaceRiskPolicyLibrary | undefined;
46
+ export declare class WorkspaceRiskPolicyLibrary implements WorkspaceRiskPolicyReader {
47
+ private readonly deps;
48
+ constructor(deps: WorkspaceRiskPolicyLibraryDeps);
49
+ /** The merged library, account tier first, each entry tagged with the tier that owns it. */
50
+ list(workspaceId: string): Promise<RiskPolicyLibraryEntry[]>;
51
+ /**
52
+ * One policy by id, under the same precedence {@link list} applies.
53
+ *
54
+ * The board's own tier is read FIRST and answers alone when it hits, which is both the correct
55
+ * precedence and the common case: a task usually pins a policy its own board holds, and paying
56
+ * for the account reads only on a miss keeps the engine's per-gate resolution at one query where
57
+ * it already was.
58
+ */
59
+ get(workspaceId: string, id: string): Promise<RiskPolicyLibraryEntry | null>;
60
+ /**
61
+ * The board's default for one scope — the WORKSPACE tier's own answer, unchanged by inheritance.
62
+ *
63
+ * A delegate rather than a merge, and deliberately so: an account row carries no default claim
64
+ * (see `AccountRiskPolicy`), because which policy governs a task that pinned nothing is a
65
+ * per-board question that no single account row could answer correctly for every board under it.
66
+ * A board that wants an inherited posture as its default clones it and promotes the copy.
67
+ */
68
+ getDefault(workspaceId: string, scope: RunDefaultScope): Promise<RiskPolicy | null>;
69
+ /**
70
+ * What this board hides, joined against the account tier for identity — including the entries
71
+ * that now hide nothing because the account withdrew the policy (see
72
+ * `describeRiskPolicySuppressions`).
73
+ */
74
+ listSuppressions(workspaceId: string): Promise<RiskPolicySuppression[]>;
75
+ /**
76
+ * The account policy this board actually INHERITS under `id`, or null.
77
+ *
78
+ * Suppression-aware, under exactly the precedence {@link list} and {@link get} apply, because that
79
+ * is what makes this the merged reader rather than a second opinion: a hidden id is absent from the
80
+ * library, so a guard answering off the raw account row would let a board CLONE a posture it had
81
+ * just opted out of, and would tell an operator editing that id that the account governs their
82
+ * board when the board has withdrawn it.
83
+ */
84
+ inheritedPolicy(workspaceId: string, id: string): Promise<AccountRiskPolicy | null>;
85
+ /**
86
+ * What the ACCOUNT defines under `id`, whether or not this board hides it.
87
+ *
88
+ * Deliberately suppression-BLIND, and its own method rather than a flag on the one above, for the
89
+ * single caller that needs it: hiding is idempotent, so hiding an already-hidden policy has to
90
+ * settle as the state it already is. Asked through {@link inheritedPolicy} that request would 404
91
+ * on the second click, which is a refusal reporting a failure for a board that is in exactly the
92
+ * state the request asked for.
93
+ */
94
+ accountPolicy(workspaceId: string, id: string): Promise<AccountRiskPolicy | null>;
95
+ /** The account tier as the merge wants it: its policies plus this board's suppressions. */
96
+ private inheritedTier;
97
+ private suppressedIds;
98
+ private accountOf;
99
+ }
100
+ //# sourceMappingURL=WorkspaceRiskPolicyLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceRiskPolicyLibrary.d.ts","sourceRoot":"","sources":["../../../src/modules/merge/WorkspaceRiskPolicyLibrary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,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