create-principles-disciple 1.150.1 → 1.150.2
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/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/ingestion.d.ts +9 -7
- package/codex-adapter/dist/ingestion/ingestion.js +68 -144
- package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +35 -44
- package/codex-adapter/dist/ingestion/transcript-decoder.js +23 -84
- package/codex-adapter/dist/ingestion/transcript-source.d.ts +29 -0
- package/codex-adapter/dist/ingestion/transcript-source.js +65 -0
- package/codex-adapter/dist/pd-hook.d.ts +5 -0
- package/codex-adapter/dist/pd-hook.js +8 -1
- package/console/dist/server/routes/examiner-eligibility.d.ts +73 -0
- package/console/dist/server/routes/examiner-eligibility.js +326 -0
- package/console/dist/server/routes/examiner.js +66 -8
- package/console/dist/web/assets/app.css +40 -0
- package/console/dist/web/assets/app.js +30 -30
- package/core/dist/runtime/config/pd-config-effective.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-effective.js +5 -2
- package/core/dist/runtime/config/pd-config-effective.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +20 -0
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/host-runtime/dist/adaptive-priority-provider.d.ts +7 -0
- package/host-runtime/dist/adaptive-priority-provider.js +34 -2
- package/host-runtime/dist/adaptive-skip-decision.d.ts +61 -0
- package/host-runtime/dist/adaptive-skip-decision.js +114 -0
- package/host-runtime/dist/codex-ingestion-consent.d.ts +32 -95
- package/host-runtime/dist/codex-ingestion-consent.js +33 -205
- package/host-runtime/dist/conversation-ingestion/consent.d.ts +124 -0
- package/host-runtime/dist/conversation-ingestion/consent.js +531 -0
- package/host-runtime/dist/conversation-ingestion/index.d.ts +12 -0
- package/host-runtime/dist/conversation-ingestion/index.js +12 -0
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +101 -0
- package/host-runtime/dist/conversation-ingestion/pipeline.js +162 -0
- package/host-runtime/dist/conversation-ingestion/source.d.ts +172 -0
- package/host-runtime/dist/conversation-ingestion/source.js +111 -0
- package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +51 -0
- package/host-runtime/dist/conversation-ingestion/text-policy.js +68 -0
- package/host-runtime/dist/governance-observation-store.d.ts +9 -7
- package/host-runtime/dist/governance-observation-store.js +20 -4
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +6 -0
- package/host-runtime/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +213 -213
- package/release-manager/dist/installers/codex-host-installer.js +20 -0
- package/release-manager/package.json +1 -1
|
@@ -1,223 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex conversation-ingestion consent
|
|
3
|
-
*
|
|
2
|
+
* Codex conversation-ingestion consent — COMPAT SHIM over the host-neutral
|
|
3
|
+
* v3 ledger (PRI-1171 P1; SPEC v0.2 §8.1).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
5
|
+
* The authority moved to
|
|
6
|
+
* `<workspace>/.state/conversation-ingestion-consent.json` (host-keyed, schema
|
|
7
|
+
* v3) in `conversation-ingestion/consent.ts`. This module keeps the historical
|
|
8
|
+
* Codex-named API stable for existing consumers (pd-cli setup / health) for
|
|
9
|
+
* ONE version cycle; new code reads the seam API directly.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Scope: per-workspace (the flag and the transcripts it gates are
|
|
18
|
-
* workspace-scoped). This file is consent control state — it never contains
|
|
19
|
-
* any captured conversation text (SPEC §15 "consent state without displaying
|
|
20
|
-
* captured text").
|
|
21
|
-
*
|
|
22
|
-
* Patterns mirror the product-telemetry consent store: missing file is the
|
|
23
|
-
* normal never-asked case; a malformed file fails loud (rc-3/rc-9) because
|
|
24
|
-
* silently treating it as "never asked" could re-prompt against a recorded
|
|
25
|
-
* Owner decision; writes are atomic (temp + rename); unknown/malformed
|
|
26
|
-
* fields are rejected via guards, never `as` (rc-1/rc-2/rc-5).
|
|
11
|
+
* Behavior notes vs the pre-PRI-1171 store:
|
|
12
|
+
* - the active authority file is now under `.state/` — the legacy
|
|
13
|
+
* `.pd/codex-ingestion-consent.json` (v2) is migrated on first read and
|
|
14
|
+
* renamed `.superseded` (kept for audit, never read again);
|
|
15
|
+
* - `decidedVia` additionally accepts `owner_directive` (with evidenceRef);
|
|
16
|
+
* - records gain an optional `evidenceRef`;
|
|
17
|
+
* - the disclosure version is still stamped from the frozen Codex
|
|
18
|
+
* disclosure constant unless the caller provides one explicitly.
|
|
27
19
|
*/
|
|
28
|
-
import fs from 'node:fs';
|
|
29
|
-
import path from 'node:path';
|
|
30
20
|
import { CODEX_INGESTION_DISCLOSURE_VERSION } from './codex-disclosure.js';
|
|
21
|
+
import { CONVERSATION_INGESTION_CONSENT_SCHEMA_VERSION, deriveConversationIngestionConsentState, getConversationIngestionConsentPath, readConversationIngestionConsent, recordConversationIngestionConsent, } from './conversation-ingestion/consent.js';
|
|
31
22
|
export const CODEX_INGESTION_CONSENT_FILENAME = 'codex-ingestion-consent.json';
|
|
32
|
-
|
|
23
|
+
/** Now the v3 ledger schema version (the v2 file format is legacy/migrating-only). */
|
|
24
|
+
export const CODEX_INGESTION_CONSENT_SCHEMA_VERSION = CONVERSATION_INGESTION_CONSENT_SCHEMA_VERSION;
|
|
25
|
+
/** Path of the ACTIVE authority (the v3 ledger under `.state/`). */
|
|
33
26
|
export function getCodexIngestionConsentPath(workspaceDir) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
function isDecision(value) {
|
|
37
|
-
return value === 'granted' || value === 'pending' || value === 'revoked' || value === 'failed';
|
|
38
|
-
}
|
|
39
|
-
function isDecidedVia(value) {
|
|
40
|
-
return value === 'pd_codex_setup' || value === 'codex_plugin_setup';
|
|
41
|
-
}
|
|
42
|
-
function isNonShortString(value, max) {
|
|
43
|
-
return typeof value === 'string' && value.length > 0 && value.length <= max;
|
|
44
|
-
}
|
|
45
|
-
function isIsoTimestamp(value) {
|
|
46
|
-
return isNonShortString(value, 40) && !Number.isNaN(Date.parse(value));
|
|
27
|
+
return getConversationIngestionConsentPath(workspaceDir);
|
|
47
28
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Read the consent record. ENOENT is the normal never-asked case
|
|
50
|
-
* (existed=false, record=null). Anything unreadable/malformed fails loud —
|
|
51
|
-
* degrading to "never asked" could re-prompt or re-enable against the
|
|
52
|
-
* Owner's recorded decision.
|
|
53
|
-
*/
|
|
29
|
+
/** Read the Codex slot of the v3 ledger (migrating a legacy v2 file when present). */
|
|
54
30
|
export function readCodexIngestionConsent(workspaceDir) {
|
|
55
|
-
|
|
56
|
-
let raw;
|
|
57
|
-
try {
|
|
58
|
-
raw = fs.readFileSync(filePath, 'utf8');
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
const codeValue = typeof error === 'object' && error !== null && Object.hasOwn(error, 'code')
|
|
62
|
-
? error.code
|
|
63
|
-
: undefined;
|
|
64
|
-
if (codeValue === 'ENOENT') {
|
|
65
|
-
return { ok: true, existed: false, record: null };
|
|
66
|
-
}
|
|
67
|
-
const code = typeof codeValue === 'string' ? codeValue : String(error);
|
|
68
|
-
return {
|
|
69
|
-
ok: false,
|
|
70
|
-
reason: `codex_ingestion_consent_unreadable: ${code.slice(0, 120)}`,
|
|
71
|
-
nextAction: `Check permissions on ${filePath}`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
let parsed;
|
|
75
|
-
try {
|
|
76
|
-
parsed = JSON.parse(raw);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
return {
|
|
80
|
-
ok: false,
|
|
81
|
-
reason: 'codex_ingestion_consent_malformed_json',
|
|
82
|
-
nextAction: `Fix or delete ${filePath} (delete = consent returns to not_present; the ingestion flag itself is unchanged)`,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
86
|
-
return {
|
|
87
|
-
ok: false,
|
|
88
|
-
reason: 'codex_ingestion_consent_malformed_shape',
|
|
89
|
-
nextAction: `Fix or delete ${filePath} (delete = consent returns to not_present; the ingestion flag itself is unchanged)`,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const obj = parsed;
|
|
93
|
-
const allowedKeys = ['decision', 'disclosureVersion', 'decidedAt', 'decidedVia', 'failureReason', 'schemaVersion'];
|
|
94
|
-
const errors = [];
|
|
95
|
-
for (const key of Object.keys(obj)) {
|
|
96
|
-
if (!allowedKeys.includes(key))
|
|
97
|
-
errors.push(`unknown field '${key}'`);
|
|
98
|
-
}
|
|
99
|
-
if (!isDecision(obj.decision))
|
|
100
|
-
errors.push('decision must be pending|granted|revoked|failed');
|
|
101
|
-
if (!isNonShortString(obj.disclosureVersion, 40))
|
|
102
|
-
errors.push('disclosureVersion must be a short non-empty string');
|
|
103
|
-
if (!isIsoTimestamp(obj.decidedAt))
|
|
104
|
-
errors.push('decidedAt must be a parseable ISO-8601 string');
|
|
105
|
-
if (!isDecidedVia(obj.decidedVia))
|
|
106
|
-
errors.push('decidedVia must be pd_codex_setup|codex_plugin_setup');
|
|
107
|
-
if (obj.failureReason !== undefined && !isNonShortString(obj.failureReason, 200)) {
|
|
108
|
-
errors.push('failureReason must be a non-empty string (≤200 chars) when present');
|
|
109
|
-
}
|
|
110
|
-
if (obj.schemaVersion !== CODEX_INGESTION_CONSENT_SCHEMA_VERSION) {
|
|
111
|
-
errors.push(`schemaVersion must be '${CODEX_INGESTION_CONSENT_SCHEMA_VERSION}'`);
|
|
112
|
-
}
|
|
113
|
-
if (errors.length > 0) {
|
|
114
|
-
return {
|
|
115
|
-
ok: false,
|
|
116
|
-
reason: `codex_ingestion_consent_malformed: ${errors.join('; ')}`,
|
|
117
|
-
nextAction: `Fix or delete ${filePath} (delete = consent returns to not_present; the ingestion flag itself is unchanged)`,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// Post-validation reconstruction from guard-narrowed fields — no `as` on
|
|
121
|
-
// the untrusted parsed object (rc-2). The errors check above proves every
|
|
122
|
-
// guard passes; the re-invoked guards here satisfy the type system the
|
|
123
|
-
// same way the telemetry consent store does.
|
|
124
|
-
return {
|
|
125
|
-
ok: true,
|
|
126
|
-
existed: true,
|
|
127
|
-
record: {
|
|
128
|
-
decision: isDecision(obj.decision) ? obj.decision : 'failed',
|
|
129
|
-
disclosureVersion: isNonShortString(obj.disclosureVersion, 40) ? obj.disclosureVersion : '',
|
|
130
|
-
decidedAt: isIsoTimestamp(obj.decidedAt) ? obj.decidedAt : '',
|
|
131
|
-
decidedVia: isDecidedVia(obj.decidedVia) ? obj.decidedVia : 'pd_codex_setup',
|
|
132
|
-
...(isNonShortString(obj.failureReason, 200) && obj.failureReason !== undefined ? { failureReason: obj.failureReason } : {}),
|
|
133
|
-
schemaVersion: CODEX_INGESTION_CONSENT_SCHEMA_VERSION,
|
|
134
|
-
},
|
|
135
|
-
};
|
|
31
|
+
return readConversationIngestionConsent(workspaceDir, 'codex');
|
|
136
32
|
}
|
|
137
33
|
/**
|
|
138
|
-
* Record an explicit consent decision
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* flow's explicit, ordered step.
|
|
34
|
+
* Record an explicit Codex consent decision. The disclosure version is stamped
|
|
35
|
+
* from the frozen Codex disclosure constant (callers may override — e.g. the
|
|
36
|
+
* P3 new-disclosure full-text tier). The flags remain untouched.
|
|
142
37
|
*/
|
|
143
38
|
export function recordCodexIngestionConsent(workspaceDir, input) {
|
|
144
|
-
|
|
145
|
-
// record this writer produces must never be rejected by its own reader.
|
|
146
|
-
const errors = [];
|
|
147
|
-
if (input.decidedAt !== undefined && !isIsoTimestamp(input.decidedAt))
|
|
148
|
-
errors.push('decidedAt must be a parseable ISO-8601 string when provided');
|
|
149
|
-
if (input.decision === 'failed' && (input.failureReason === undefined || input.failureReason.trim().length === 0)) {
|
|
150
|
-
errors.push('decision=failed requires a non-empty failureReason');
|
|
151
|
-
}
|
|
152
|
-
if (input.failureReason !== undefined && input.decision !== 'failed' && input.failureReason.trim().length === 0) {
|
|
153
|
-
errors.push('failureReason must be non-empty when provided');
|
|
154
|
-
}
|
|
155
|
-
if (errors.length > 0) {
|
|
156
|
-
return {
|
|
157
|
-
ok: false,
|
|
158
|
-
reason: 'codex_ingestion_consent_input_invalid: ' + errors.join('; '),
|
|
159
|
-
nextAction: 'Fix the recordCodexIngestionConsent arguments at the call site.',
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
const filePath = getCodexIngestionConsentPath(workspaceDir);
|
|
163
|
-
const record = {
|
|
39
|
+
return recordConversationIngestionConsent(workspaceDir, 'codex', {
|
|
164
40
|
decision: input.decision,
|
|
165
|
-
disclosureVersion: CODEX_INGESTION_DISCLOSURE_VERSION,
|
|
166
|
-
decidedAt: input.decidedAt ?? new Date().toISOString(),
|
|
167
41
|
decidedVia: input.decidedVia,
|
|
168
|
-
...(input.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
try {
|
|
174
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
175
|
-
fs.writeFileSync(tmpPath, `${JSON.stringify(record, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
176
|
-
fs.renameSync(tmpPath, filePath);
|
|
177
|
-
return { ok: true, record };
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
181
|
-
try {
|
|
182
|
-
fs.rmSync(tmpPath, { force: true });
|
|
183
|
-
}
|
|
184
|
-
catch {
|
|
185
|
-
// best-effort cleanup; the write failure below is the loud signal
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
ok: false,
|
|
189
|
-
reason: `codex_ingestion_consent_write_failed: ${message.slice(0, 200)}`,
|
|
190
|
-
nextAction: `Check permissions on ${dir}`,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
42
|
+
...(input.decidedAt !== undefined ? { decidedAt: input.decidedAt } : {}),
|
|
43
|
+
...(input.failureReason !== undefined ? { failureReason: input.failureReason } : {}),
|
|
44
|
+
disclosureVersion: input.disclosureVersion ?? CODEX_INGESTION_DISCLOSURE_VERSION,
|
|
45
|
+
...(input.evidenceRef !== undefined ? { evidenceRef: input.evidenceRef } : {}),
|
|
46
|
+
});
|
|
193
47
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Combine the consent record with the ingestion flag into the health-surface
|
|
196
|
-
* state (SPEC §15). Every flag×record combination maps to exactly one
|
|
197
|
-
* interpretable state — none of them reads as silently healthy:
|
|
198
|
-
*
|
|
199
|
-
* record granted + flag any → 'granted' (activation succeeded)
|
|
200
|
-
* record revoked + flag any → 'revoked' (Owner said no; flag-off
|
|
201
|
-
* path also regularizes the flag)
|
|
202
|
-
* record failed + flag any → 'failed' (activation did not land;
|
|
203
|
-
* failureReason explains why)
|
|
204
|
-
* record pending + flag off → 'pending' (decision recorded, activation not yet applied)
|
|
205
|
-
* record pending + flag on → 'pending' (activation applied, terminal write pending)
|
|
206
|
-
* no record + flag on → 'flag_on_without_grant' (governance warning)
|
|
207
|
-
* no record + flag off → 'not_present'
|
|
208
|
-
*/
|
|
48
|
+
/** Health-surface consent state (unchanged mapping). */
|
|
209
49
|
export function deriveCodexIngestionConsentState(record, ingestionFlagEnabled) {
|
|
210
|
-
|
|
211
|
-
return ingestionFlagEnabled ? 'flag_on_without_grant' : 'not_present';
|
|
212
|
-
}
|
|
213
|
-
switch (record.decision) {
|
|
214
|
-
case 'granted':
|
|
215
|
-
return 'granted';
|
|
216
|
-
case 'revoked':
|
|
217
|
-
return 'revoked';
|
|
218
|
-
case 'failed':
|
|
219
|
-
return 'failed';
|
|
220
|
-
case 'pending':
|
|
221
|
-
return 'pending';
|
|
222
|
-
}
|
|
50
|
+
return deriveConversationIngestionConsentState(record, ingestionFlagEnabled);
|
|
223
51
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation-ingestion consent ledger v3 (PRI-1171; SPEC v0.2 §8.1).
|
|
3
|
+
*
|
|
4
|
+
* Host-neutral successor of the Codex-only consent store: ONE file per
|
|
5
|
+
* workspace, keyed by host kind, at
|
|
6
|
+
* `<workspace>/.state/conversation-ingestion-consent.json`.
|
|
7
|
+
*
|
|
8
|
+
* Authority model (P4, unchanged from v2): the FEATURE FLAGS stay the runtime
|
|
9
|
+
* authority for whether ingestion runs; this ledger is the GOVERNANCE RECORD
|
|
10
|
+
* that the conversation-ingestion flags may only be enabled THROUGH the
|
|
11
|
+
* disclosed consent flow (or an explicit Owner directive). The unified
|
|
12
|
+
* ingestion pipeline additionally consults the recorded decision as its
|
|
13
|
+
* consent gate (SPEC §8.2: host AND ingestion-flag AND consent=granted).
|
|
14
|
+
*
|
|
15
|
+
* v2 → v3 migration (one-way, audit-preserving): when no v3 file exists but a
|
|
16
|
+
* legacy `<workspace>/.pd/codex-ingestion-consent.json` (schema v2) does, the
|
|
17
|
+
* first read migrates it — the v3 file is written FIRST (atomic), then the
|
|
18
|
+
* legacy file is RENAMED with a `.superseded` suffix (never deleted). A crash
|
|
19
|
+
* between the two steps is safe: v3 existing means the legacy file is ignored;
|
|
20
|
+
* no v3 means the migration simply retries. Health and the pipeline read ONLY
|
|
21
|
+
* v3 (single authority — no dual-file ambiguity).
|
|
22
|
+
*
|
|
23
|
+
* Records carry `disclosureVersion`: consent binds to the disclosure text it
|
|
24
|
+
* was granted against. The full-text tier additionally requires the record's
|
|
25
|
+
* disclosureVersion to be at least the current disclosure (see
|
|
26
|
+
* conversation-ingestion/text-policy.ts); an old bounded-era grant stays
|
|
27
|
+
* bounded until a new-disclosure record exists.
|
|
28
|
+
*
|
|
29
|
+
* `decidedVia: 'owner_directive'` records an Owner decision made outside the
|
|
30
|
+
* setup flows (e.g. SPEC approval), with `evidenceRef` pointing at the
|
|
31
|
+
* decision record.
|
|
32
|
+
*
|
|
33
|
+
* Patterns mirror the v2 store: missing file is the normal never-asked case;
|
|
34
|
+
* malformed files fail loud (rc-3/rc-9) because silently treating them as
|
|
35
|
+
* "never asked" could re-enable against a recorded Owner decision; writes are
|
|
36
|
+
* atomic (temp + rename); unknown/malformed fields are rejected via guards,
|
|
37
|
+
* never `as` (rc-1/rc-2/rc-5). This file is consent control state — it never
|
|
38
|
+
* contains captured conversation text.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CONVERSATION_INGESTION_CONSENT_FILENAME = "conversation-ingestion-consent.json";
|
|
41
|
+
export declare const CONVERSATION_INGESTION_CONSENT_SCHEMA_VERSION = "3";
|
|
42
|
+
/** Suffix applied to the superseded v2 file (kept on disk for audit; never read again). */
|
|
43
|
+
export declare const CONVERSATION_INGESTION_CONSENT_SUPERSEDED_SUFFIX = ".superseded";
|
|
44
|
+
/** Legacy v2 authority location (Codex-only era); migrated on first read. */
|
|
45
|
+
export declare const LEGACY_CODEX_CONSENT_FILENAME = "codex-ingestion-consent.json";
|
|
46
|
+
export declare const LEGACY_CODEX_CONSENT_SCHEMA_VERSION = "2";
|
|
47
|
+
export type ConversationConsentHostKind = 'codex' | 'workbuddy' | 'openclaw';
|
|
48
|
+
/**
|
|
49
|
+
* Consent transition states (unchanged semantics from the v2 store):
|
|
50
|
+
*
|
|
51
|
+
* absent ──(disclosure shown, explicit decision)──▶ pending
|
|
52
|
+
* pending ──(flag enabled successfully)───────────▶ granted
|
|
53
|
+
* pending ──(declined / flag regularized off)─────▶ revoked
|
|
54
|
+
* pending ──(flag enable failed)──────────────────▶ failed (with reason)
|
|
55
|
+
* granted ──(explicit decline)────────────────────▶ revoked
|
|
56
|
+
*
|
|
57
|
+
* `granted` is only ever recorded AFTER the runtime flag activation has
|
|
58
|
+
* succeeded — consent can never become granted before activation. The flags
|
|
59
|
+
* remain the runtime authority; this record is the governance state machine
|
|
60
|
+
* that makes every observed flag/consent combination interpretable.
|
|
61
|
+
*/
|
|
62
|
+
export type ConversationIngestionConsentDecision = 'pending' | 'granted' | 'revoked' | 'failed';
|
|
63
|
+
export type ConversationIngestionConsentDecidedVia = 'pd_codex_setup' | 'codex_plugin_setup' | 'owner_directive';
|
|
64
|
+
export interface ConversationIngestionConsentRecord {
|
|
65
|
+
decision: ConversationIngestionConsentDecision;
|
|
66
|
+
disclosureVersion: string;
|
|
67
|
+
decidedAt: string;
|
|
68
|
+
decidedVia: ConversationIngestionConsentDecidedVia;
|
|
69
|
+
/** Populated when decision='failed': why the flag activation did not land. */
|
|
70
|
+
failureReason?: string;
|
|
71
|
+
/** Populated for owner_directive grants: where the decision is recorded (e.g. SPEC revision table). */
|
|
72
|
+
evidenceRef?: string;
|
|
73
|
+
schemaVersion: string;
|
|
74
|
+
}
|
|
75
|
+
export type ConversationIngestionConsentRead = {
|
|
76
|
+
ok: true;
|
|
77
|
+
existed: boolean;
|
|
78
|
+
record: ConversationIngestionConsentRecord | null;
|
|
79
|
+
migratedFromLegacy?: boolean;
|
|
80
|
+
warnings?: readonly string[];
|
|
81
|
+
} | {
|
|
82
|
+
ok: false;
|
|
83
|
+
reason: string;
|
|
84
|
+
nextAction: string;
|
|
85
|
+
};
|
|
86
|
+
export type ConversationIngestionConsentWrite = {
|
|
87
|
+
ok: true;
|
|
88
|
+
record: ConversationIngestionConsentRecord;
|
|
89
|
+
} | {
|
|
90
|
+
ok: false;
|
|
91
|
+
reason: string;
|
|
92
|
+
nextAction: string;
|
|
93
|
+
};
|
|
94
|
+
/** Health-surface consent state (no captured text, ever). */
|
|
95
|
+
export type ConversationIngestionConsentState = 'granted' | 'revoked' | 'pending' | 'failed' | 'not_present' | 'flag_on_without_grant';
|
|
96
|
+
export declare function getConversationIngestionConsentPath(workspaceDir: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Read one host's consent record from the v3 ledger (the ONLY authority).
|
|
99
|
+
* A missing v3 file with an existing legacy v2 Codex file triggers the one-way
|
|
100
|
+
* migration. ENOENT on both is the normal never-asked case.
|
|
101
|
+
*/
|
|
102
|
+
export declare function readConversationIngestionConsent(workspaceDir: string, hostKind: ConversationConsentHostKind): ConversationIngestionConsentRead;
|
|
103
|
+
/**
|
|
104
|
+
* Record an explicit consent decision for one host (the setup flow presents
|
|
105
|
+
* the frozen disclosure before calling this; an owner_directive record cites
|
|
106
|
+
* its evidenceRef). Other hosts' slots are preserved; the flags themselves are
|
|
107
|
+
* intentionally untouched.
|
|
108
|
+
*/
|
|
109
|
+
export declare function recordConversationIngestionConsent(workspaceDir: string, hostKind: ConversationConsentHostKind, input: {
|
|
110
|
+
decision: ConversationIngestionConsentDecision;
|
|
111
|
+
decidedVia: ConversationIngestionConsentDecidedVia;
|
|
112
|
+
decidedAt?: string;
|
|
113
|
+
failureReason?: string;
|
|
114
|
+
disclosureVersion?: string;
|
|
115
|
+
evidenceRef?: string;
|
|
116
|
+
}): ConversationIngestionConsentWrite;
|
|
117
|
+
/**
|
|
118
|
+
* Combine the consent record with the ingestion flag into the health-surface
|
|
119
|
+
* state. Every flag×record combination maps to exactly one interpretable
|
|
120
|
+
* state — none of them reads as silently healthy.
|
|
121
|
+
*/
|
|
122
|
+
export declare function deriveConversationIngestionConsentState(record: ConversationIngestionConsentRecord | null, ingestionFlagEnabled: boolean): ConversationIngestionConsentState;
|
|
123
|
+
/** Host kinds recognized by the ledger (for health surfaces). */
|
|
124
|
+
export declare const CONVERSATION_CONSENT_HOST_KINDS: readonly ConversationConsentHostKind[];
|