wicked-core-ts 0.7.3 → 0.7.5

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 -5
  2. package/package.json +8 -7
package/index.d.ts CHANGED
@@ -311,10 +311,53 @@ export declare class Core {
311
311
  recallKnowledge(query: string, k: number): Promise<string>
312
312
  /** All registered governance policies, as a JSON array of `Policy` objects. */
313
313
  listPolicies(): Promise<string>
314
- /** All conformance rules on the store (Pattern + Policy types), as a JSON array. */
315
- listConformanceRules(): Promise<string>
314
+ /**
315
+ * All conformance rules on the store (Pattern + Policy types), as a JSON array of
316
+ * serialized `ConformanceRule` objects — severity-first (critical→info), then weight DESC
317
+ * within a band, then id. The rows carry the unified steering-rule model's fields
318
+ * (steering_type / applies_to / excludes / weight / effect / trigger / obligations /
319
+ * criteria / provenance / …) exactly as the model serializes them — default-valued steering
320
+ * fields are elided on the wire (absent steering_type ⇒ "architecture", absent weight ⇒ 1).
321
+ *
322
+ * Steering facets (the studio Steering surface's list):
323
+ * - `steeringType` filters on the rule's `steering_type` — one of architecture | development |
324
+ * security | testing | operations | compliance | design-ux. A rule authored before the
325
+ * field existed counts as `"architecture"` (the model's serde default); an unknown value
326
+ * REJECTS (fails closed — a typo must not read as "no rules of that type").
327
+ * - `includeRetired: true` adds withdrawn rules (retire-not-delete: they still explain the
328
+ * past decisions that cite them; recall/enforcement never returns them).
329
+ *
330
+ * Both omitted ⇒ the exact pre-0.7.5 behavior (every active rule).
331
+ */
332
+ listConformanceRules(steeringType?: string | undefined | null, includeRetired?: boolean | undefined | null): Promise<string>
333
+ /**
334
+ * The doctrine RuleSet parents (AW-13 grouping) as a JSON array of
335
+ * `{ domain, rule_ids, rule_count }` rows, domain-sorted. The array length is the wiki
336
+ * meta's `ruleset_count` (crew's `countRuleSets` resolved `null` on engine builds without
337
+ * this binding — "cannot count" must never impersonate "0"); the rows carry `Contains`
338
+ * membership so grouping renders without a second round-trip. Membership is the store's
339
+ * edges verbatim — a retired rule stays listed in its RuleSet (grouping is doc structure,
340
+ * not enforcement). Read-only connection; never blocks the single-writer actor.
341
+ */
342
+ listRuleSets(): Promise<string>
316
343
  /** All conformance claims (governance decisions) on the store, as a JSON array. */
317
344
  listConformanceClaims(): Promise<string>
345
+ /**
346
+ * The AW-23 / arch-R23 population/connection scoreboard — the wiki-health report that tells
347
+ * a POPULATED rule corpus from an ingested-once-and-decaying one: rule counts, typing
348
+ * coverage, connection (ref-resolution) coverage, enforcement evidence, recall volume.
349
+ * Resolves to the SAME JSON `wicked-core rules scoreboard --json` emits (a pretty-printed
350
+ * `Scoreboard` object) — one report shape for CLI operators and crew/studio consumers alike.
351
+ *
352
+ * `docsDir` mirrors the CLI's `--dir`: typing coverage is doc-side (`enforcement_class`
353
+ * lives in frontmatter, never on the rule node), so it needs the SAME docs root
354
+ * `rules ingest --dir` used; omit it and the report says `typing.available: false`,
355
+ * honestly, in-band — never a fake 0% or 100%. `ambiguityCap` mirrors `--ambiguity-cap`
356
+ * (default 5; must be ≥ 1 — fails closed on 0, like the CLI). Strictly a REPORT over a
357
+ * read-only connection: it never blocks the single-writer actor, and residue gating stays
358
+ * `rules drift`'s job.
359
+ */
360
+ governanceScoreboard(docsDir?: string | undefined | null, ambiguityCap?: number | undefined | null): Promise<string>
318
361
  /**
319
362
  * Upsert a governance policy. `policy_json` is a JSON-serialized `Policy` object
320
363
  * (fields: id, kind, applies_to, effect, trigger, severity, criteria, rule, obligations).
@@ -324,10 +367,77 @@ export declare class Core {
324
367
  upsertPolicy(policyJson: string): Promise<string>
325
368
  /**
326
369
  * Upsert a conformance rule. `rule_json` is a JSON-serialized `ConformanceRule` object
327
- * (fields: id, rule_type, statement, severity, confidence, targets, provenance).
328
- * Validates server-side (INV-C1/C2/C4). Idempotent on stable id.
370
+ * (fields: id, rule_type, statement, severity, confidence, targets, provenance — plus the
371
+ * unified steering-rule fields: steering_type, applies_to, excludes, weight, and the
372
+ * optional effect / trigger / obligations / criteria; a rule without `effect` stays
373
+ * recall-only). The JSON passes through un-projected — the model's own serde is the wire
374
+ * contract, so new steering fields ride this binding without a rebuild. Provenance is
375
+ * first-class for UI/chat-authored rules too (`provenance.source: "ui" | "chat"`), not just
376
+ * doc-ingested `path@sha#id` rows. Validates server-side (INV-C1/C2/C4). Idempotent on
377
+ * stable id.
329
378
  */
330
379
  upsertConformanceRule(ruleJson: string): Promise<string>
380
+ /**
381
+ * STEERING batch import (the unified steering-rule model). `batch_json` is a JSON
382
+ * `{ default_type: string | null, entries: [...] }` document where each entry is either a
383
+ * frontmattered markdown doc (`{ kind: "doc", name?, content }` — parsed by the SAME
384
+ * MarkdownAdapter/normalize path `rules ingest --dir` runs, provenance `path@sha#id` refs
385
+ * included) or a ready rule object (`{ kind: "rule", rule }` — the rule JSON passes to the
386
+ * upsert path un-projected, so new model fields ride through without a rebuild).
387
+ * `default_type` is applied as the `steering_type` of every rule whose entry omits one; a
388
+ * rule that names its own type keeps it.
389
+ *
390
+ * Fail-closed PER ENTRY: a bad entry (unparseable doc, invalid rule, INV violation,
391
+ * duplicate id within the batch) rejects ALONE with its reason — the rest still land; only
392
+ * a malformed batch envelope rejects the whole call. Every write goes through the
393
+ * single-writer actor (validate + `register_rule`). Resolves to a JSON array of per-entry
394
+ * results, batch order: `{ index, name?, status: "imported" | "rejected", ids?, error? }`
395
+ * (`ids` = the rule ids the entry minted — a doc can mint several; a rejected entry mints
396
+ * none). This binding is also crew's PRESENCE SENTINEL for the whole steering seam
397
+ * (`steeringSupported()`): it ships with the unified model, so its existence tells crew the
398
+ * engine round-trips the steering fields instead of silently dropping them.
399
+ */
400
+ steeringImport(batchJson: string): Promise<string>
401
+ /**
402
+ * Governance rules eval — run an eval corpus through the REAL SELECT→DECIDE gate path and
403
+ * score every sample (the engine seam behind crew's `POST /api/v1/testing/evals/run`).
404
+ * `args_json` is `{ type?, corpus?, knowledgeDb?, dbPath }` (camelCase keys are the PINNED
405
+ * binding contract): `type` slices the corpus to one of the 7 steering types; `corpus`
406
+ * names an estate knowledge scope (`evals:<name>` — a corpus landed by
407
+ * [`Core::governance_corpus_import`]) or, omitted, selects the compiled-in default corpus;
408
+ * `knowledgeDb` powers embedding gap hints (absent/unusable ⇒ the report carries
409
+ * `degraded: "facet-only"` — an honest downgrade to keyword hints, never fabricated
410
+ * similarity); `dbPath` is the rules store, opened READ-ONLY — this call never goes through
411
+ * the single-writer actor and never writes either store.
412
+ *
413
+ * Resolves to the `EvalReport` JSON exactly as the engine serializes it (snake_case — crew
414
+ * passes it through verbatim as the pinned wire contract):
415
+ * `{ results: [{ sample: { id, description, kind, steering_type }, expected: "deny"|"allow",
416
+ * fired: [rule-id…], verdict: "caught"|"gap"|"false_positive", nearest_rules? }],
417
+ * summary: { total, caught, gaps, false_positives }, degraded: "facet-only"|null }`.
418
+ *
419
+ * Fail-closed: malformed args, an unknown steering type, a corpus name outside the
420
+ * `evals:` scope, or a missing store reject the Promise with the engine's reason — crew maps
421
+ * those to 400, and gates the whole route on this binding's PRESENCE (absent ⇒ 501).
422
+ */
423
+ governanceEvals(argsJson: string): Promise<string>
424
+ /**
425
+ * Import an eval corpus into the estate knowledge store (the engine seam behind crew's
426
+ * `POST /api/v1/testing/corpora/import`). `args_json` is `{ name, samples, knowledgeDb? }`
427
+ * (camelCase keys are the PINNED binding contract): `samples` is an array of
428
+ * `{ id, description, kind: "good"|"bad", steering_type, signals: { phase?, tool?, files?,
429
+ * content? } }` — validated fail-closed as a whole corpus (blank/duplicate ids, unknown
430
+ * steering types reject the batch) and landed under scope `evals:<name>`, one chunk per
431
+ * sample, id-keyed (re-import upserts in place) WITH embeddings via the same
432
+ * `KnowledgeEngine` path the rules fan-out uses. `knowledgeDb` defaults to the operator's
433
+ * `~/.wicked-estate/knowledge.db`; tests must always pass a temp path.
434
+ *
435
+ * Resolves to the `ImportReceipt` JSON `{ imported, scope: "evals:<name>", embedded }` —
436
+ * `embedded` is VERIFIED against the durable store after the write handle drops, not
437
+ * asserted. Fail-closed on malformed args (crew maps that to 400; route presence-gates on
438
+ * this binding like [`Core::governance_evals`] — absent ⇒ 501).
439
+ */
440
+ governanceCorpusImport(argsJson: string): Promise<string>
331
441
  /**
332
442
  * Withdraw a governance policy from enforcement (FINDING-038 — governance state was otherwise
333
443
  * append-only, so a mis-authored policy denied forever).
@@ -367,7 +477,8 @@ export declare class Core {
367
477
  registerWorkflow(json: string): Promise<string>
368
478
  /**
369
479
  * Recall which conformance rules apply to the given `query_json` (a JSON-serialized
370
- * `RuleQuery` — fields: language, layer, framework, severity, rule_type; all optional).
480
+ * `RuleQuery` — fields: language, layer, framework, severity, rule_type, steering_type;
481
+ * all optional).
371
482
  * An empty or whitespace `query_json` is treated as an all-rules query (no facet filters).
372
483
  * Opens a read-only connection — does not block the single-writer actor. Returns a JSON
373
484
  * 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.3",
3
+ "version": "0.7.5",
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.3",
45
- "wicked-core-ts-darwin-x64": "0.7.3",
46
- "wicked-core-ts-linux-arm64-gnu": "0.7.3",
47
- "wicked-core-ts-linux-x64-gnu": "0.7.3",
48
- "wicked-core-ts-win32-x64-msvc": "0.7.3"
45
+ "wicked-core-ts-darwin-arm64": "0.7.5",
46
+ "wicked-core-ts-darwin-x64": "0.7.5",
47
+ "wicked-core-ts-linux-arm64-gnu": "0.7.5",
48
+ "wicked-core-ts-linux-x64-gnu": "0.7.5",
49
+ "wicked-core-ts-win32-x64-msvc": "0.7.5"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@napi-rs/cli": "^2.18.4"