@oathe/oathe 0.0.1 → 0.2.1
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/.claude-plugin/marketplace.json +14 -0
- package/LICENSE +202 -21
- package/NOTICE +7 -0
- package/README.md +104 -12
- package/assets/oathe-hero.svg +92 -0
- package/bin/oathe.mjs +376 -0
- package/docs/PRIVACY.md +45 -0
- package/package.json +33 -23
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/.mcp.json +13 -0
- package/plugin/hooks/frame-note.mjs +24 -0
- package/plugin/hooks/heartbeat.mjs +49 -0
- package/plugin/hooks/hooks.json +39 -0
- package/plugin/hooks/lib.mjs +83 -0
- package/plugin/hooks/render-board.mjs +11 -0
- package/plugin/skills/oathe-work/SKILL.md +33 -0
- package/src/atif.mjs +633 -0
- package/src/blocks.mjs +192 -0
- package/src/board-render.mjs +106 -0
- package/src/config.mjs +169 -0
- package/src/context.mjs +35 -0
- package/src/doctor.mjs +108 -0
- package/src/harness.mjs +271 -0
- package/src/init.mjs +92 -0
- package/src/launch-env.mjs +25 -0
- package/src/launch.mjs +259 -0
- package/src/manifest.mjs +89 -0
- package/src/mcp/oathe-tools.mjs +517 -0
- package/src/paths.mjs +49 -0
- package/src/plans.mjs +50 -0
- package/src/runtime/discharge.mjs +57 -0
- package/src/runtime/provider.mjs +154 -0
- package/src/runtime/simple-cage.mjs +67 -0
- package/src/runtime/sql-acceptance-lane.mjs +89 -0
- package/src/session-host.mjs +81 -0
- package/src/substrate.mjs +337 -0
- package/src/successor.mjs +31 -0
- package/src/traces.mjs +242 -0
- package/src/uninstall.mjs +45 -0
- package/src/verifier.mjs +322 -0
- package/src/workspace.mjs +47 -0
- package/vendor/ddl/001_core.sql +312 -0
- package/vendor/ddl/002_claim.sql +438 -0
- package/vendor/ddl/003_verification.sql +480 -0
- package/vendor/ddl/004_delegation.sql +397 -0
- package/vendor/ddl/005_escalation.sql +303 -0
- package/vendor/ddl/006_dependency.sql +384 -0
- package/vendor/ddl/007_assignment.sql +502 -0
- package/vendor/ddl/008_effect_receipt.sql +290 -0
- package/vendor/ddl/009_verified_edge.sql +452 -0
- package/vendor/ddl/010_parent_child_verification.sql +320 -0
- package/vendor/ddl/011_confirm.sql +288 -0
- package/vendor/ddl/012_evaluator_lane.sql +444 -0
- package/vendor/ddl/013_claim_terminal.sql +279 -0
- package/vendor/ddl/014_claim_settlement.sql +327 -0
- package/vendor/ddl/015_claim_yield.sql +213 -0
- package/vendor/ddl/016_reopened_reclaim.sql +285 -0
- package/vendor/ddl/017_claim_yield_causes.sql +357 -0
- package/vendor/ddl/018_receiptless_unknown.sql +249 -0
- package/vendor/ddl/019_verification_contract_freeze.sql +335 -0
- package/vendor/ddl/020_context_compilation.sql +105 -0
- package/vendor/ddl/021_execution_attempt_closure.sql +95 -0
- package/vendor/ddl/022_verification_clause.sql +106 -0
- package/vendor/ddl/023_executor_role.sql +66 -0
- package/vendor/ddl/024_executor_role_hardening.sql +439 -0
- package/vendor/ddl/025_running_attempt_uniqueness.sql +102 -0
- package/vendor/ddl/026_acceptance_authority.sql +230 -0
- package/vendor/ddl/027_ownership_return.sql +836 -0
- package/vendor/ddl/028_attempt_bind_ownership.sql +173 -0
- package/vendor/ddl/manifest.json +183 -0
- package/index.js +0 -33
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
-- 005_escalation.sql — the escalation lane: the typed act that replaces the
|
|
2
|
+
-- abolished modal block.
|
|
3
|
+
--
|
|
4
|
+
-- Contract: FOUNDER RULING R6 — "Modal/input-blocking is abolished in the
|
|
5
|
+
-- headless cell. Needing input is a typed act: the `escalate` tool — a typed
|
|
6
|
+
-- escalation event addressed to the agent's ASSIGNER (`dispatched_by` / parent
|
|
7
|
+
-- chain), cascading to the CEO principal, who ALONE decides human contact...
|
|
8
|
+
-- The escalation channel is exempt from every gate (the deep-research-launch-
|
|
9
|
+
-- guard self-deadlock lesson)." Also contract §2.3 / R5: deadline lapse with
|
|
10
|
+
-- neither claim nor decline escalates to the assigner. Requires 001_core.sql
|
|
11
|
+
-- and 004_delegation.sql.
|
|
12
|
+
--
|
|
13
|
+
-- Re-apply: idempotent (CREATE ... IF NOT EXISTS / OR REPLACE).
|
|
14
|
+
-- Revert: DROP SCHEMA cell CASCADE; (this file installs nothing outside it)
|
|
15
|
+
--
|
|
16
|
+
-- WHY THIS LANE IS DELIBERATELY UNGUARDED
|
|
17
|
+
--
|
|
18
|
+
-- Every other verb in this substrate refuses something. This one refuses only
|
|
19
|
+
-- what it cannot RESOLVE — an unknown principal, a cycle, a chain with nobody
|
|
20
|
+
-- above it. It performs no grant check, reads no claim state, and consults no
|
|
21
|
+
-- tombstone, because the measured lesson is a guard that blocked the request
|
|
22
|
+
-- for help and thereby turned one stuck agent into a system that could not say
|
|
23
|
+
-- it was stuck. A gate on this lane is a self-deadlock by construction.
|
|
24
|
+
--
|
|
25
|
+
-- WHY AN ESCALATION IS NEVER SETTLEMENT-BEARING
|
|
26
|
+
--
|
|
27
|
+
-- "I need input" is a fact about an agent, never a fact about whether work is
|
|
28
|
+
-- done. If any settlement writer consumed these rows, escalation would become a
|
|
29
|
+
-- second authority over the work lifecycle (L1). Nothing here writes a
|
|
30
|
+
-- settlement fact, nothing keys a row to an escalation, and no trigger turns an
|
|
31
|
+
-- escalation into a consequence — asserted against the live catalog by
|
|
32
|
+
-- tests/test_escalation.py rather than promised in this comment.
|
|
33
|
+
--
|
|
34
|
+
-- Declared failure vocabulary added by this file (SQLSTATE class FC; this lane
|
|
35
|
+
-- reserves FC020-FC039):
|
|
36
|
+
-- FC021 UNKNOWN_TASK an escalation ABOUT work that does not
|
|
37
|
+
-- exist (re-raised; owned by 004)
|
|
38
|
+
-- FC024 ESCALATION_UNKNOWN_PRINCIPAL a seat the org chart does not have
|
|
39
|
+
-- FC025 ESCALATION_CHAIN_CYCLE a chain that returns to a seat it visited
|
|
40
|
+
-- FC026 ESCALATION_CHAIN_UNTERMINATED a chain with no seat above it
|
|
41
|
+
|
|
42
|
+
-- ---------------------------------------------------------------------------
|
|
43
|
+
-- escalation — the typed event
|
|
44
|
+
-- ---------------------------------------------------------------------------
|
|
45
|
+
CREATE TABLE IF NOT EXISTS cell.escalation (
|
|
46
|
+
escalation_id uuid NOT NULL,
|
|
47
|
+
org_id text NOT NULL,
|
|
48
|
+
from_principal text NOT NULL,
|
|
49
|
+
|
|
50
|
+
-- The RESOLVED first seat on the chain. Stored rather than recomputed on
|
|
51
|
+
-- read: the org chart changes, and an escalation must still say who it was
|
|
52
|
+
-- addressed to at the moment it was raised (L12 — durable judgment does not
|
|
53
|
+
-- decay).
|
|
54
|
+
to_principal text NOT NULL,
|
|
55
|
+
|
|
56
|
+
-- HOW that seat was resolved: the dispatcher who handed out the work, or
|
|
57
|
+
-- the organizational parent when nobody did. Kept instead of storing
|
|
58
|
+
-- `dispatched_by` so the column is NOT NULL and still says which rule ran.
|
|
59
|
+
chain_basis text NOT NULL,
|
|
60
|
+
|
|
61
|
+
reason text NOT NULL,
|
|
62
|
+
task_id text NOT NULL,
|
|
63
|
+
|
|
64
|
+
-- NULL EXACTLY for a lapsed assignment. Every other reason arises INSIDE an
|
|
65
|
+
-- interval of responsibility, so the claim is the anchor an operator needs
|
|
66
|
+
-- to find the work; a lapse is the one escalation raised precisely because
|
|
67
|
+
-- nobody took responsibility at all. The CHECK below is what keeps that the
|
|
68
|
+
-- only lawful absence.
|
|
69
|
+
work_claim_id uuid,
|
|
70
|
+
|
|
71
|
+
created_at timestamptz NOT NULL,
|
|
72
|
+
|
|
73
|
+
CONSTRAINT escalation_pkey PRIMARY KEY (escalation_id),
|
|
74
|
+
|
|
75
|
+
CONSTRAINT escalation_from_principal_fkey
|
|
76
|
+
FOREIGN KEY (org_id, from_principal)
|
|
77
|
+
REFERENCES cell.principal (org_id, principal_id),
|
|
78
|
+
|
|
79
|
+
CONSTRAINT escalation_to_principal_fkey
|
|
80
|
+
FOREIGN KEY (org_id, to_principal)
|
|
81
|
+
REFERENCES cell.principal (org_id, principal_id),
|
|
82
|
+
|
|
83
|
+
CONSTRAINT escalation_task_fkey
|
|
84
|
+
FOREIGN KEY (org_id, task_id) REFERENCES cell.task (org_id, task_id),
|
|
85
|
+
|
|
86
|
+
CONSTRAINT escalation_work_claim_fkey
|
|
87
|
+
FOREIGN KEY (org_id, work_claim_id)
|
|
88
|
+
REFERENCES cell.work_claim (org_id, work_claim_id),
|
|
89
|
+
|
|
90
|
+
CONSTRAINT escalation_reason_is_a_declared_meaning
|
|
91
|
+
CHECK (reason IN ('input_needed', 'assignment_deadline_lapsed',
|
|
92
|
+
'max_attempts_exhausted', 'external_wait_unresolved')),
|
|
93
|
+
|
|
94
|
+
CONSTRAINT escalation_chain_basis_is_a_declared_rule
|
|
95
|
+
CHECK (chain_basis IN ('dispatcher', 'organizational_parent')),
|
|
96
|
+
|
|
97
|
+
CONSTRAINT escalation_without_a_claim_is_the_lapse_case
|
|
98
|
+
CHECK (work_claim_id IS NOT NULL OR reason = 'assignment_deadline_lapsed'),
|
|
99
|
+
|
|
100
|
+
-- An escalation addressed to its own author is a request for help that
|
|
101
|
+
-- arrives nowhere, and is indistinguishable from one that was handled.
|
|
102
|
+
CONSTRAINT escalation_never_addresses_its_own_author
|
|
103
|
+
CHECK (to_principal <> from_principal)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
CREATE INDEX IF NOT EXISTS escalation_by_addressee
|
|
107
|
+
ON cell.escalation (org_id, to_principal, created_at);
|
|
108
|
+
|
|
109
|
+
COMMENT ON TABLE cell.escalation IS
|
|
110
|
+
'FOUNDER RULING R6. The typed act that replaces input-blocking. Addressed '
|
|
111
|
+
'to the assigner chain, cascading to the CEO principal who alone decides '
|
|
112
|
+
'human contact. NEVER settlement-bearing: no settlement writer consumes '
|
|
113
|
+
'these rows, and nothing keys a row to one.';
|
|
114
|
+
|
|
115
|
+
-- ------------------------------------------------------- the chain resolution
|
|
116
|
+
--
|
|
117
|
+
-- `dispatched_by` first when there is one — a cross-scope delegation's assigner
|
|
118
|
+
-- is NOT the assignee's organizational parent, and a chain walked from the
|
|
119
|
+
-- parent alone would route the request for help past the one seat that knows
|
|
120
|
+
-- why the work exists. Then the organizational parent chain, to the CEO.
|
|
121
|
+
--
|
|
122
|
+
-- The cycle guard is an exact one (the set of seats already visited), not a
|
|
123
|
+
-- depth cap: a depth cap is a number somebody has to justify, and it answers
|
|
124
|
+
-- "how long may a chain be" when the question is "did this chain come back".
|
|
125
|
+
CREATE OR REPLACE FUNCTION cell.escalation_chain(
|
|
126
|
+
p_org_id text,
|
|
127
|
+
p_from_principal text,
|
|
128
|
+
p_dispatched_by text
|
|
129
|
+
)
|
|
130
|
+
RETURNS TABLE (
|
|
131
|
+
chain_depth int,
|
|
132
|
+
chain_principal text,
|
|
133
|
+
chain_role text,
|
|
134
|
+
chain_basis text
|
|
135
|
+
)
|
|
136
|
+
LANGUAGE plpgsql
|
|
137
|
+
AS $chain$
|
|
138
|
+
DECLARE
|
|
139
|
+
v_cursor text;
|
|
140
|
+
v_role text;
|
|
141
|
+
v_assigner text;
|
|
142
|
+
v_depth int := 0;
|
|
143
|
+
v_basis text;
|
|
144
|
+
v_seen text[] := ARRAY[]::text[];
|
|
145
|
+
BEGIN
|
|
146
|
+
-- The escalating principal must exist even when a dispatcher is named: an
|
|
147
|
+
-- escalation from a seat the org does not have is a record nobody can act
|
|
148
|
+
-- on, and it would still write a row.
|
|
149
|
+
PERFORM 1 FROM cell.principal p
|
|
150
|
+
WHERE p.org_id = p_org_id AND p.principal_id = p_from_principal;
|
|
151
|
+
IF NOT FOUND THEN
|
|
152
|
+
RAISE EXCEPTION
|
|
153
|
+
'ESCALATION_UNKNOWN_PRINCIPAL:%/% — the escalating seat is not in '
|
|
154
|
+
'this org''s chart, so no chain can be walked from it.',
|
|
155
|
+
p_org_id, p_from_principal
|
|
156
|
+
USING ERRCODE = 'FC024';
|
|
157
|
+
END IF;
|
|
158
|
+
|
|
159
|
+
IF p_dispatched_by IS NOT NULL THEN
|
|
160
|
+
v_cursor := p_dispatched_by;
|
|
161
|
+
v_basis := 'dispatcher';
|
|
162
|
+
ELSE
|
|
163
|
+
SELECT p.assigner_principal_id INTO v_cursor
|
|
164
|
+
FROM cell.principal p
|
|
165
|
+
WHERE p.org_id = p_org_id AND p.principal_id = p_from_principal;
|
|
166
|
+
v_basis := 'organizational_parent';
|
|
167
|
+
|
|
168
|
+
IF v_cursor IS NULL THEN
|
|
169
|
+
RAISE EXCEPTION
|
|
170
|
+
'ESCALATION_CHAIN_UNTERMINATED:%/% — this seat has nobody above '
|
|
171
|
+
'it and no dispatcher was named. The cascade ends AT the CEO '
|
|
172
|
+
'principal, who alone decides human contact; there is no seat to '
|
|
173
|
+
'address above them. Returning an empty chain would read as '
|
|
174
|
+
'''escalated to nobody, fine''.',
|
|
175
|
+
p_org_id, p_from_principal
|
|
176
|
+
USING ERRCODE = 'FC026';
|
|
177
|
+
END IF;
|
|
178
|
+
END IF;
|
|
179
|
+
|
|
180
|
+
LOOP
|
|
181
|
+
IF v_cursor = ANY (v_seen) THEN
|
|
182
|
+
RAISE EXCEPTION
|
|
183
|
+
'ESCALATION_CHAIN_CYCLE:%/%:% — the chain returns to a seat it '
|
|
184
|
+
'already visited (%). A walk that cannot tell a cycle from '
|
|
185
|
+
'progress is an escalation that never arrives and never fails '
|
|
186
|
+
'either.',
|
|
187
|
+
p_org_id, p_from_principal, v_cursor, array_to_string(v_seen, ' -> ')
|
|
188
|
+
USING ERRCODE = 'FC025';
|
|
189
|
+
END IF;
|
|
190
|
+
v_seen := v_seen || v_cursor;
|
|
191
|
+
|
|
192
|
+
SELECT p.role, p.assigner_principal_id INTO v_role, v_assigner
|
|
193
|
+
FROM cell.principal p
|
|
194
|
+
WHERE p.org_id = p_org_id AND p.principal_id = v_cursor;
|
|
195
|
+
|
|
196
|
+
IF NOT FOUND THEN
|
|
197
|
+
RAISE EXCEPTION
|
|
198
|
+
'ESCALATION_UNKNOWN_PRINCIPAL:%/% — the chain names a seat this '
|
|
199
|
+
'org does not have, so the request for help has no addressee.',
|
|
200
|
+
p_org_id, v_cursor
|
|
201
|
+
USING ERRCODE = 'FC024';
|
|
202
|
+
END IF;
|
|
203
|
+
|
|
204
|
+
v_depth := v_depth + 1;
|
|
205
|
+
chain_depth := v_depth;
|
|
206
|
+
chain_principal := v_cursor;
|
|
207
|
+
chain_role := v_role;
|
|
208
|
+
chain_basis := CASE WHEN v_depth = 1 THEN v_basis
|
|
209
|
+
ELSE 'organizational_parent' END;
|
|
210
|
+
RETURN NEXT;
|
|
211
|
+
|
|
212
|
+
EXIT WHEN v_role = 'ceo';
|
|
213
|
+
|
|
214
|
+
v_cursor := v_assigner;
|
|
215
|
+
IF v_cursor IS NULL THEN
|
|
216
|
+
-- Unreachable while principal_only_the_ceo_answers_to_nobody holds;
|
|
217
|
+
-- kept loud rather than assumed, because the day that CHECK is
|
|
218
|
+
-- relaxed this is the leg that tells us instead of a chain that
|
|
219
|
+
-- silently stops one seat short.
|
|
220
|
+
RAISE EXCEPTION
|
|
221
|
+
'ESCALATION_CHAIN_UNTERMINATED:%/% — the chain ran out below the '
|
|
222
|
+
'CEO principal.',
|
|
223
|
+
p_org_id, p_from_principal
|
|
224
|
+
USING ERRCODE = 'FC026';
|
|
225
|
+
END IF;
|
|
226
|
+
END LOOP;
|
|
227
|
+
|
|
228
|
+
RETURN;
|
|
229
|
+
END;
|
|
230
|
+
$chain$;
|
|
231
|
+
|
|
232
|
+
COMMENT ON FUNCTION cell.escalation_chain IS
|
|
233
|
+
'assigner -> parent chain -> CEO principal (FOUNDER RULING R6). Refuses an '
|
|
234
|
+
'unknown seat, a cycle, and a chain with nobody above it; never returns an '
|
|
235
|
+
'empty chain, which a caller would read as ''escalated to nobody''.';
|
|
236
|
+
|
|
237
|
+
-- ------------------------------------------------------------- the escalate verb
|
|
238
|
+
--
|
|
239
|
+
-- Every argument required, none defaulted — `dispatched_by` and `work_claim_id`
|
|
240
|
+
-- are genuinely absent in real cases and the caller says which case it is.
|
|
241
|
+
-- No grant check, no claim-state check, no tombstone check: see the header.
|
|
242
|
+
CREATE OR REPLACE FUNCTION cell.escalate(
|
|
243
|
+
p_org_id text,
|
|
244
|
+
p_escalation_id uuid,
|
|
245
|
+
p_from_principal text,
|
|
246
|
+
p_dispatched_by text,
|
|
247
|
+
p_reason text,
|
|
248
|
+
p_task_id text,
|
|
249
|
+
p_work_claim_id uuid,
|
|
250
|
+
p_created_at timestamptz,
|
|
251
|
+
p_audit_event_id uuid
|
|
252
|
+
)
|
|
253
|
+
RETURNS text
|
|
254
|
+
LANGUAGE plpgsql
|
|
255
|
+
AS $escalate$
|
|
256
|
+
DECLARE
|
|
257
|
+
v_to_principal text;
|
|
258
|
+
v_basis text;
|
|
259
|
+
v_task_department text;
|
|
260
|
+
BEGIN
|
|
261
|
+
SELECT c.chain_principal, c.chain_basis INTO v_to_principal, v_basis
|
|
262
|
+
FROM cell.escalation_chain(p_org_id, p_from_principal, p_dispatched_by) c
|
|
263
|
+
WHERE c.chain_depth = 1;
|
|
264
|
+
|
|
265
|
+
SELECT t.department INTO v_task_department
|
|
266
|
+
FROM cell.task t
|
|
267
|
+
WHERE t.org_id = p_org_id AND t.task_id = p_task_id;
|
|
268
|
+
|
|
269
|
+
IF NOT FOUND THEN
|
|
270
|
+
RAISE EXCEPTION
|
|
271
|
+
'UNKNOWN_TASK:%/% — an escalation is raised ABOUT work, and no work '
|
|
272
|
+
'by that identity exists in this org.',
|
|
273
|
+
p_org_id, p_task_id
|
|
274
|
+
USING ERRCODE = 'FC021';
|
|
275
|
+
END IF;
|
|
276
|
+
|
|
277
|
+
INSERT INTO cell.escalation (
|
|
278
|
+
escalation_id, org_id, from_principal, to_principal, chain_basis,
|
|
279
|
+
reason, task_id, work_claim_id, created_at
|
|
280
|
+
) VALUES (
|
|
281
|
+
p_escalation_id, p_org_id, p_from_principal, v_to_principal, v_basis,
|
|
282
|
+
p_reason, p_task_id, p_work_claim_id, p_created_at
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
-- Audited under the department of the WORK, by the same generated-topic
|
|
286
|
+
-- rule as every other event in this lane (004_delegation.sql).
|
|
287
|
+
INSERT INTO cell.audit_event (
|
|
288
|
+
audit_event_id, org_id, department, kind, task_id, actor_principal,
|
|
289
|
+
ts, producer
|
|
290
|
+
) VALUES (
|
|
291
|
+
p_audit_event_id, p_org_id, v_task_department, 'escalated', p_task_id,
|
|
292
|
+
p_from_principal, p_created_at, 'cell.escalate'
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
RETURN v_to_principal;
|
|
296
|
+
END;
|
|
297
|
+
$escalate$;
|
|
298
|
+
|
|
299
|
+
COMMENT ON FUNCTION cell.escalate IS
|
|
300
|
+
'FOUNDER RULING R6: needing input is a typed act, not a modal block. '
|
|
301
|
+
'Addresses the first seat on the assigner chain and records the event. '
|
|
302
|
+
'EXEMPT FROM EVERY GATE by design — a guard on this verb is a self-deadlock, '
|
|
303
|
+
'and this verb writes no settlement fact.';
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
-- 006_dependency.sql — dependency edges: acceptance-only release, compound AND,
|
|
2
|
+
-- and cross-scope resolution keyed on the GATING task's identity.
|
|
3
|
+
--
|
|
4
|
+
-- Contract: docs/a1-cell-work-spine-contract.md §3.1 (no auto-void), §3.2 (the
|
|
5
|
+
-- moot-wait settle and its discriminator), §3.3 (the release bar — FOUNDER
|
|
6
|
+
-- RULING R4, acceptance-ONLY, no selector), §3.4(1) (the widened
|
|
7
|
+
-- completed-but-unsettled arm), §4.1 (the edge lifecycle vocabulary), §4.4
|
|
8
|
+
-- (evidence-required retraction), §4.7 (dep_key validity rules).
|
|
9
|
+
-- Requires 001_core.sql and 003_verification.sql (the completion tri-state).
|
|
10
|
+
--
|
|
11
|
+
-- Re-apply: idempotent (CREATE ... IF NOT EXISTS / OR REPLACE).
|
|
12
|
+
-- Revert: DROP SCHEMA cell CASCADE; (this file installs nothing outside it)
|
|
13
|
+
--
|
|
14
|
+
-- THE THREE MEASURED DEFECTS THIS FILE IS SHAPED BY
|
|
15
|
+
--
|
|
16
|
+
-- 1. The task-dep released on a SELF-ASSERTION. On the Mac a `task` edge
|
|
17
|
+
-- released on `queue_task_state.closed`, which derives from the upstream
|
|
18
|
+
-- author's own completion claim — "statements are not truth" living inside
|
|
19
|
+
-- the dependency system. R4 rules the bar to be the upstream task's recorded
|
|
20
|
+
-- VERIFICATION (completion tri-state `complete`), and rejects the proposed
|
|
21
|
+
-- per-edge opt-down selector as unnecessary flexibility: low-stakes hand-offs
|
|
22
|
+
-- use A2A messaging, and §1.4's mandatory verify_by bounds verification
|
|
23
|
+
-- latency. There is therefore NO selector column below, and none may be
|
|
24
|
+
-- added without a ruling — a column nobody may set is a column that gets set.
|
|
25
|
+
--
|
|
26
|
+
-- 2. The DEPARTMENT-SCOPED resolver: a cross-department gate could never
|
|
27
|
+
-- resolve. Every join below is keyed on (org_id, gating_task_id) and on
|
|
28
|
+
-- nothing else. Department is not an isolation boundary in the cell; ORG is
|
|
29
|
+
-- (PRD:1626, L17), and that difference is expressed as a composite foreign
|
|
30
|
+
-- key rather than as a convention.
|
|
31
|
+
--
|
|
32
|
+
-- 3. Completion AUTO-VOID (`realCompleteTask`, lifecycle.ts:1037-1091). It is
|
|
33
|
+
-- not ported — not with an allowlist, not with a carve-out. There is no
|
|
34
|
+
-- `voided` state for it to leave behind, an edge cannot be DELETEd, and the
|
|
35
|
+
-- only mootness settle is the tautologically-moot pair carrying an explicit
|
|
36
|
+
-- `moot_completion` discriminator (§3.2, §3.4(5)).
|
|
37
|
+
--
|
|
38
|
+
-- Declared failure vocabulary added by this file (SQLSTATE class FC; this lane
|
|
39
|
+
-- reserves FC070-FC079 — it previously trespassed on the delegation lane's
|
|
40
|
+
-- FC020-FC039 block, which made three codes mean two things each):
|
|
41
|
+
-- FC070 DEP_RELEASED_WITHOUT_ACCEPTANCE a task-lane edge released while the
|
|
42
|
+
-- gating task is not `complete`
|
|
43
|
+
-- FC071 ACCEPTANCE_PACKAGE_NOT_VERIFIED an acceptance edge released with no
|
|
44
|
+
-- verified acceptance-package verdict
|
|
45
|
+
-- FC072 DEP_EDGE_DELETED an edge removed rather than settled
|
|
46
|
+
-- or retracted with evidence
|
|
47
|
+
|
|
48
|
+
-- ---------------------------------------------------------------------------
|
|
49
|
+
-- dep_edge — one wait, of one typed family, held by one waiting task
|
|
50
|
+
-- ---------------------------------------------------------------------------
|
|
51
|
+
CREATE TABLE IF NOT EXISTS cell.dep_edge (
|
|
52
|
+
edge_id uuid NOT NULL,
|
|
53
|
+
org_id text NOT NULL,
|
|
54
|
+
|
|
55
|
+
-- the WAITING task: the one that does not proceed until this edge settles
|
|
56
|
+
task_id text NOT NULL,
|
|
57
|
+
|
|
58
|
+
dep_type text NOT NULL,
|
|
59
|
+
dep_key text NOT NULL,
|
|
60
|
+
|
|
61
|
+
-- The gating task's IDENTITY — the whole of the cross-scope resolution key.
|
|
62
|
+
-- NOT NULL exactly for the two task-lane families, where §4.7 says the
|
|
63
|
+
-- dep_key IS a task id; NULL for the five families that resolve against
|
|
64
|
+
-- something outside the task table.
|
|
65
|
+
gating_task_id text,
|
|
66
|
+
|
|
67
|
+
-- contract §4.1's state machine, shared by every family:
|
|
68
|
+
-- declared ──(registered key)──→ evaluable ──(signed pass)──→ satisfied
|
|
69
|
+
-- └──(acknowledgment)──→ debt_acked └──→ evaluation_blocked
|
|
70
|
+
-- └──(evidence)──→ retracted
|
|
71
|
+
-- `voided` is DELIBERATELY absent (§3.1).
|
|
72
|
+
state text NOT NULL,
|
|
73
|
+
|
|
74
|
+
declared_by text NOT NULL,
|
|
75
|
+
declared_at timestamptz NOT NULL,
|
|
76
|
+
|
|
77
|
+
-- The signer, the kind, and the stamp — all three NOT NULL exactly when the
|
|
78
|
+
-- edge is satisfied. "Who released this, on what basis, when" is the
|
|
79
|
+
-- question the Mac's void events could not answer, which is why they had
|
|
80
|
+
-- zero readers estate-wide.
|
|
81
|
+
settled_by text,
|
|
82
|
+
settle_kind text,
|
|
83
|
+
settled_at timestamptz,
|
|
84
|
+
|
|
85
|
+
-- §4.4: retracting requires evidence_refs and mints NO verification record.
|
|
86
|
+
-- Retraction is not release.
|
|
87
|
+
retraction_evidence_refs jsonb,
|
|
88
|
+
retracted_at timestamptz,
|
|
89
|
+
|
|
90
|
+
-- L8: an acknowledged registration debt names its OWNER and its DUE date, or
|
|
91
|
+
-- it is not an acknowledgment, it is a shrug. NOT NULL exactly while the edge
|
|
92
|
+
-- sits in debt_acked; the durable record of the debt is the typed event, so
|
|
93
|
+
-- discharging the debt clears these columns without erasing the history.
|
|
94
|
+
debt_owner text,
|
|
95
|
+
debt_due timestamptz,
|
|
96
|
+
|
|
97
|
+
CONSTRAINT dep_edge_pkey PRIMARY KEY (edge_id),
|
|
98
|
+
|
|
99
|
+
CONSTRAINT dep_edge_waiting_task_fkey
|
|
100
|
+
FOREIGN KEY (org_id, task_id) REFERENCES cell.task (org_id, task_id),
|
|
101
|
+
|
|
102
|
+
-- Cross-scope, not cross-org: the gating task may live in any department and
|
|
103
|
+
-- must live in this org.
|
|
104
|
+
CONSTRAINT dep_edge_gating_task_fkey
|
|
105
|
+
FOREIGN KEY (org_id, gating_task_id) REFERENCES cell.task (org_id, task_id),
|
|
106
|
+
|
|
107
|
+
CONSTRAINT dep_edge_dep_type_is_a_declared_family
|
|
108
|
+
CHECK (dep_type IN ('task', 'verified', 'acceptance_package',
|
|
109
|
+
'operator_approval', 'capacity_free', 'time_elapse',
|
|
110
|
+
'external_event')),
|
|
111
|
+
|
|
112
|
+
CONSTRAINT dep_edge_dep_state_is_a_declared_lifecycle_state
|
|
113
|
+
CHECK (state IN ('declared', 'debt_acked', 'evaluable', 'satisfied',
|
|
114
|
+
'evaluation_blocked', 'retracted')),
|
|
115
|
+
|
|
116
|
+
-- §4.7: the task lane's dep_key IS the gating task_id, validated at declare
|
|
117
|
+
-- time. The measured instrument bug — the reconciler resolving acceptance
|
|
118
|
+
-- packages by dep_key while the operator report told humans to file them by
|
|
119
|
+
-- task_id — has no shape it can take here.
|
|
120
|
+
CONSTRAINT dep_edge_task_lane_dep_key_is_the_gating_task
|
|
121
|
+
CHECK (dep_type NOT IN ('task', 'acceptance_package')
|
|
122
|
+
OR (gating_task_id IS NOT NULL AND dep_key = gating_task_id)),
|
|
123
|
+
|
|
124
|
+
CONSTRAINT dep_edge_outside_the_task_lane_names_no_gating_task
|
|
125
|
+
CHECK (dep_type IN ('task', 'acceptance_package') OR gating_task_id IS NULL),
|
|
126
|
+
|
|
127
|
+
CONSTRAINT dep_edge_edge_does_not_gate_itself
|
|
128
|
+
CHECK (gating_task_id IS DISTINCT FROM task_id),
|
|
129
|
+
|
|
130
|
+
CONSTRAINT dep_edge_satisfied_edge_carries_its_signer_kind_and_stamp
|
|
131
|
+
CHECK ((state = 'satisfied')
|
|
132
|
+
= (settled_by IS NOT NULL AND settle_kind IS NOT NULL
|
|
133
|
+
AND settled_at IS NOT NULL)),
|
|
134
|
+
|
|
135
|
+
CONSTRAINT dep_edge_settle_kind_is_a_declared_kind
|
|
136
|
+
CHECK (settle_kind IS NULL
|
|
137
|
+
OR settle_kind IN ('evaluator_verdict', 'moot_completion')),
|
|
138
|
+
|
|
139
|
+
-- §3.2: `capacity_free` is the only tautologically-moot class (6/6 measured),
|
|
140
|
+
-- with `time_elapse` its clock-shaped sibling. Every other family renders as
|
|
141
|
+
-- a loud completed-but-unsettled state and settles by its own evaluator.
|
|
142
|
+
CONSTRAINT dep_edge_moot_settle_is_only_for_a_tautologically_moot_family
|
|
143
|
+
CHECK (settle_kind IS DISTINCT FROM 'moot_completion'
|
|
144
|
+
OR dep_type IN ('capacity_free', 'time_elapse')),
|
|
145
|
+
|
|
146
|
+
-- The IS NOT NULL is load-bearing: without it a retraction carrying no
|
|
147
|
+
-- evidence key at all yields NULL through the jsonb operators and a CHECK
|
|
148
|
+
-- passes on NULL — the unevidenced retraction this constraint exists to
|
|
149
|
+
-- refuse would sail through (the 001_core.sql lesson, restated).
|
|
150
|
+
CONSTRAINT dep_edge_retracted_edge_carries_addressable_evidence
|
|
151
|
+
CHECK (state <> 'retracted'
|
|
152
|
+
OR (retracted_at IS NOT NULL
|
|
153
|
+
AND retraction_evidence_refs IS NOT NULL
|
|
154
|
+
AND jsonb_typeof(retraction_evidence_refs) = 'array'
|
|
155
|
+
AND jsonb_array_length(retraction_evidence_refs) > 0)),
|
|
156
|
+
|
|
157
|
+
CONSTRAINT dep_edge_only_a_retracted_edge_carries_a_retraction
|
|
158
|
+
CHECK (state = 'retracted'
|
|
159
|
+
OR (retracted_at IS NULL AND retraction_evidence_refs IS NULL)),
|
|
160
|
+
|
|
161
|
+
CONSTRAINT dep_edge_acknowledged_debt_names_its_owner_and_due
|
|
162
|
+
CHECK ((state = 'debt_acked')
|
|
163
|
+
= (debt_owner IS NOT NULL AND debt_due IS NOT NULL))
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
COMMENT ON TABLE cell.dep_edge IS
|
|
167
|
+
'Contract §3.3 as ruled by R4: a task-type edge releases on the upstream '
|
|
168
|
+
'task''s recorded VERIFICATION, period. There is no selector column and none '
|
|
169
|
+
'may be added without a founder ruling.';
|
|
170
|
+
|
|
171
|
+
CREATE INDEX IF NOT EXISTS dep_edge_by_waiting_task
|
|
172
|
+
ON cell.dep_edge (org_id, task_id, state);
|
|
173
|
+
|
|
174
|
+
CREATE INDEX IF NOT EXISTS dep_edge_by_gating_task
|
|
175
|
+
ON cell.dep_edge (org_id, gating_task_id)
|
|
176
|
+
WHERE gating_task_id IS NOT NULL;
|
|
177
|
+
|
|
178
|
+
-- ------------------------------------------ the acceptance bar, as enforcement
|
|
179
|
+
--
|
|
180
|
+
-- The view below says whether an edge MAY be released. This trigger is why that
|
|
181
|
+
-- answer cannot be ignored. A release bar that lives only in a projection is a
|
|
182
|
+
-- bar with a bypass, and the Mac's 23 direct-publish `verified` settles are the
|
|
183
|
+
-- measured price of exactly that shape.
|
|
184
|
+
CREATE OR REPLACE FUNCTION cell.enforce_acceptance_only_release()
|
|
185
|
+
RETURNS trigger
|
|
186
|
+
LANGUAGE plpgsql
|
|
187
|
+
AS $acceptance_only$
|
|
188
|
+
DECLARE
|
|
189
|
+
v_completion text;
|
|
190
|
+
BEGIN
|
|
191
|
+
-- Only a TRANSITION into satisfied is checked. Re-stating an already-settled
|
|
192
|
+
-- edge is idempotent, and re-checking it would make a legitimate correction
|
|
193
|
+
-- elsewhere on the row fail for a reason that has nothing to do with it.
|
|
194
|
+
IF NEW.state IS DISTINCT FROM 'satisfied' THEN
|
|
195
|
+
RETURN NEW;
|
|
196
|
+
END IF;
|
|
197
|
+
IF TG_OP = 'UPDATE' AND OLD.state = 'satisfied' THEN
|
|
198
|
+
RETURN NEW;
|
|
199
|
+
END IF;
|
|
200
|
+
|
|
201
|
+
IF NEW.dep_type = 'task' THEN
|
|
202
|
+
SELECT completion INTO v_completion
|
|
203
|
+
FROM cell.v_task_completion
|
|
204
|
+
WHERE org_id = NEW.org_id AND task_id = NEW.gating_task_id;
|
|
205
|
+
|
|
206
|
+
IF v_completion IS DISTINCT FROM 'complete' THEN
|
|
207
|
+
RAISE EXCEPTION
|
|
208
|
+
'DEP_RELEASED_WITHOUT_ACCEPTANCE:%/% — the gating task projects '
|
|
209
|
+
'''%'', not ''complete''. FOUNDER RULING R4: a task-type dependency '
|
|
210
|
+
'releases on the upstream task''s recorded VERIFICATION and on '
|
|
211
|
+
'nothing else. Releasing on the upstream author''s own completion '
|
|
212
|
+
'assertion is "statements are not truth" inside the dependency '
|
|
213
|
+
'system itself, which is what the Mac did.',
|
|
214
|
+
NEW.org_id, NEW.gating_task_id,
|
|
215
|
+
coalesce(v_completion, '<no such task>')
|
|
216
|
+
USING ERRCODE = 'FC070';
|
|
217
|
+
END IF;
|
|
218
|
+
|
|
219
|
+
ELSIF NEW.dep_type = 'acceptance_package' THEN
|
|
220
|
+
IF NOT EXISTS (
|
|
221
|
+
SELECT 1 FROM cell.verification v
|
|
222
|
+
WHERE v.org_id = NEW.org_id
|
|
223
|
+
AND v.task_id = NEW.gating_task_id
|
|
224
|
+
AND v.source = 'acceptance_package'
|
|
225
|
+
AND v.result = 'verified'
|
|
226
|
+
) THEN
|
|
227
|
+
RAISE EXCEPTION
|
|
228
|
+
'ACCEPTANCE_PACKAGE_NOT_VERIFIED:%/% — no acceptance-package '
|
|
229
|
+
'verdict with result ''verified'' is recorded against the accepted '
|
|
230
|
+
'task. A rejected or indeterminate verdict is a verification '
|
|
231
|
+
'record; it is not a release (§1.4).',
|
|
232
|
+
NEW.org_id, NEW.gating_task_id
|
|
233
|
+
USING ERRCODE = 'FC071';
|
|
234
|
+
END IF;
|
|
235
|
+
END IF;
|
|
236
|
+
|
|
237
|
+
RETURN NEW;
|
|
238
|
+
END;
|
|
239
|
+
$acceptance_only$;
|
|
240
|
+
|
|
241
|
+
CREATE OR REPLACE TRIGGER dep_edge_release_meets_the_acceptance_bar
|
|
242
|
+
BEFORE INSERT OR UPDATE ON cell.dep_edge
|
|
243
|
+
FOR EACH ROW EXECUTE FUNCTION cell.enforce_acceptance_only_release();
|
|
244
|
+
|
|
245
|
+
-- ---------------------------------------------------- no auto-void, stated once
|
|
246
|
+
--
|
|
247
|
+
-- Deleting an edge is auto-void with better manners: the wait disappears and
|
|
248
|
+
-- nothing records that it did. An edge ends by satisfaction with a signer, or by
|
|
249
|
+
-- retraction with evidence — both of which leave the row and its history behind
|
|
250
|
+
-- (L12). TRUNCATE does not fire this trigger, which is what lets the test harness
|
|
251
|
+
-- reset a scratch database without disarming the rule it is testing.
|
|
252
|
+
CREATE OR REPLACE FUNCTION cell.refuse_dep_edge_deletion()
|
|
253
|
+
RETURNS trigger
|
|
254
|
+
LANGUAGE plpgsql
|
|
255
|
+
AS $no_delete$
|
|
256
|
+
BEGIN
|
|
257
|
+
RAISE EXCEPTION
|
|
258
|
+
'DEP_EDGE_DELETED:% — a dependency edge is never removed. It is satisfied '
|
|
259
|
+
'by its evaluator (with a signer and a settle_kind) or retracted with '
|
|
260
|
+
'evidence_refs; both leave the declared history in place. Deleting it is '
|
|
261
|
+
'the completion auto-void the cell does not port — 52/52 measured voids '
|
|
262
|
+
'extinguished waits nobody could later account for, and zero consumers '
|
|
263
|
+
'ever read a void event.',
|
|
264
|
+
OLD.edge_id
|
|
265
|
+
USING ERRCODE = 'FC072';
|
|
266
|
+
END;
|
|
267
|
+
$no_delete$;
|
|
268
|
+
|
|
269
|
+
CREATE OR REPLACE TRIGGER dep_edge_is_never_deleted
|
|
270
|
+
BEFORE DELETE ON cell.dep_edge
|
|
271
|
+
FOR EACH ROW EXECUTE FUNCTION cell.refuse_dep_edge_deletion();
|
|
272
|
+
|
|
273
|
+
-- ---------------------------------------------------------------------------
|
|
274
|
+
-- v_dep_edge_release — may this edge be released, and by whom
|
|
275
|
+
--
|
|
276
|
+
-- `settles_by` is the single source of truth for release authority (§4.5's
|
|
277
|
+
-- discipline applied to the dependency lane). MEASURED motivation: "what counts
|
|
278
|
+
-- as a valid release" was encoded in SEVEN places on the Mac plus one stale copy,
|
|
279
|
+
-- and every encoding drifted.
|
|
280
|
+
--
|
|
281
|
+
-- The join is on (org_id, gating_task_id). There is no department predicate here
|
|
282
|
+
-- and there must never be one: that predicate IS the measured dept-scoped
|
|
283
|
+
-- resolver defect, and the dependency test suite is written cross-department by
|
|
284
|
+
-- default so reintroducing it turns the whole suite red.
|
|
285
|
+
-- ---------------------------------------------------------------------------
|
|
286
|
+
CREATE OR REPLACE VIEW cell.v_dep_edge_release AS
|
|
287
|
+
SELECT
|
|
288
|
+
e.edge_id,
|
|
289
|
+
e.org_id,
|
|
290
|
+
e.task_id,
|
|
291
|
+
e.dep_type,
|
|
292
|
+
e.dep_key,
|
|
293
|
+
e.gating_task_id,
|
|
294
|
+
e.state,
|
|
295
|
+
g.completion AS gating_completion,
|
|
296
|
+
CASE e.dep_type
|
|
297
|
+
WHEN 'task' THEN 'evaluator_lane'
|
|
298
|
+
WHEN 'acceptance_package' THEN 'acceptance_seat'
|
|
299
|
+
WHEN 'verified' THEN 'registered_checker'
|
|
300
|
+
WHEN 'operator_approval' THEN 'operator_confirm'
|
|
301
|
+
WHEN 'capacity_free' THEN 'reconciler_mootness'
|
|
302
|
+
WHEN 'time_elapse' THEN 'reconciler_mootness'
|
|
303
|
+
WHEN 'external_event' THEN 'external_event_evaluator'
|
|
304
|
+
END AS settles_by,
|
|
305
|
+
CASE
|
|
306
|
+
-- R4's bar, computed: the upstream task's tri-state, nothing weaker.
|
|
307
|
+
WHEN e.dep_type = 'task'
|
|
308
|
+
THEN coalesce(g.completion, '') = 'complete'
|
|
309
|
+
WHEN e.dep_type = 'acceptance_package'
|
|
310
|
+
THEN EXISTS (SELECT 1 FROM cell.verification v
|
|
311
|
+
WHERE v.org_id = e.org_id
|
|
312
|
+
AND v.task_id = e.gating_task_id
|
|
313
|
+
AND v.source = 'acceptance_package'
|
|
314
|
+
AND v.result = 'verified')
|
|
315
|
+
-- The remaining five families release on an observation this substrate
|
|
316
|
+
-- does not hold: an evaluator's signature, an operator's consume, a
|
|
317
|
+
-- clock, free capacity, an external event. Reporting `false` is the
|
|
318
|
+
-- honest answer to "may it be released from what is recorded here" —
|
|
319
|
+
-- `settles_by` names who does hold that observation.
|
|
320
|
+
ELSE false
|
|
321
|
+
END AS releasable
|
|
322
|
+
FROM cell.dep_edge e
|
|
323
|
+
LEFT JOIN cell.v_task_completion g
|
|
324
|
+
ON g.org_id = e.org_id AND g.task_id = e.gating_task_id;
|
|
325
|
+
|
|
326
|
+
-- ---------------------------------------------------------------------------
|
|
327
|
+
-- v_task_open_deps — the compound AND, and the widened board arm
|
|
328
|
+
--
|
|
329
|
+
-- Compound AND (case 5): a task proceeds when EVERY edge is satisfied. Arrival
|
|
330
|
+
-- order is immaterial because this is a count over recorded state, not a
|
|
331
|
+
-- sequence of transitions — which is also why a duplicate satisfy releases once.
|
|
332
|
+
--
|
|
333
|
+
-- A RETRACTED edge is neither open nor satisfied: it does not hold the task up,
|
|
334
|
+
-- and it does not release it either. It makes the task's settlement status
|
|
335
|
+
-- `predicate_retracted`, carrying the retraction as its evidence (§1.6) — 17
|
|
336
|
+
-- historical tasks project exactly this.
|
|
337
|
+
--
|
|
338
|
+
-- `board_state` is contract §3.4(1), the widened completed-but-unsettled arm:
|
|
339
|
+
-- `done_awaiting_deps` renders for EVERY loud edge family, not only for
|
|
340
|
+
-- operator-approval edges. Without that, a completed task holding a `verified`
|
|
341
|
+
-- or `external_event` edge renders `blocked` forever — the 2026-07-21
|
|
342
|
+
-- founder-surface ghost-row incident, resurrected by its own fix.
|
|
343
|
+
-- ---------------------------------------------------------------------------
|
|
344
|
+
CREATE OR REPLACE VIEW cell.v_task_open_deps AS
|
|
345
|
+
SELECT
|
|
346
|
+
c.org_id,
|
|
347
|
+
c.task_id,
|
|
348
|
+
c.department,
|
|
349
|
+
c.completion,
|
|
350
|
+
d.total_deps,
|
|
351
|
+
d.open_deps,
|
|
352
|
+
d.satisfied_deps,
|
|
353
|
+
d.retracted_deps,
|
|
354
|
+
d.open_dep_types,
|
|
355
|
+
(d.open_deps = 0 AND d.retracted_deps = 0) AS all_deps_satisfied,
|
|
356
|
+
(d.retracted_deps > 0) AS predicate_retracted,
|
|
357
|
+
CASE
|
|
358
|
+
WHEN d.retracted_deps > 0 THEN 'predicate_retracted'
|
|
359
|
+
WHEN c.completion = 'none' AND d.open_deps > 0 THEN 'blocked'
|
|
360
|
+
WHEN c.completion = 'none' THEN 'open'
|
|
361
|
+
WHEN d.open_deps > 0 THEN 'done_awaiting_deps'
|
|
362
|
+
WHEN c.completion = 'asserted_unverified' THEN 'done_awaiting_verification'
|
|
363
|
+
ELSE 'complete'
|
|
364
|
+
END AS board_state
|
|
365
|
+
FROM cell.v_task_completion c
|
|
366
|
+
CROSS JOIN LATERAL (
|
|
367
|
+
SELECT
|
|
368
|
+
count(*)::int AS total_deps,
|
|
369
|
+
count(*) FILTER (WHERE e.state NOT IN ('satisfied', 'retracted'))::int
|
|
370
|
+
AS open_deps,
|
|
371
|
+
count(*) FILTER (WHERE e.state = 'satisfied')::int AS satisfied_deps,
|
|
372
|
+
count(*) FILTER (WHERE e.state = 'retracted')::int AS retracted_deps,
|
|
373
|
+
coalesce(
|
|
374
|
+
array_agg(DISTINCT e.dep_type)
|
|
375
|
+
FILTER (WHERE e.state NOT IN ('satisfied', 'retracted')),
|
|
376
|
+
ARRAY[]::text[]) AS open_dep_types
|
|
377
|
+
FROM cell.dep_edge e
|
|
378
|
+
WHERE e.org_id = c.org_id AND e.task_id = c.task_id
|
|
379
|
+
) d;
|
|
380
|
+
|
|
381
|
+
COMMENT ON VIEW cell.v_task_open_deps IS
|
|
382
|
+
'Contract §3.4(1): done_awaiting_deps renders for EVERY loud edge family, '
|
|
383
|
+
'not only operator-approval — a completed task holding a verified edge must '
|
|
384
|
+
'never render blocked forever.';
|