@dzhechkov/harness-core 0.7.4 → 0.7.6

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 (82) hide show
  1. package/.dz-manifest.json +141 -61
  2. package/README.md +38 -1
  3. package/dist/agentdb-index.d.ts.map +1 -1
  4. package/dist/agentdb-index.js +26 -2
  5. package/dist/agentdb-index.js.map +1 -1
  6. package/dist/amendment-trace.d.ts.map +1 -1
  7. package/dist/amendment-trace.js +6 -1
  8. package/dist/amendment-trace.js.map +1 -1
  9. package/dist/cadence.d.ts +66 -0
  10. package/dist/cadence.d.ts.map +1 -0
  11. package/dist/cadence.js +222 -0
  12. package/dist/cadence.js.map +1 -0
  13. package/dist/feature-adr-routing.d.ts.map +1 -1
  14. package/dist/feature-adr-routing.js +7 -2
  15. package/dist/feature-adr-routing.js.map +1 -1
  16. package/dist/index.d.ts +8 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +6 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/loop-blobs.generated.js +2 -2
  21. package/dist/loop-blobs.generated.js.map +1 -1
  22. package/dist/operations.d.ts.map +1 -1
  23. package/dist/operations.js +53 -18
  24. package/dist/operations.js.map +1 -1
  25. package/dist/provenance.d.ts +6 -0
  26. package/dist/provenance.d.ts.map +1 -1
  27. package/dist/provenance.js +22 -1
  28. package/dist/provenance.js.map +1 -1
  29. package/dist/publish.d.ts +31 -0
  30. package/dist/publish.d.ts.map +1 -1
  31. package/dist/publish.js +78 -0
  32. package/dist/publish.js.map +1 -1
  33. package/dist/recall-hook-policy.d.ts +3 -1
  34. package/dist/recall-hook-policy.d.ts.map +1 -1
  35. package/dist/recall-hook-policy.js +15 -2
  36. package/dist/recall-hook-policy.js.map +1 -1
  37. package/dist/recall-usage.d.ts +15 -0
  38. package/dist/recall-usage.d.ts.map +1 -1
  39. package/dist/recall-usage.js +51 -1
  40. package/dist/recall-usage.js.map +1 -1
  41. package/dist/score.d.ts.map +1 -1
  42. package/dist/score.js +38 -4
  43. package/dist/score.js.map +1 -1
  44. package/dist/skill-drift.d.ts +8 -2
  45. package/dist/skill-drift.d.ts.map +1 -1
  46. package/dist/skill-drift.js +60 -11
  47. package/dist/skill-drift.js.map +1 -1
  48. package/dist/skill-install-roots.d.ts +100 -0
  49. package/dist/skill-install-roots.d.ts.map +1 -0
  50. package/dist/skill-install-roots.js +116 -0
  51. package/dist/skill-install-roots.js.map +1 -0
  52. package/dist/tg-post.d.ts +76 -0
  53. package/dist/tg-post.d.ts.map +1 -0
  54. package/dist/tg-post.js +158 -0
  55. package/dist/tg-post.js.map +1 -0
  56. package/dist/usage.d.ts +31 -0
  57. package/dist/usage.d.ts.map +1 -1
  58. package/dist/usage.js +108 -21
  59. package/dist/usage.js.map +1 -1
  60. package/dist/writer-quiescence.d.ts +42 -0
  61. package/dist/writer-quiescence.d.ts.map +1 -0
  62. package/dist/writer-quiescence.js +82 -0
  63. package/dist/writer-quiescence.js.map +1 -0
  64. package/package.json +13 -13
  65. package/sbom.json +260 -60
  66. package/src/agentdb-index.ts +26 -2
  67. package/src/amendment-trace.ts +6 -1
  68. package/src/cadence.ts +227 -0
  69. package/src/feature-adr-routing.ts +7 -2
  70. package/src/index.ts +8 -1
  71. package/src/loop-blobs.generated.ts +2 -2
  72. package/src/operations.ts +52 -19
  73. package/src/provenance.ts +23 -1
  74. package/src/publish.ts +98 -0
  75. package/src/recall-hook-policy.ts +15 -2
  76. package/src/recall-usage.ts +44 -1
  77. package/src/score.ts +30 -4
  78. package/src/skill-drift.ts +70 -13
  79. package/src/skill-install-roots.ts +119 -0
  80. package/src/tg-post.ts +192 -0
  81. package/src/usage.ts +132 -17
  82. package/src/writer-quiescence.ts +95 -0
@@ -110,7 +110,19 @@ export async function indexPatternsToAgentdb(
110
110
  };
111
111
  const model = resolveEmbedModel(projectRoot);
112
112
  if ('error' in model) return { indexed: 0, error: model.error };
113
- const emb = new EmbeddingService({ model: model.model, dimension: model.dim, provider: 'transformers' });
113
+ const emb = new EmbeddingService({
114
+ model: model.model,
115
+ dimension: model.dim,
116
+ provider: 'transformers',
117
+ // agentdb >= 3.0.0-alpha.20 refuses UNREGISTERED models without an explicit role policy
118
+ // (its built-in registry knows all-MiniLM-L6-v2 but not our multilingual variant — grounded
119
+ // in dist/src/controllers/EmbeddingService.js:53). paraphrase-multilingual-MiniLM is a
120
+ // SYMMETRIC sentence-transformer (no query/passage instruction prefixes), so the policy is
121
+ // {kind:'symmetric'} — the same one the registry assigns its own symmetric models. On
122
+ // alpha.18 the extra field is ignored; without it alpha.20 threw and the vector tier fell
123
+ // to lexical SILENTLY (mirror writes answered {indexed:0, error} — measured 2026-08-24).
124
+ rolePolicy: { kind: 'symmetric' },
125
+ } as never);
114
126
  await emb.initialize();
115
127
 
116
128
  const dbFile = resolveAgentdbPath(projectRoot, opts.dbPath);
@@ -242,7 +254,19 @@ export async function resolveAgentdbEmbedder(
242
254
  };
243
255
  const model = resolveEmbedModel(projectRoot);
244
256
  if ('error' in model) return { error: model.error };
245
- const emb = new EmbeddingService({ model: model.model, dimension: model.dim, provider: 'transformers' });
257
+ const emb = new EmbeddingService({
258
+ model: model.model,
259
+ dimension: model.dim,
260
+ provider: 'transformers',
261
+ // agentdb >= 3.0.0-alpha.20 refuses UNREGISTERED models without an explicit role policy
262
+ // (its built-in registry knows all-MiniLM-L6-v2 but not our multilingual variant — grounded
263
+ // in dist/src/controllers/EmbeddingService.js:53). paraphrase-multilingual-MiniLM is a
264
+ // SYMMETRIC sentence-transformer (no query/passage instruction prefixes), so the policy is
265
+ // {kind:'symmetric'} — the same one the registry assigns its own symmetric models. On
266
+ // alpha.18 the extra field is ignored; without it alpha.20 threw and the vector tier fell
267
+ // to lexical SILENTLY (mirror writes answered {indexed:0, error} — measured 2026-08-24).
268
+ rolePolicy: { kind: 'symmetric' },
269
+ } as never);
246
270
  await emb.initialize();
247
271
  return { embed: (t: string) => emb.embed(t) };
248
272
  } catch (err) {
@@ -74,7 +74,12 @@ export const MIN_MATCHABLE_ID_LENGTH = 8;
74
74
  export function extractTestTitles(body: string): string[] {
75
75
  const code = body.replace(/\/\*[\s\S]*?\*\//g, ' ').replace(/(^|[^:])\/\/[^\n]*/g, '$1');
76
76
  const out: string[] = [];
77
- const re = /\b(?:it|test|describe)(?:\.\w+)*(?:\s*\([^()]{0,200}\))?\s*(?:`[^`]*`)?\s*\(\s*(['"`])([\s\S]{1,300}?)\1/g;
77
+ // The modifier-argument group admits ONE level of nested parens: `it.skipIf(!existsSync(BIN))`
78
+ // carries a call inside the guard, and the flat `[^()]{0,200}` failed on it — so every title in
79
+ // a file whose tests were guarded that way was invisible, and `dz amendment-check` reported
80
+ // `searched 1 test title(s)` over a nine-test file (MEASURED 2026-08-24 on the name-check
81
+ // feature; worked around there by de-guarding the tests, fixed here at the extractor).
82
+ const re = /\b(?:it|test|describe)(?:\.\w+)*(?:\s*\((?:[^()]|\([^()]*\)){0,200}\))?\s*(?:`[^`]*`)?\s*\(\s*(['"`])([\s\S]{1,300}?)\1/g;
78
83
  for (let m = re.exec(code); m !== null; m = re.exec(code)) if (m[2]) out.push(m[2]);
79
84
  return out;
80
85
  }
package/src/cadence.ts ADDED
@@ -0,0 +1,227 @@
1
+ /**
2
+ * `dz cadence` — the "what shipped" aggregator (backlog ef740b44), built on one spine:
3
+ * A WINDOW DEEPER THAN THE RECORD IS REFUSED (ADR-001). The weekly-digest research (2026-08-22)
4
+ * caught a «year» digest standing on 174 days of data — scale forgery by aggregation; an
5
+ * aggregator that silently computes any requested period repeats it mechanically.
6
+ *
7
+ * Four sources, every degradation NAMED in the report, never a silent zero:
8
+ * - graded shipments: features/<slug>/08_qe_report.md through the hardened readQeGrade
9
+ * (prefix-negation aware, all measured real-world grade forms); ungraded reports are a COLUMN;
10
+ * - npm publishes: the dz recap registry-time cache (third-party timestamps);
11
+ * - guard repeat decay on a FIXED rule set: a rule enters only with events BEFORE the window
12
+ * start (the data-driven birth proxy — the no-stubs class of «zero repeats because the rule is
13
+ * young» is excluded by construction);
14
+ * - knowledge reuse: recall events per bucket from .dz/recall-usage.jsonl.
15
+ */
16
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
17
+ import { join } from 'node:path';
18
+
19
+ import { readQeGrade } from './score.js';
20
+
21
+ export type CadenceWindow = 'day' | 'week' | 'month' | 'quarter' | 'halfyear' | 'year';
22
+
23
+ export const CADENCE_WINDOW_DAYS: Record<CadenceWindow, number> = {
24
+ day: 1, week: 7, month: 30, quarter: 91, halfyear: 182, year: 365,
25
+ };
26
+
27
+ export interface CadenceWindowDecision {
28
+ readonly ok: boolean;
29
+ readonly reason: string;
30
+ /** The largest window today's record CAN honestly carry, or null when even `day` cannot. */
31
+ readonly largestAllowed: CadenceWindow | null;
32
+ }
33
+
34
+ /**
35
+ * ADR-001: a window is accepted only when the record is at least TWO windows deep — two full units
36
+ * are the minimum for the word «cadence»; one point has no rhythm.
37
+ */
38
+ export function decideCadenceWindow(window: CadenceWindow, dataDepthDays: number): CadenceWindowDecision {
39
+ const need = CADENCE_WINDOW_DAYS[window] * 2;
40
+ const order: CadenceWindow[] = ['year', 'halfyear', 'quarter', 'month', 'week', 'day'];
41
+ const largestAllowed = order.find((w) => dataDepthDays >= CADENCE_WINDOW_DAYS[w] * 2) ?? null;
42
+ if (dataDepthDays >= need) return { ok: true, reason: `record depth ${dataDepthDays}d covers 2×${window}`, largestAllowed };
43
+ return {
44
+ ok: false,
45
+ reason: `REFUSED: the record is ${dataDepthDays} day(s) deep and a ${window} cadence needs ${need} — a cadence computed from under two full windows is a scale forgery, not a number` +
46
+ (largestAllowed ? `; the largest honest window today is «${largestAllowed}»` : '; even «day» is not established yet'),
47
+ largestAllowed,
48
+ };
49
+ }
50
+
51
+ /** ISO week key (YYYY-Www) for a ms timestamp. */
52
+ export function isoWeekOf(ms: number): string {
53
+ const d = new Date(ms);
54
+ const t = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
55
+ const day = t.getUTCDay() === 0 ? 7 : t.getUTCDay();
56
+ t.setUTCDate(t.getUTCDate() + 4 - day);
57
+ const yearStart = Date.UTC(t.getUTCFullYear(), 0, 1);
58
+ const week = Math.ceil(((t.getTime() - yearStart) / 86400000 + 1) / 7);
59
+ return `${t.getUTCFullYear()}-W${String(week).padStart(2, '0')}`;
60
+ }
61
+
62
+ export interface CadenceEvent { readonly ts: number; readonly kind: string; readonly detail?: string }
63
+
64
+ /** Bucket events into ISO weeks inside [windowStart, now]. */
65
+ export function weeklyBuckets(events: readonly CadenceEvent[], windowStartMs: number, nowMs: number): Map<string, CadenceEvent[]> {
66
+ const out = new Map<string, CadenceEvent[]>();
67
+ for (const e of events) {
68
+ if (!isFinite(e.ts) || e.ts < windowStartMs || e.ts > nowMs) continue;
69
+ const k = isoWeekOf(e.ts);
70
+ const list = out.get(k) ?? [];
71
+ list.push(e);
72
+ out.set(k, list);
73
+ }
74
+ return out;
75
+ }
76
+
77
+ export interface GuardDecayRow { readonly rule: string; readonly before: number; readonly inWindow: number }
78
+
79
+ /**
80
+ * Repeat decay over the FIXED set: only rules with at least one event BEFORE the window start
81
+ * qualify (their existence predates the window); newborn rules are EXCLUDED by construction and
82
+ * returned separately so the exclusion is visible.
83
+ */
84
+ export function guardRepeatDecay(
85
+ events: readonly { ts: number; rule: string }[],
86
+ windowStartMs: number,
87
+ ): { decay: GuardDecayRow[]; excludedNewborn: string[] } {
88
+ const before = new Map<string, number>();
89
+ const inWindow = new Map<string, number>();
90
+ for (const e of events) {
91
+ if (!isFinite(e.ts) || e.rule === '') continue;
92
+ if (e.ts < windowStartMs) before.set(e.rule, (before.get(e.rule) ?? 0) + 1);
93
+ else inWindow.set(e.rule, (inWindow.get(e.rule) ?? 0) + 1);
94
+ }
95
+ const decay: GuardDecayRow[] = [...before.entries()]
96
+ .map(([rule, b]) => ({ rule, before: b, inWindow: inWindow.get(rule) ?? 0 }))
97
+ .sort((a, b) => b.before - a.before);
98
+ const excludedNewborn = [...inWindow.keys()].filter((r) => !before.has(r)).sort();
99
+ return { decay, excludedNewborn };
100
+ }
101
+
102
+ export interface CadenceReport {
103
+ readonly window: CadenceWindow;
104
+ readonly decision: CadenceWindowDecision;
105
+ readonly depthDays: number;
106
+ readonly shipments: { graded: Record<string, number>; ungraded: number; gradedTotal: number; byGrade: Record<string, number> };
107
+ readonly npmPublishes: { weekly: Record<string, number>; degraded: string | null };
108
+ readonly guard: { decay: GuardDecayRow[]; excludedNewborn: string[]; degraded: string | null };
109
+ readonly recalls: { weekly: Record<string, number>; degraded: string | null };
110
+ }
111
+
112
+ function safeJsonl(path: string): unknown[] {
113
+ const out: unknown[] = [];
114
+ try {
115
+ for (const line of readFileSync(path, 'utf-8').split('\n')) {
116
+ if (line.trim() === '') continue;
117
+ try { out.push(JSON.parse(line)); } catch { /* torn line — skip, counted nowhere */ }
118
+ }
119
+ } catch { /* absent file — callers name the degradation */ }
120
+ return out;
121
+ }
122
+
123
+ /** Build the full report. `now` injectable — the refusal decision must be testable. */
124
+ export function buildCadenceReport(root: string, window: CadenceWindow, now?: number): CadenceReport {
125
+ const nowMs = typeof now === 'number' && isFinite(now) ? now : Date.now();
126
+
127
+ // Shipment events: graded 08 reports, dated by the run-cost ledger (fallback: report mtime is
128
+ // NOT used — an mtime moves on every touch; an undatable report lands in `ungraded`... no: in
129
+ // its own named bucket via ledger-missing) — v1 keeps the honest subset: ledger-dated only.
130
+ const ledger = safeJsonl(join(root, '.dz', 'feature-adr', 'run-cost-ledger.jsonl')) as Array<{ slug?: string; date?: string }>;
131
+ const dateBySlug = new Map<string, number>();
132
+ let earliest = nowMs;
133
+ for (const r of ledger) {
134
+ if (typeof r.slug !== 'string' || typeof r.date !== 'string') continue;
135
+ const ts = Date.parse(r.date);
136
+ if (!isFinite(ts)) continue;
137
+ if (!dateBySlug.has(r.slug) || ts > (dateBySlug.get(r.slug) as number)) dateBySlug.set(r.slug, ts);
138
+ if (ts < earliest) earliest = ts;
139
+ }
140
+ // Record depth is the UNION of sources — the npm registry reaches months past the ledger, and a
141
+ // refusal computed from the shallowest source alone would under-admit honest windows.
142
+ let unionEarliest = earliest;
143
+ try {
144
+ const cache = JSON.parse(readFileSync(join(root, '.dz', 'recap', 'npm-times.json'), 'utf-8')) as { packages?: Record<string, { versions?: Record<string, string> }> };
145
+ for (const entry of Object.values(cache.packages ?? {})) for (const iso of Object.values(entry.versions ?? {})) {
146
+ const ts = Date.parse(iso); if (isFinite(ts) && ts < unionEarliest) unionEarliest = ts;
147
+ }
148
+ } catch { /* cache absent — named later */ }
149
+ for (const row of safeJsonl(join(root, '.dz', 'guard-audit.jsonl')) as Array<{ ts?: string }>) {
150
+ const ts = Date.parse(String(row.ts ?? '')); if (isFinite(ts) && ts < unionEarliest) unionEarliest = ts;
151
+ }
152
+ const depthDays = Math.floor((nowMs - unionEarliest) / 86400000);
153
+ const decision = decideCadenceWindow(window, depthDays);
154
+ const windowStart = nowMs - CADENCE_WINDOW_DAYS[window] * 86400000;
155
+
156
+ const gradedWeekly: Record<string, number> = {};
157
+ const byGrade: Record<string, number> = {};
158
+ let ungraded = 0;
159
+ let gradedTotal = 0;
160
+ const featuresDir = join(root, 'features');
161
+ if (existsSync(featuresDir) && decision.ok) {
162
+ for (const slug of readdirSync(featuresDir)) {
163
+ const report = join(featuresDir, slug, '08_qe_report.md');
164
+ if (!existsSync(report)) continue;
165
+ const ts = dateBySlug.get(slug);
166
+ if (ts === undefined || ts < windowStart || ts > nowMs) continue;
167
+ const grade = readQeGrade(readFileSync(report, 'utf-8')).grade;
168
+ if (grade === null) { ungraded += 1; continue; }
169
+ gradedTotal += 1;
170
+ byGrade[grade] = (byGrade[grade] ?? 0) + 1;
171
+ const wk = isoWeekOf(ts);
172
+ gradedWeekly[wk] = (gradedWeekly[wk] ?? 0) + 1;
173
+ }
174
+ }
175
+
176
+ // npm publishes from the recap cache — third-party registry timestamps.
177
+ const npmWeekly: Record<string, number> = {};
178
+ let npmDegraded: string | null = null;
179
+ const npmCache = join(root, '.dz', 'recap', 'npm-times.json');
180
+ if (!existsSync(npmCache)) {
181
+ npmDegraded = 'no npm-times cache — run `dz recap --refresh-publishes` first (registry timestamps are third-party data this command never fetches itself)';
182
+ } else if (decision.ok) {
183
+ try {
184
+ const cache = JSON.parse(readFileSync(npmCache, 'utf-8')) as { packages?: Record<string, { versions?: Record<string, string> }> };
185
+ for (const entry of Object.values(cache.packages ?? {})) {
186
+ for (const iso of Object.values(entry.versions ?? {})) {
187
+ const ts = Date.parse(iso);
188
+ if (!isFinite(ts) || ts < windowStart || ts > nowMs) continue;
189
+ const wk = isoWeekOf(ts);
190
+ npmWeekly[wk] = (npmWeekly[wk] ?? 0) + 1;
191
+ }
192
+ }
193
+ } catch { npmDegraded = 'npm-times cache unreadable — refresh it (`dz recap --refresh-publishes`)'; }
194
+ }
195
+
196
+ // Guard decay on the fixed set.
197
+ const guardRows = (safeJsonl(join(root, '.dz', 'guard-audit.jsonl')) as Array<{ ts?: string; at?: string; rule?: string; violations?: Array<{ rule?: string }> }>)
198
+ .flatMap((r) => {
199
+ const ts = Date.parse(String(r.ts ?? r.at ?? ''));
200
+ if (!isFinite(ts)) return [];
201
+ // the live shape: one audit row carries violations[] each naming its rule
202
+ if (Array.isArray(r.violations)) return r.violations.map((v) => ({ ts, rule: String(v?.rule ?? '') })).filter((x) => x.rule !== '');
203
+ return typeof r.rule === 'string' && r.rule !== '' ? [{ ts, rule: r.rule }] : [];
204
+ });
205
+ const guard = decision.ok ? guardRepeatDecay(guardRows, windowStart) : { decay: [], excludedNewborn: [] };
206
+ const guardDegraded = guardRows.length === 0 ? 'no guard-audit events on disk — decay has nothing to stand on' : null;
207
+
208
+ // Knowledge reuse: recall events.
209
+ const recallRows = (safeJsonl(join(root, '.dz', 'recall-usage.jsonl')) as Array<{ ts?: string; at?: string }>)
210
+ .map((r) => Date.parse(String(r.ts ?? r.at ?? '')))
211
+ .filter((t) => isFinite(t));
212
+ const recallWeekly: Record<string, number> = {};
213
+ if (decision.ok) for (const ts of recallRows) {
214
+ if (ts < windowStart || ts > nowMs) continue;
215
+ const wk = isoWeekOf(ts);
216
+ recallWeekly[wk] = (recallWeekly[wk] ?? 0) + 1;
217
+ }
218
+ const recallDegraded = recallRows.length === 0 ? 'no recall-usage events — the reuse leg has nothing to stand on' : null;
219
+
220
+ return {
221
+ window, decision, depthDays,
222
+ shipments: { graded: gradedWeekly, ungraded, gradedTotal, byGrade },
223
+ npmPublishes: { weekly: npmWeekly, degraded: npmDegraded },
224
+ guard: { ...guard, degraded: guardDegraded },
225
+ recalls: { weekly: recallWeekly, degraded: recallDegraded },
226
+ };
227
+ }
@@ -188,7 +188,7 @@ export function decideUsageAction(
188
188
  // ── Data tables (data-only extensibility — gpt-5.6-ready) ───────────────────
189
189
 
190
190
  /** Known codex ids. Adding a new id (e.g. `'gpt-5.7'`) is a DATA-ONLY change. */
191
- export const KNOWN_CODEX: Record<string, number> = { auto: 1, 'gpt-5.5': 1, 'gpt-5.6': 1, 'gpt-5.6-sol': 1 };
191
+ export const KNOWN_CODEX: Record<string, number> = { auto: 1, 'gpt-5.5': 1, 'gpt-5.6': 1, 'gpt-5.6-luna': 1, 'gpt-5.6-terra': 1, 'gpt-5.6-sol': 1 };
192
192
 
193
193
  /** The Claude model names the Workflow runtime accepts as `agent()` `model`. */
194
194
  export const CLAUDE_NAMES: Record<string, number> = { fable: 1, opus: 1, sonnet: 1, haiku: 1 };
@@ -2029,7 +2029,12 @@ export function planCompletenessGateCmd(repo: string, featureDir: string, tier?:
2029
2029
  // and the tried paths live OUTSIDE the verdict line so no path can smuggle a second verdict word
2030
2030
  // into it.
2031
2031
  'echo "K2_GATE_SCRIPT=${GS:-none}"',
2032
- 'echo "K2_GATE_TRIED=${C1:-(none)} | $C2 | $C3"',
2032
+ 'echo "K2_GATE_TRIED=C1(args.gateScript)=${C1:-<unset>} | C2(workspace)=$C2 | C3(target-repo)=$C3"',
2033
+ // A COLLAPSE is not a second candidate. When the workspace was not pinned, WS falls back to the
2034
+ // gate agent own cwd — in the field that WAS the target repo, so C2 and C3 printed the same path
2035
+ // twice and the chain silently degenerated from three candidates to two. Saying so turns a
2036
+ // puzzling duplicate into an instruction. Not verdict-shaped, so the parser anchoring is untouched.
2037
+ '[ "$C2" = "$C3" ] && echo "K2_GATE_NOTE=the workspace candidate resolved to the TARGET repo (WS==repo), so only two distinct candidates were tried; pass args.workspace or args.gateScript when the feature-adr skill is installed outside the target repo"',
2033
2038
  'if [ -z "$GS" ]; then echo "K2 plan-completeness: NOT-ESTABLISHED — tooling-missing: no gate script at any candidate on the K2_GATE_TRIED line above"; echo "K2_EXIT=3"; else cd ' + q(repo) + ' && node "$GS" ' + q(featureDir) + t + ' 2>&1; echo "K2_EXIT=$?"; fi',
2034
2039
  ].join('\n')
2035
2040
  }
package/src/index.ts CHANGED
@@ -76,6 +76,7 @@ export type { CreateSkillOptions, CreateSkillResult } from './create-skill.js';
76
76
  export { checkUpstream, checkAllUpstream, discoverSourcePackages, loadSourcesManifest } from './sync-upstream.js';
77
77
  export type { SyncUpstreamReport, UpstreamCheckResult, SourcesManifest, SourcePackageInfo } from './sync-upstream.js';
78
78
  export { sweepSkillDrift, syncCanonicalSkill } from './skill-drift.js';
79
+ export { SKILL_INSTALL_ROOTS, SKILL_INSTALL_ROOT_BY_TARGET, DEV_SKILL_ROOT, TARGET_ENRICHMENT_ASSETS } from './skill-install-roots.js';
79
80
  export type { SweepResult, DriftedSkill, SyncResult, SyncCanonicalOptions } from './skill-drift.js';
80
81
  export { benchmarkSkill, benchmarkSkills, compareSkills } from './benchmark.js';
81
82
  export { buildRegistry, searchRegistry, filterByCategory, skillPackBaseDirs, discoverSkillPackDirs, discoverVerifiablePackDirs } from './registry.js';
@@ -331,6 +332,7 @@ export {
331
332
  compactRecallUsageLog,
332
333
  compactRecallUsageLogChecked,
333
334
  appendRecallUsage,
335
+ countRecallEventsForRun,
334
336
  runtimeOf,
335
337
  RUNTIMES,
336
338
  } from './recall-usage.js';
@@ -461,7 +463,7 @@ export type {
461
463
  ChainDefectAge,
462
464
  ChainDefectAges,
463
465
  } from './event-chain.js';
464
- export { decideProvenance, environmentCanMintProvenance, publishArgv, discoverPackages, publishPackages, bumpPatch, compareVersions, findUnpackagedSkills, orderByDependencies, syncReadmeVersion } from './publish.js';
466
+ export { decideProvenance, environmentCanMintProvenance, publishArgv, discoverPackages, publishPackages, bumpPatch, compareVersions, findUnpackagedSkills, findUnpublishedWorkspaceFloors, orderByDependencies, syncReadmeVersion } from './publish.js';
465
467
  export { fetchAllDownloads } from './downloads.js';
466
468
  export type { PackageDownloads, DownloadsReport } from './downloads.js';
467
469
  export { discoverInstalled, checkUpgrades } from './upgrade.js';
@@ -818,6 +820,7 @@ export * from './recap.js';
818
820
  export * from './provenance.js';
819
821
  export * from './name-check.js';
820
822
  export * from './cli-flag-notice.js';
823
+ export * from './tg-post.js';
821
824
 
822
825
  // Mutation gate (feature ha-mutation-gate) — deliberately break each NAMED protection in a scratch
823
826
  // copy, run the suite, REQUIRE red. Proves a test DISCRIMINATES, not merely that it is green.
@@ -832,3 +835,7 @@ export * from './backlog.js';
832
835
  // no-stubs (backlog 0b403a0106103901) — deterministic unfinished-stub-marker scan over the
833
836
  // CHANGE-SET, wired as the `no-stubs` SOFT publish guard rule + the feature-adr Step-8 QE item.
834
837
  export * from './no-stubs.js';
838
+ export { quiescenceProbeScript, decideWriterQuiescence, WQ_WINDOW_SECONDS, WQ_MAX_WINDOWS, WQ_REQUIRED_QUIET } from './writer-quiescence.js';
839
+ export type { WriterQuiescenceDecision } from './writer-quiescence.js';
840
+ export { decideCadenceWindow, isoWeekOf, weeklyBuckets, guardRepeatDecay, buildCadenceReport, CADENCE_WINDOW_DAYS } from './cadence.js';
841
+ export type { CadenceWindow, CadenceReport, CadenceWindowDecision } from './cadence.js';
@@ -61,11 +61,11 @@ export const BLOBS: Record<string, LoopBlob> = {
61
61
  "model-resolver": {
62
62
  name: "model-resolver",
63
63
  version: "1.0.0",
64
- contentHash: "dd4020b613dc3814aaaf5c6a07a82bff844680f3be43d2943754f46b0b1bea3c",
64
+ contentHash: "e82ac2137279537f5b65725cbd8de5817fcbc89571068e2df843587352fa83f5",
65
65
  sourcePath: "packages/@dzhechkov/harness-core/src/feature-adr-routing.ts",
66
66
  requires: [],
67
67
  exports: ["specToOpts","resolveStageModel","KNOWN_CODEX","mergeOpts","stageLabel","modelLabel"],
68
- code: "const OVERRIDE_REASONING = {\n router: 'high',\n requirements: 'xhigh',\n research: 'xhigh',\n adr: 'xhigh',\n ideation: 'xhigh',\n ddd: 'xhigh',\n architecture: 'xhigh',\n plan: 'xhigh',\n code: 'xhigh',\n qe: 'high',\n fleet: 'high',\n};\nfunction topCodexId(env) {\n let top = env.CODEX_MODEL;\n if (top === 'auto') {\n const ids = Object.keys(KNOWN_CODEX);\n for (let i = 0; i < ids.length; i++) {\n if (ids[i] !== 'auto')\n top = ids[i] || top;\n }\n }\n return top;\n}\nconst KNOWN_CODEX = { auto: 1, 'gpt-5.5': 1, 'gpt-5.6': 1, 'gpt-5.6-sol': 1 };\nconst CLAUDE_NAMES = { fable: 1, opus: 1, sonnet: 1, haiku: 1 };\nconst VALID_REASONING = { none: 1, minimal: 1, low: 1, medium: 1, high: 1, xhigh: 1 };\nconst DEFAULT_MODELS = {\n router: 'fable',\n requirements: 'sonnet',\n research: 'sonnet',\n adr: 'opus',\n ideation: 'sonnet',\n ddd: 'opus',\n architecture: 'opus',\n plan: 'sonnet',\n code: null,\n qe: null,\n fleet: 'sonnet',\n};\nfunction specToOpts(spec, env) {\n const log = env.log || function () { };\n if (!spec)\n return {};\n const parts = String(spec).split(':');\n const head = parts[0] || '';\n if (head === 'codex') {\n let id = parts[1] || env.CODEX_MODEL;\n if (id !== 'auto' && !KNOWN_CODEX[id]) {\n log('models: unknown codex id ' + id + ' — using ' + env.CODEX_MODEL);\n id = env.CODEX_MODEL;\n }\n let reasoning = parts[2] || 'high';\n if (!VALID_REASONING[reasoning]) {\n log('models: unknown reasoning ' + reasoning + ' — using high');\n reasoning = 'high';\n }\n return { agentType: 'codex:codex-rescue', codexModel: id, _reasoning: reasoning };\n }\n if (CLAUDE_NAMES[head])\n return { model: head };\n log('models: unknown spec ' + spec + ' — session-inherited');\n return {};\n}\nfunction resolveCoderSpec(env) {\n if (env.CODER === 'codex' || env.CODER === 'codex-fallback')\n return 'codex:' + env.CODEX_MODEL + ':high';\n return 'opus';\n}\nfunction coderIsCodex(env) {\n if (env.CODER === 'codex' || env.CODER === 'codex-fallback')\n return true;\n const codeSpec = env.MODELS.code;\n if (codeSpec && String(codeSpec).split(':')[0] === 'codex')\n return true;\n return false;\n}\nfunction resolveQeSpec(env) {\n if (coderIsCodex(env))\n return 'opus';\n const CODEX_AVAILABLE = env.codexAvailable !== false;\n if (!CODEX_AVAILABLE)\n return 'opus';\n return 'codex:' + topCodexId(env) + ':high';\n}\nfunction routingRequested(env) {\n return (Object.keys(env.MODELS).length > 0 ||\n env.PLANNER === 'codex' ||\n env.CODER === 'codex' ||\n env.CODER === 'codex-fallback' ||\n env.QE_REVIEWER === 'codex' ||\n env.QE_REVIEWER === 'codex-fallback');\n}\nfunction resolveStageModel(stage, env) {\n if (env.usageOverride) {\n const r = (env.usageReasoning && env.usageReasoning[stage]) || OVERRIDE_REASONING[stage] || 'high';\n const o = specToOpts('codex:' + topCodexId(env) + ':' + r, env);\n o._usageSwitched = true;\n return o;\n }\n let spec = env.MODELS[stage];\n if (spec === undefined) {\n if (!routingRequested(env))\n return {};\n spec = DEFAULT_MODELS[stage];\n }\n if (stage === 'code' && (spec === null || spec === undefined))\n return specToOpts(resolveCoderSpec(env), env);\n if (stage === 'qe' && (spec === null || spec === undefined))\n return specToOpts(resolveQeSpec(env), env);\n return specToOpts(spec, env);\n}\nfunction modelLabel(opts) {\n if (opts && opts.agentType === 'codex:codex-rescue') {\n const base = 'codex:' + opts.codexModel + ':' + opts._reasoning;\n return opts._usageSwitched ? base + ' (usage-switched)' : base;\n }\n if (opts && opts.model)\n return opts.model;\n return 'session';\n}\nfunction stageLabel(base, opts) {\n const m = modelLabel(opts);\n return m === 'session' ? base : base + ' · ' + m;\n}\nfunction mergeOpts(base, extra) {\n const out = {};\n for (const k in base)\n out[k] = base[k];\n for (const k in extra)\n out[k] = extra[k];\n return out;\n}",
68
+ code: "const OVERRIDE_REASONING = {\n router: 'high',\n requirements: 'xhigh',\n research: 'xhigh',\n adr: 'xhigh',\n ideation: 'xhigh',\n ddd: 'xhigh',\n architecture: 'xhigh',\n plan: 'xhigh',\n code: 'xhigh',\n qe: 'high',\n fleet: 'high',\n};\nfunction topCodexId(env) {\n let top = env.CODEX_MODEL;\n if (top === 'auto') {\n const ids = Object.keys(KNOWN_CODEX);\n for (let i = 0; i < ids.length; i++) {\n if (ids[i] !== 'auto')\n top = ids[i] || top;\n }\n }\n return top;\n}\nconst KNOWN_CODEX = { auto: 1, 'gpt-5.5': 1, 'gpt-5.6': 1, 'gpt-5.6-luna': 1, 'gpt-5.6-terra': 1, 'gpt-5.6-sol': 1 };\nconst CLAUDE_NAMES = { fable: 1, opus: 1, sonnet: 1, haiku: 1 };\nconst VALID_REASONING = { none: 1, minimal: 1, low: 1, medium: 1, high: 1, xhigh: 1 };\nconst DEFAULT_MODELS = {\n router: 'fable',\n requirements: 'sonnet',\n research: 'sonnet',\n adr: 'opus',\n ideation: 'sonnet',\n ddd: 'opus',\n architecture: 'opus',\n plan: 'sonnet',\n code: null,\n qe: null,\n fleet: 'sonnet',\n};\nfunction specToOpts(spec, env) {\n const log = env.log || function () { };\n if (!spec)\n return {};\n const parts = String(spec).split(':');\n const head = parts[0] || '';\n if (head === 'codex') {\n let id = parts[1] || env.CODEX_MODEL;\n if (id !== 'auto' && !KNOWN_CODEX[id]) {\n log('models: unknown codex id ' + id + ' — using ' + env.CODEX_MODEL);\n id = env.CODEX_MODEL;\n }\n let reasoning = parts[2] || 'high';\n if (!VALID_REASONING[reasoning]) {\n log('models: unknown reasoning ' + reasoning + ' — using high');\n reasoning = 'high';\n }\n return { agentType: 'codex:codex-rescue', codexModel: id, _reasoning: reasoning };\n }\n if (CLAUDE_NAMES[head])\n return { model: head };\n log('models: unknown spec ' + spec + ' — session-inherited');\n return {};\n}\nfunction resolveCoderSpec(env) {\n if (env.CODER === 'codex' || env.CODER === 'codex-fallback')\n return 'codex:' + env.CODEX_MODEL + ':high';\n return 'opus';\n}\nfunction coderIsCodex(env) {\n if (env.CODER === 'codex' || env.CODER === 'codex-fallback')\n return true;\n const codeSpec = env.MODELS.code;\n if (codeSpec && String(codeSpec).split(':')[0] === 'codex')\n return true;\n return false;\n}\nfunction resolveQeSpec(env) {\n if (coderIsCodex(env))\n return 'opus';\n const CODEX_AVAILABLE = env.codexAvailable !== false;\n if (!CODEX_AVAILABLE)\n return 'opus';\n return 'codex:' + topCodexId(env) + ':high';\n}\nfunction routingRequested(env) {\n return (Object.keys(env.MODELS).length > 0 ||\n env.PLANNER === 'codex' ||\n env.CODER === 'codex' ||\n env.CODER === 'codex-fallback' ||\n env.QE_REVIEWER === 'codex' ||\n env.QE_REVIEWER === 'codex-fallback');\n}\nfunction resolveStageModel(stage, env) {\n if (env.usageOverride) {\n const r = (env.usageReasoning && env.usageReasoning[stage]) || OVERRIDE_REASONING[stage] || 'high';\n const o = specToOpts('codex:' + topCodexId(env) + ':' + r, env);\n o._usageSwitched = true;\n return o;\n }\n let spec = env.MODELS[stage];\n if (spec === undefined) {\n if (!routingRequested(env))\n return {};\n spec = DEFAULT_MODELS[stage];\n }\n if (stage === 'code' && (spec === null || spec === undefined))\n return specToOpts(resolveCoderSpec(env), env);\n if (stage === 'qe' && (spec === null || spec === undefined))\n return specToOpts(resolveQeSpec(env), env);\n return specToOpts(spec, env);\n}\nfunction modelLabel(opts) {\n if (opts && opts.agentType === 'codex:codex-rescue') {\n const base = 'codex:' + opts.codexModel + ':' + opts._reasoning;\n return opts._usageSwitched ? base + ' (usage-switched)' : base;\n }\n if (opts && opts.model)\n return opts.model;\n return 'session';\n}\nfunction stageLabel(base, opts) {\n const m = modelLabel(opts);\n return m === 'session' ? base : base + ' · ' + m;\n}\nfunction mergeOpts(base, extra) {\n const out = {};\n for (const k in base)\n out[k] = base[k];\n for (const k in extra)\n out[k] = extra[k];\n return out;\n}",
69
69
  },
70
70
  "usage-probes": {
71
71
  name: "usage-probes",
package/src/operations.ts CHANGED
@@ -196,7 +196,12 @@ function enrichEmitForTarget(
196
196
  `interface:`,
197
197
  ` display_name: "${name}"`,
198
198
  `policy:`,
199
- ` allow_implicit_invocation: ${risk.level === 'low' || risk.level === 'medium'}`,
199
+ // MEASURED (hermes research, codex.md §63, twin-test): codex PARSES this file and
200
+ // `allow_implicit_invocation: false` HIDES the skill from the session entirely — it is a
201
+ // visibility switch, not an ask-first switch. Risk-gating through it silently disappeared a
202
+ // compiled pack (the terraform smoke pack never registered, backlog 2b80420f). Visibility is
203
+ // therefore ALWAYS true; the risk score stays as INFORMATION for the operator below.
204
+ ` allow_implicit_invocation: true # false would HIDE the skill from codex entirely (measured); risk is informational, see risk_level`,
200
205
  ` risk_level: "${risk.level}"`,
201
206
  ` risk_score: ${risk.total.toFixed(2)}`,
202
207
  ` risk_axes:`,
@@ -835,24 +840,39 @@ export async function runDoctor(options: { projectRoot: string }): Promise<Docto
835
840
  const nodeMajor = Number(process.versions.node.split('.')[0] ?? '0');
836
841
  checks.push({ name: 'node >= 20', ok: nodeMajor >= 20, detail: `node ${process.version}` });
837
842
 
838
- // 2. Key directories
839
- for (const dir of ['.claude/skills', 'packages/@dzhechkov/skills-meta']) {
843
+ // 2/3. MONOREPO-ONLY checks, gated on PROJECT KIND (backlog fcf29728: in a consumer project
844
+ // skills-meta and the 10 adapters are not there and MUST not be — both checks were red forever
845
+ // and dz doctor could never exit 0 outside this repository, a standing false BLOCK for any
846
+ // consumer CI). Kind detection is structural: a checkout that carries packages/@dzhechkov IS the
847
+ // monorepo (or a fork of it) and owes itself these checks; anything else is a consumer project
848
+ // and gets a NAMED skip — a skip, never a silent pass and never a fail.
849
+ const isMonorepo = existsSync(join(root, 'packages', '@dzhechkov'));
850
+ checks.push({
851
+ name: '.claude/skills present',
852
+ ok: existsSync(join(root, '.claude', 'skills')),
853
+ detail: '.claude/skills',
854
+ });
855
+ if (isMonorepo) {
856
+ checks.push({
857
+ name: 'packages/@dzhechkov/skills-meta present',
858
+ ok: existsSync(join(root, 'packages/@dzhechkov/skills-meta')),
859
+ detail: 'packages/@dzhechkov/skills-meta',
860
+ });
861
+ const adapters = ['adapter-claude', 'adapter-codex', 'adapter-opencode', 'adapter-hermes', 'adapter-openclaude', 'adapter-copilot', 'adapter-agents-md', 'adapter-cursor', 'adapter-gemini', 'adapter-windsurf'];
862
+ const foundAdapters = adapters.filter((a) => existsSync(join(root, 'packages/@dzhechkov', a)));
863
+ checks.push({
864
+ name: 'adapters present',
865
+ ok: foundAdapters.length === adapters.length,
866
+ detail: `${foundAdapters.length}/${adapters.length} adapters found`,
867
+ });
868
+ } else {
840
869
  checks.push({
841
- name: `${dir} present`,
842
- ok: existsSync(join(root, dir)),
843
- detail: dir,
870
+ name: 'monorepo checks',
871
+ ok: true,
872
+ detail: 'consumer project (no packages/@dzhechkov) — skills-meta/adapter checks are the MONOREPO\'s own duty and are skipped here by kind, not by silence',
844
873
  });
845
874
  }
846
875
 
847
- // 3. Adapter resolvability (one per target platform)
848
- const adapters = ['adapter-claude', 'adapter-codex', 'adapter-opencode', 'adapter-hermes', 'adapter-openclaude', 'adapter-copilot', 'adapter-agents-md', 'adapter-cursor', 'adapter-gemini', 'adapter-windsurf'];
849
- const foundAdapters = adapters.filter((a) => existsSync(join(root, 'packages/@dzhechkov', a)));
850
- checks.push({
851
- name: 'adapters present',
852
- ok: foundAdapters.length === adapters.length,
853
- detail: `${foundAdapters.length}/${adapters.length} adapters found`,
854
- });
855
-
856
876
  // 4. Package version consistency
857
877
  const pkgsDir = join(root, 'packages/@dzhechkov');
858
878
  if (existsSync(pkgsDir)) {
@@ -937,10 +957,17 @@ export async function runDoctor(options: { projectRoot: string }): Promise<Docto
937
957
  const skillDirs = readdirSync(skillsDir, { withFileTypes: true })
938
958
  .filter((e) => e.isDirectory() && !e.name.startsWith('.'));
939
959
  const withSkillMd = skillDirs.filter((e) => existsSync(join(skillsDir, e.name, 'SKILL.md')));
960
+ // A visible dir with NO SKILL.md is almost never a broken skill — it is a FOREIGN directory
961
+ // (measured: a 102-file health-advisor/ residue from an old `ha init` read as «27/28», which a
962
+ // human parses as "one skill is broken" and goes fixing a skill; the true cure is cleanup).
963
+ // Name the offenders and say which treatment applies (HA-improvements 2026-08, b5ba7b4a).
964
+ const foreign = skillDirs.filter((e) => !existsSync(join(skillsDir, e.name, 'SKILL.md'))).map((e) => e.name);
940
965
  checks.push({
941
966
  name: 'skills health',
942
967
  ok: withSkillMd.length === skillDirs.length,
943
- detail: `${withSkillMd.length}/${skillDirs.length} skill dirs have SKILL.md`,
968
+ detail: foreign.length === 0
969
+ ? `${withSkillMd.length}/${skillDirs.length} skill dirs have SKILL.md`
970
+ : `${withSkillMd.length}/${skillDirs.length} skill dirs have SKILL.md — ${foreign.length} FOREIGN dir(s) in the skills root (not broken skills; the cure is cleanup, not repair): ${foreign.slice(0, 5).join(', ')}${foreign.length > 5 ? ', …' : ''}`,
944
971
  });
945
972
  }
946
973
 
@@ -1007,14 +1034,20 @@ export async function runDoctor(options: { projectRoot: string }): Promise<Docto
1007
1034
  const usageLog = join(root, '.dz', 'recall-usage.jsonl');
1008
1035
  const { newest, hasCodexRow } = newestRecallUsageRuntime(usageLog);
1009
1036
  const fresh = newest !== undefined && Date.now() - Date.parse(newest) < 14 * 24 * 60 * 60 * 1000;
1037
+ // In a CONSUMER project the machine-global hook is wired but a FRESH project has zero rows
1038
+ // by construction — dead-leg and new-project are indistinguishable there, and a permanent
1039
+ // red on arrival is a false CI block (fcf29728). The row degrades to an ADVISORY (ok:true,
1040
+ // wording intact) outside the monorepo; in the monorepo it stays the hard row that killed
1041
+ // the 19-day dark leg.
1042
+ const applyLegOk = hasCodexRow && fresh;
1010
1043
  checks.push({
1011
1044
  name: 'codex apply-leg (recall hook)',
1012
- ok: hasCodexRow && fresh,
1013
- detail: hasCodexRow
1045
+ ok: isMonorepo ? applyLegOk : true,
1046
+ detail: (isMonorepo || applyLegOk ? '' : 'advisory (consumer project — a fresh store has no rows by construction): ') + (hasCodexRow
1014
1047
  ? fresh
1015
1048
  ? `codex recall rows present, newest ${newest}`
1016
1049
  : `codex recall hook is WIRED but SILENT: newest recall-usage row is ${String(newest)} — the entry may have lost hook trust (re-run dz hooks-sync --target codex --verify)`
1017
- : 'codex recall hook is WIRED but has NEVER written a row — a dead leg looks exactly like a correctly-silent one, so this is reported non-OK until one lands',
1050
+ : 'codex recall hook is WIRED but has NEVER written a row — a dead leg looks exactly like a correctly-silent one, so this is reported non-OK until one lands'),
1018
1051
  });
1019
1052
  }
1020
1053
  }
package/src/provenance.ts CHANGED
@@ -25,6 +25,12 @@ export type SourceVerdict =
25
25
  | 'no-source'
26
26
  /** The manifest did not declare what kind of source this is — never inferred from its shape. */
27
27
  | 'unknown-kind'
28
+ /** A PUBLIC external web URL (http/https). It is already public by construction, so it cannot
29
+ * "leave this machine" — nothing local to protect. Refused only if the URL is malformed. */
30
+ | 'public-url'
31
+ /** A `url` claim whose value is not a well-formed http(s) URL — a scheme this gate will not clear
32
+ * (a file://, a bare word, or a non-URL) must not pass as a public web source. */
33
+ | 'malformed-url'
28
34
  /** A store record that the TRACKED public list does not name. Default-deny. */
29
35
  | 'not-marked-public'
30
36
  /** The path does not resolve. You cannot cite what does not exist. */
@@ -164,6 +170,18 @@ export function classifySource(claim: SourceClaim, facts: SourceProvenanceFacts)
164
170
  return at('allowed', 'committed, reviewed, and not refused by the owner\'s boundary');
165
171
  }
166
172
 
173
+ if (claim.kind === 'url') {
174
+ // The channel translates OTHERS' public tweets/posts; their sources are PUBLIC web URLs. Such a
175
+ // URL is already public — it cannot leak off this machine, so there is no local secret to
176
+ // protect (the whole point of the path/record checks). It is cleared iff it is a well-formed
177
+ // http(s) URL; anything else (file://, a bare path, a non-URL) is refused, never inferred.
178
+ let ok = false;
179
+ try { const u = new URL(source); ok = u.protocol === 'http:' || u.protocol === 'https:'; } catch { ok = false; }
180
+ return ok
181
+ ? at('public-url', 'a public http(s) web source — already public, nothing local to protect')
182
+ : at('malformed-url', 'kind "url" but the value is not a well-formed http(s) URL — a public web source must be a real http(s) URL');
183
+ }
184
+
167
185
  return at('unknown-kind', `the manifest declares kind ${JSON.stringify(claim.kind ?? null)} — a kind this gate cannot check is refused, never inferred from the path's shape`);
168
186
  }
169
187
 
@@ -187,7 +205,11 @@ export function decideSourceProvenance(manifest: SourceManifest | null, facts: S
187
205
  return { outcome: 'not-established', exit: 3, claims: [], reason: 'the manifest lists no claims — a draft with nothing to check has not been shown to be safe, only left unchecked' };
188
206
  }
189
207
  const claims = manifest.claims.map((c) => classifySource(c, facts));
190
- const blocked = claims.filter((c) => c.verdict !== 'allowed');
208
+ // A claim passes iff its verdict is a CLEARED one: a repo-internal source proven safe (allowed),
209
+ // or a public web URL that is already public by construction (public-url — the tg-post channel
210
+ // case). Every other verdict is a refusal.
211
+ const CLEARED = new Set(['allowed', 'public-url']);
212
+ const blocked = claims.filter((c) => !CLEARED.has(c.verdict));
191
213
  if (blocked.length > 0) {
192
214
  return {
193
215
  outcome: 'blocked',