wicked-core-ts 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 (2) hide show
  1. package/index.d.ts +116 -6
  2. package/package.json +8 -7
package/index.d.ts CHANGED
@@ -211,8 +211,23 @@ export declare class Core {
211
211
  * a UI builds its project list from).
212
212
  */
213
213
  sessionsDetail(): Promise<string>
214
- /** A unit's captured work output (transcript), as a JSON value — a string, or `null` if none. */
214
+ /**
215
+ * A unit's captured work output (transcript), as a JSON value — a string, or `null` if none.
216
+ * A REJECTED unit answers with whatever PARTIAL output existed at rejection (usability review
217
+ * #1) — the unit record's `status`/`denial` marks it partial; `null` only when no output was
218
+ * ever stored (never ran, or denied before any output existed — see `unitTranscript`).
219
+ */
215
220
  workOutput(unitId: string): Promise<string>
221
+ /**
222
+ * A unit's full transcript RECORD (usability review #1), as a JSON object — or `null` when the
223
+ * unit never ran far enough to leave one. Shape: `{ unit_id, resolution: "resolved"|"rejected",
224
+ * partial: bool, phase_status?, output?, denial_reason?, denial? }` where `denial` is
225
+ * `{ source, reason, claim_id?, rule_ids?, denied_tool?, phase? }`. A rejected unit keeps its
226
+ * PARTIAL output here, flagged; a unit denied BEFORE any output existed answers with an
227
+ * explicit failure record (`output` absent, `denial` carrying the claim id / firing rule ids /
228
+ * denied tool) instead of `null`.
229
+ */
230
+ unitTranscript(unitId: string): Promise<string>
216
231
  /**
217
232
  * A run's recorded event history, oldest first, as a JSON array. Each entry is the SAME tagged
218
233
  * object the `/ws` stream carries ([`CoreEvent::to_json`]) plus a capture-time `ts` (epoch millis)
@@ -311,8 +326,35 @@ export declare class Core {
311
326
  recallKnowledge(query: string, k: number): Promise<string>
312
327
  /** All registered governance policies, as a JSON array of `Policy` objects. */
313
328
  listPolicies(): Promise<string>
314
- /** All conformance rules on the store (Pattern + Policy types), as a JSON array. */
315
- listConformanceRules(): Promise<string>
329
+ /**
330
+ * All conformance rules on the store (Pattern + Policy types), as a JSON array of
331
+ * serialized `ConformanceRule` objects — severity-first (critical→info), then weight DESC
332
+ * within a band, then id. The rows carry the unified steering-rule model's fields
333
+ * (steering_type / applies_to / excludes / weight / effect / trigger / obligations /
334
+ * criteria / provenance / …) exactly as the model serializes them — default-valued steering
335
+ * fields are elided on the wire (absent steering_type ⇒ "architecture", absent weight ⇒ 1).
336
+ *
337
+ * Steering facets (the studio Steering surface's list):
338
+ * - `steeringType` filters on the rule's `steering_type` — one of architecture | development |
339
+ * security | testing | operations | compliance | design-ux. A rule authored before the
340
+ * field existed counts as `"architecture"` (the model's serde default); an unknown value
341
+ * REJECTS (fails closed — a typo must not read as "no rules of that type").
342
+ * - `includeRetired: true` adds withdrawn rules (retire-not-delete: they still explain the
343
+ * past decisions that cite them; recall/enforcement never returns them).
344
+ *
345
+ * Both omitted ⇒ the exact pre-0.7.5 behavior (every active rule).
346
+ */
347
+ listConformanceRules(steeringType?: string | undefined | null, includeRetired?: boolean | undefined | null): Promise<string>
348
+ /**
349
+ * The doctrine RuleSet parents (AW-13 grouping) as a JSON array of
350
+ * `{ domain, rule_ids, rule_count }` rows, domain-sorted. The array length is the wiki
351
+ * meta's `ruleset_count` (crew's `countRuleSets` resolved `null` on engine builds without
352
+ * this binding — "cannot count" must never impersonate "0"); the rows carry `Contains`
353
+ * membership so grouping renders without a second round-trip. Membership is the store's
354
+ * edges verbatim — a retired rule stays listed in its RuleSet (grouping is doc structure,
355
+ * not enforcement). Read-only connection; never blocks the single-writer actor.
356
+ */
357
+ listRuleSets(): Promise<string>
316
358
  /** All conformance claims (governance decisions) on the store, as a JSON array. */
317
359
  listConformanceClaims(): Promise<string>
318
360
  /**
@@ -340,10 +382,77 @@ export declare class Core {
340
382
  upsertPolicy(policyJson: string): Promise<string>
341
383
  /**
342
384
  * Upsert a conformance rule. `rule_json` is a JSON-serialized `ConformanceRule` object
343
- * (fields: id, rule_type, statement, severity, confidence, targets, provenance).
344
- * Validates server-side (INV-C1/C2/C4). Idempotent on stable id.
385
+ * (fields: id, rule_type, statement, severity, confidence, targets, provenance — plus the
386
+ * unified steering-rule fields: steering_type, applies_to, excludes, weight, and the
387
+ * optional effect / trigger / obligations / criteria; a rule without `effect` stays
388
+ * recall-only). The JSON passes through un-projected — the model's own serde is the wire
389
+ * contract, so new steering fields ride this binding without a rebuild. Provenance is
390
+ * first-class for UI/chat-authored rules too (`provenance.source: "ui" | "chat"`), not just
391
+ * doc-ingested `path@sha#id` rows. Validates server-side (INV-C1/C2/C4). Idempotent on
392
+ * stable id.
345
393
  */
346
394
  upsertConformanceRule(ruleJson: string): Promise<string>
395
+ /**
396
+ * STEERING batch import (the unified steering-rule model). `batch_json` is a JSON
397
+ * `{ default_type: string | null, entries: [...] }` document where each entry is either a
398
+ * frontmattered markdown doc (`{ kind: "doc", name?, content }` — parsed by the SAME
399
+ * MarkdownAdapter/normalize path `rules ingest --dir` runs, provenance `path@sha#id` refs
400
+ * included) or a ready rule object (`{ kind: "rule", rule }` — the rule JSON passes to the
401
+ * upsert path un-projected, so new model fields ride through without a rebuild).
402
+ * `default_type` is applied as the `steering_type` of every rule whose entry omits one; a
403
+ * rule that names its own type keeps it.
404
+ *
405
+ * Fail-closed PER ENTRY: a bad entry (unparseable doc, invalid rule, INV violation,
406
+ * duplicate id within the batch) rejects ALONE with its reason — the rest still land; only
407
+ * a malformed batch envelope rejects the whole call. Every write goes through the
408
+ * single-writer actor (validate + `register_rule`). Resolves to a JSON array of per-entry
409
+ * results, batch order: `{ index, name?, status: "imported" | "rejected", ids?, error? }`
410
+ * (`ids` = the rule ids the entry minted — a doc can mint several; a rejected entry mints
411
+ * none). This binding is also crew's PRESENCE SENTINEL for the whole steering seam
412
+ * (`steeringSupported()`): it ships with the unified model, so its existence tells crew the
413
+ * engine round-trips the steering fields instead of silently dropping them.
414
+ */
415
+ steeringImport(batchJson: string): Promise<string>
416
+ /**
417
+ * Governance rules eval — run an eval corpus through the REAL SELECT→DECIDE gate path and
418
+ * score every sample (the engine seam behind crew's `POST /api/v1/testing/evals/run`).
419
+ * `args_json` is `{ type?, corpus?, knowledgeDb?, dbPath }` (camelCase keys are the PINNED
420
+ * binding contract): `type` slices the corpus to one of the 7 steering types; `corpus`
421
+ * names an estate knowledge scope (`evals:<name>` — a corpus landed by
422
+ * [`Core::governance_corpus_import`]) or, omitted, selects the compiled-in default corpus;
423
+ * `knowledgeDb` powers embedding gap hints (absent/unusable ⇒ the report carries
424
+ * `degraded: "facet-only"` — an honest downgrade to keyword hints, never fabricated
425
+ * similarity); `dbPath` is the rules store, opened READ-ONLY — this call never goes through
426
+ * the single-writer actor and never writes either store.
427
+ *
428
+ * Resolves to the `EvalReport` JSON exactly as the engine serializes it (snake_case — crew
429
+ * passes it through verbatim as the pinned wire contract):
430
+ * `{ results: [{ sample: { id, description, kind, steering_type }, expected: "deny"|"allow",
431
+ * fired: [rule-id…], verdict: "caught"|"gap"|"false_positive", nearest_rules? }],
432
+ * summary: { total, caught, gaps, false_positives }, degraded: "facet-only"|null }`.
433
+ *
434
+ * Fail-closed: malformed args, an unknown steering type, a corpus name outside the
435
+ * `evals:` scope, or a missing store reject the Promise with the engine's reason — crew maps
436
+ * those to 400, and gates the whole route on this binding's PRESENCE (absent ⇒ 501).
437
+ */
438
+ governanceEvals(argsJson: string): Promise<string>
439
+ /**
440
+ * Import an eval corpus into the estate knowledge store (the engine seam behind crew's
441
+ * `POST /api/v1/testing/corpora/import`). `args_json` is `{ name, samples, knowledgeDb? }`
442
+ * (camelCase keys are the PINNED binding contract): `samples` is an array of
443
+ * `{ id, description, kind: "good"|"bad", steering_type, signals: { phase?, tool?, files?,
444
+ * content? } }` — validated fail-closed as a whole corpus (blank/duplicate ids, unknown
445
+ * steering types reject the batch) and landed under scope `evals:<name>`, one chunk per
446
+ * sample, id-keyed (re-import upserts in place) WITH embeddings via the same
447
+ * `KnowledgeEngine` path the rules fan-out uses. `knowledgeDb` defaults to the operator's
448
+ * `~/.wicked-estate/knowledge.db`; tests must always pass a temp path.
449
+ *
450
+ * Resolves to the `ImportReceipt` JSON `{ imported, scope: "evals:<name>", embedded }` —
451
+ * `embedded` is VERIFIED against the durable store after the write handle drops, not
452
+ * asserted. Fail-closed on malformed args (crew maps that to 400; route presence-gates on
453
+ * this binding like [`Core::governance_evals`] — absent ⇒ 501).
454
+ */
455
+ governanceCorpusImport(argsJson: string): Promise<string>
347
456
  /**
348
457
  * Withdraw a governance policy from enforcement (FINDING-038 — governance state was otherwise
349
458
  * append-only, so a mis-authored policy denied forever).
@@ -383,7 +492,8 @@ export declare class Core {
383
492
  registerWorkflow(json: string): Promise<string>
384
493
  /**
385
494
  * Recall which conformance rules apply to the given `query_json` (a JSON-serialized
386
- * `RuleQuery` — fields: language, layer, framework, severity, rule_type; all optional).
495
+ * `RuleQuery` — fields: language, layer, framework, severity, rule_type, steering_type;
496
+ * all optional).
387
497
  * An empty or whitespace `query_json` is treated as an all-rules query (no facet filters).
388
498
  * Opens a read-only connection — does not block the single-writer actor. Returns a JSON
389
499
  * array of `ConformanceRule` objects, severity-first then id.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-core-ts",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Node/TypeScript bindings (napi-rs) for wicked-core: drive the in-process orchestration engine from JS/TS.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,14 +38,15 @@
38
38
  "smoke": "node smoke.mjs",
39
39
  "smoke:lifecycle": "node smoke-lifecycle.mjs",
40
40
  "smoke:terminal": "node smoke-terminal.mjs",
41
- "smoke:all": "node smoke.mjs && node smoke-lifecycle.mjs && node smoke-terminal.mjs"
41
+ "smoke:evals": "node smoke-evals.mjs",
42
+ "smoke:all": "node smoke.mjs && node smoke-lifecycle.mjs && node smoke-terminal.mjs && node smoke-evals.mjs"
42
43
  },
43
44
  "optionalDependencies": {
44
- "wicked-core-ts-darwin-arm64": "0.7.4",
45
- "wicked-core-ts-darwin-x64": "0.7.4",
46
- "wicked-core-ts-linux-arm64-gnu": "0.7.4",
47
- "wicked-core-ts-linux-x64-gnu": "0.7.4",
48
- "wicked-core-ts-win32-x64-msvc": "0.7.4"
45
+ "wicked-core-ts-darwin-arm64": "0.7.6",
46
+ "wicked-core-ts-darwin-x64": "0.7.6",
47
+ "wicked-core-ts-linux-arm64-gnu": "0.7.6",
48
+ "wicked-core-ts-linux-x64-gnu": "0.7.6",
49
+ "wicked-core-ts-win32-x64-msvc": "0.7.6"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@napi-rs/cli": "^2.18.4"