@shiftleftpt/sbd-toe-mcp 0.10.1 → 0.20.0-beta.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.
@@ -29,6 +29,32 @@
29
29
  import type { Affordance } from "../serving/protocol-envelope.js";
30
30
  export type CodegenMode = "codegen" | "review" | "test-plan";
31
31
  export type RiskLevel = "L1" | "L2" | "L3";
32
+ /**
33
+ * Response ENCODING level (v2 token diet, epic v2-token-diet slice s1).
34
+ *
35
+ * - `full` (default): classic payload, byte-identical to previous releases —
36
+ * whether `detail` is omitted or explicitly "full".
37
+ * - `standard` / `minimal`: same citable ID set, deduplicated encoding
38
+ * (inverted `citations`, grouped `manual_grounding`, top-level
39
+ * `provenance_legend` instead of per-item `source`). No information is
40
+ * lost — only the serialization changes. Since s3b (revised ADENDA
41
+ * 2026-07-05 — no top-N/subsetting) `minimal` differs from `standard`
42
+ * ONLY in traceability serialization: evidence cap 10→5 and the minimal
43
+ * `manual_grounding` form; the activated scope stays complete and
44
+ * byte-identical to `standard`.
45
+ * - `ultrathin` (s3c, reactivated by the operator 2026-07-05): one level below
46
+ * `minimal`, same rules (COMPLETE activated set, no top-k, nothing id-only,
47
+ * never silent) but requirements/controls WITHOUT the published
48
+ * `description` (executable `descriptions_ref` → detail="minimal"),
49
+ * evidence_patterns 0 inline (counts + rest-ref → detail="minimal"),
50
+ * `manual_grounding` reduced to {total_entries, manual_commit_sha,
51
+ * groups_ref} and `completeness_report` diagnostics trimmed to exact counts
52
+ * (+ executable ref). Citable ID set unchanged (invariant 3).
53
+ *
54
+ * The default flips to `standard` only at graduation to the next stable
55
+ * release (documented as breaking) — never on the beta line.
56
+ */
57
+ export type CodegenDetailLevel = "ultrathin" | "minimal" | "standard" | "full";
32
58
  export interface PrepareCodegenContextInput {
33
59
  task: string;
34
60
  risk_level?: RiskLevel;
@@ -40,6 +66,15 @@ export interface PrepareCodegenContextInput {
40
66
  changed_files?: string[];
41
67
  regulatory_frameworks?: string[];
42
68
  include_regulatory_overlay?: boolean;
69
+ detail?: CodegenDetailLevel;
70
+ /**
71
+ * v2 token diet, s2 — escape hatch for clients that cannot make a second
72
+ * call: when true, `detail: "standard" | "minimal"` keeps `g2_context.relations`
73
+ * inline (dieted: no per-item `source`) instead of `relations_ref`.
74
+ * Ignored at `detail: "full"` (full is always byte-identical to the classic
75
+ * payload, relations inline).
76
+ */
77
+ include_relations?: boolean;
43
78
  debug?: boolean;
44
79
  }
45
80
  export type PrepareCodegenStatus = "ready_for_codegen" | "needs_clarification" | "needs_decomposition" | "unsupported_scope";
@@ -261,9 +296,538 @@ export interface PrepareCodegenContextResultBlocked {
261
296
  notes: string[];
262
297
  };
263
298
  }
264
- export type PrepareCodegenContextResult = PrepareCodegenContextResultReady | PrepareCodegenContextResultBlocked;
299
+ /** An item shape with the repeated per-item `source` field removed (the
300
+ * provenance is carried once, in `provenance_legend`). */
301
+ export type WithoutSource<T> = Omit<T, "source">;
302
+ /**
303
+ * Inverted citation encoding (replaces `citation_map` in `standard`/`minimal`).
304
+ * Grouped by source; `source_data` is an ORDERED run-length map
305
+ * `file → count`: the first N₁ citable ids come from the first file, the
306
+ * next N₂ from the second, and so on. This preserves the exact per-id
307
+ * `{source, source_data}` of the classic `citation_map` with zero repetition.
308
+ *
309
+ * s3: the ids themselves are NOT repeated when they already appear verbatim in
310
+ * a payload section — `ids_from` lists, aligned 1:1 with the `source_data`
311
+ * files, the payload path whose ids (in payload order) are the run for that
312
+ * file. `keys(section[slice])` paths iterate the slice groups in order, then
313
+ * the entity-id keys in order. The explicit `ids` array is kept ONLY as a
314
+ * lossless fallback when a file has no static payload-path mapping (expected
315
+ * never for the published bundle). Exactly one of `ids_from`/`ids` is present.
316
+ */
317
+ export interface CitationsGroup {
318
+ /** Ordered map: published file → number of consecutive citable ids. */
319
+ source_data: Record<string, number>;
320
+ /** Payload paths (aligned with `source_data` keys) whose ids, in payload
321
+ * order, are the ids for each file's run. */
322
+ ids_from?: string[];
323
+ /** Lossless fallback: explicit ids, ordered by the `source_data` runs. */
324
+ ids?: string[];
325
+ }
326
+ export type CitationsBySource = Partial<Record<CitationMapEntry["source"], CitationsGroup>>;
327
+ /**
328
+ * `manual_grounding` grouped by (rastreabilidade_role, manual_chapter,
329
+ * manual_file, manual_commit_sha) — the fields that repeat verbatim across
330
+ * entries. Total information is preserved: `v1_entity_ids` lists every entry
331
+ * of the group, and `v1_entity_names` carries ONLY the names that are not
332
+ * already recoverable from the `g2_context` entity lists in the same payload
333
+ * (normally empty — names come from the same rastreabilidade source).
334
+ */
335
+ export interface ManualGroundingGroup {
336
+ rastreabilidade_role: string;
337
+ manual_chapter?: string | null;
338
+ manual_file?: string | null;
339
+ manual_commit_sha?: string;
340
+ v1_entity_ids: string[];
341
+ /** Lossless guard: names NOT recoverable via g2_context entity `name`. */
342
+ v1_entity_names?: Record<string, string>;
343
+ }
344
+ export interface ManualGroundingGrouped {
345
+ /** Number of flat entries the groups encode (dedup audit: sum of group sizes). */
346
+ total_entries: number;
347
+ groups: ManualGroundingGroup[];
348
+ /** Lossless guard: entries without a v1_entity_id (expected empty). */
349
+ ungrouped?: Array<WithoutSource<ManualGroundingEntry>>;
350
+ }
351
+ /**
352
+ * v2 token diet, s3b (revised ADENDA 2026-07-05) — minimal-form grounding
353
+ * group: the SAME group as {@link ManualGroundingGroup} (1:1, same order) with
354
+ * the per-group `v1_entity_ids` list replaced by its exact count (`entries`).
355
+ * The grounding id SET is NOT lost: every grounding v1_entity_id is an
356
+ * activated entity id already present verbatim in this payload's
357
+ * `g2_context` entity maps (the grounding is resolved FROM those ids) — only
358
+ * the id→(chapter,file) traceability assignment moves behind the executable
359
+ * `groups_ref` (same input, detail="standard"). Never silent: `entries`
360
+ * counts sum to `total_entries`.
361
+ */
362
+ export interface ManualGroundingMinimalGroup {
363
+ rastreabilidade_role: string;
364
+ manual_chapter?: string | null;
365
+ manual_file?: string | null;
366
+ /** Present ONLY when the sha could not be hoisted to the top level
367
+ * (mixed/absent shas across groups — never expected for the published
368
+ * bundle; lossless guard). */
369
+ manual_commit_sha?: string;
370
+ /** Exact number of v1_entity_ids the detail="standard" group carries. */
371
+ entries: number;
372
+ /** Lossless guard: names NOT recoverable via g2_context entity `name`
373
+ * (kept verbatim from the standard group; expected never). */
374
+ v1_entity_names?: Record<string, string>;
375
+ }
376
+ /** Executable reference to the full per-group grounding ids (s3b). */
377
+ export interface GroundingGroupsRef {
378
+ tool: "prepare_sbd_toe_codegen_context";
379
+ /** Merge over this call's input_echo: same input, detail="standard". */
380
+ with: {
381
+ detail: "standard";
382
+ };
383
+ note: string;
384
+ }
385
+ /**
386
+ * `manual_grounding` at `detail: "minimal"` (s3b revised): aggregated
387
+ * provenance — total count, the manual_commit_sha shared by every group
388
+ * (hoisted), and the (role, chapter, file) group list with per-group entry
389
+ * COUNTS instead of per-group id lists — plus the executable `groups_ref`.
390
+ * The citable id set is untouched (invariant 3): grounding ids never feed
391
+ * `citations`/`ids_from`, and the id set itself stays reconstructible from
392
+ * this same payload's g2_context entity maps without any extra call.
393
+ */
394
+ export interface ManualGroundingMinimal {
395
+ /** Number of flat detail="full" entries the groups encode (Σ entries). */
396
+ total_entries: number;
397
+ /** Hoisted provenance: present iff EVERY group carries this same sha
398
+ * (expected always for the published bundle); otherwise each group keeps
399
+ * its own `manual_commit_sha` inline (lossless guard). */
400
+ manual_commit_sha?: string;
401
+ groups: ManualGroundingMinimalGroup[];
402
+ /** How to obtain the full per-group v1_entity_ids (detail="standard"). */
403
+ groups_ref: GroundingGroupsRef;
404
+ /** Lossless guard: entries without a v1_entity_id (expected empty). */
405
+ ungrouped?: Array<WithoutSource<ManualGroundingEntry>>;
406
+ }
407
+ /**
408
+ * `manual_grounding` at `detail: "ultrathin"` (s3c): aggregate provenance ONLY
409
+ * — `{total_entries, manual_commit_sha, groups_ref}` — derived from the s3b
410
+ * minimal form with the (role, chapter, file) group list elided too. Never
411
+ * silent: `total_entries` is the exact flat detail="full" entry count and
412
+ * `groups_ref` is the executable reference (same input, detail="standard")
413
+ * that returns the full 1:1 grouping with per-group v1_entity_ids. Lossless
414
+ * guards (both expected never for the published bundle): if the sha could not
415
+ * be hoisted OR any group carries non-recoverable `v1_entity_names`, the s3b
416
+ * minimal `groups` list survives inline; `ungrouped` entries survive verbatim.
417
+ * Invariant-3 note (same as minimal): grounding ids never feed
418
+ * `citations`/`ids_from`, and the grounding id SET stays reconstructible from
419
+ * this same payload's g2_context entity maps without any extra call.
420
+ */
421
+ export interface ManualGroundingUltrathin {
422
+ /** Number of flat detail="full" entries the elided groups encode. */
423
+ total_entries: number;
424
+ /** Hoisted provenance (expected always: one published manual commit). */
425
+ manual_commit_sha?: string;
426
+ /** Lossless guard: present ONLY when hoisting failed or a group carried
427
+ * v1_entity_names (never expected) — the s3b minimal groups, verbatim. */
428
+ groups?: ManualGroundingMinimalGroup[];
429
+ /** How to obtain the full per-group v1_entity_ids (detail="standard"). */
430
+ groups_ref: GroundingGroupsRef;
431
+ /** Lossless guard: entries without a v1_entity_id (expected empty). */
432
+ ungrouped?: Array<WithoutSource<ManualGroundingEntry>>;
433
+ }
434
+ /**
435
+ * v2 token diet, s3 — dieted requirement projection. `category` is elided when
436
+ * (and only when) it equals the `requirement_id` prefix before the first "-"
437
+ * (true for all 251 published requirements; the field survives verbatim on any
438
+ * future mismatch — lossless guard). `description` is the PUBLISHED bundle
439
+ * field (data/publish/runtime/requirements.json), verbatim, never paraphrased
440
+ * — the "how" the full projection historically dropped.
441
+ */
442
+ export interface DietedRequirement {
443
+ requirement_id: string;
444
+ name: string;
445
+ type?: string;
446
+ /** Present only on the (never expected) category ≠ id-prefix mismatch. */
447
+ category?: string;
448
+ /** Verbatim `description` from the published bundle. */
449
+ description?: string;
450
+ }
451
+ /**
452
+ * v2 token diet, s3 — dieted control projection: classic fields minus `source`
453
+ * plus, for `confidence: "direct"` controls only, the verbatim published
454
+ * `description` (data/publish/runtime/controls.json).
455
+ */
456
+ export type DietedControl = WithoutSource<ActivatedScope["controls"][number]> & {
457
+ description?: string;
458
+ };
459
+ /**
460
+ * v2 token diet, s3c — executable reference left in `activated_scope` at
461
+ * `detail: "ultrathin"`, where the verbatim published `description` fields
462
+ * (the "how", s3) are elided from requirements and direct controls. Never
463
+ * silent: the lists themselves stay COMPLETE (same ids, same order, name
464
+ * always present — nothing id-only); only the description field moves behind
465
+ * this reference. detail="minimal" is the cheapest level that returns the
466
+ * same complete scope WITH the descriptions (verbatim, never paraphrased).
467
+ */
468
+ export interface ActivatedScopeDescriptionsRef {
469
+ tool: "prepare_sbd_toe_codegen_context";
470
+ /** Merge over this call's input_echo: same input, detail="minimal". */
471
+ with: {
472
+ detail: "minimal";
473
+ };
474
+ note: string;
475
+ }
476
+ export interface DietedActivatedScope {
477
+ requirements: DietedRequirement[];
478
+ controls: DietedControl[];
479
+ slices: Array<WithoutSource<ActivatedScope["slices"][number]>>;
480
+ regulatory_obligations: Array<WithoutSource<ActivatedScope["regulatory_obligations"][number]>>;
481
+ /** Present ONLY at detail="ultrathin" (s3c): how to obtain the verbatim
482
+ * published descriptions elided from requirements + direct controls. */
483
+ descriptions_ref?: ActivatedScopeDescriptionsRef;
484
+ }
485
+ /**
486
+ * v2 token diet, s2 — Relations on-demand. In `standard`/`minimal` the inline
487
+ * `g2_context.relations` array (~4.3K tokens) is replaced by a REFERENCE to
488
+ * executable calls of the `trace_sbd_toe_graph` tool whose union returns a
489
+ * superset of the elided relations. Anchors are activated slice_ids/entity_ids
490
+ * from THIS payload — domain ids, never internal IRIs (EPIC invariant 6).
491
+ *
492
+ * Relation kind → curated lens mapping (see buildRelationsRef):
493
+ * - (objective → mechanism/practice) edges, where the objective has a
494
+ * belongsToSlice edge to an activated slice S:
495
+ * `slice_implementation(anchor=S)` — each row (slice, objective, kind,
496
+ * target) carries BOTH the objective→target edge (kind selects the
497
+ * predicate) and the objective's belongsToSlice edge.
498
+ * - (objective, belongsToSlice, S) for objectives with ≥1 mechanism/practice
499
+ * edge: same `slice_implementation(anchor=S)` rows.
500
+ * - (objective → target) edges whose objective is activated but has NO
501
+ * belongsToSlice edge in the published graph (data gap):
502
+ * `objective_realization(anchor=objective)`.
503
+ * - (objective → target) edges where only the TARGET is activated
504
+ * (cross-slice): `mechanism_provenance(anchor=target)` — the predicate is
505
+ * recovered from the target's entity_type in this same payload.
506
+ * - (entity, belongsToSlice, slice) for Mechanism/Practice/Artifact subjects
507
+ * (and objectives without mechanism/practice edges): NO curated lens
508
+ * returns these edges, and they are 100% redundant with the payload — every
509
+ * `g2_context` entity already carries `slice_id`. Counted as
510
+ * `coverage.implicit_in_entities` (never silently dropped).
511
+ * - Anything not covered above stays INLINE in `residual_relations`
512
+ * (expected empty; never-silent guard).
513
+ */
514
+ export interface RelationsRefLensCall {
515
+ lens: "slice_implementation" | "objective_realization" | "mechanism_provenance";
516
+ /** Activated slice_id or entity_id from this payload (id, never an IRI). */
517
+ anchor: string;
518
+ }
519
+ export interface RelationsRef {
520
+ tool: "trace_sbd_toe_graph";
521
+ /** Executable calls whose union covers the lens-recoverable relations. */
522
+ lenses: RelationsRefLensCall[];
523
+ /** Exact number of relations that would go inline at detail=full (audit). */
524
+ total_relations: number;
525
+ /** Never-silent split of total_relations by recovery path. */
526
+ coverage: {
527
+ /** Recoverable by executing the `lenses` calls above. */
528
+ via_lenses: number;
529
+ /** belongsToSlice edges equal to the `slice_id` field of a g2_context entity. */
530
+ implicit_in_entities: number;
531
+ /** Relations kept inline in `residual_relations` (expected 0). */
532
+ residual_inline: number;
533
+ };
534
+ /** Only present when a relation is neither lens-recoverable nor implicit. */
535
+ residual_relations?: Array<WithoutSource<G2ContextRelation>>;
536
+ note: string;
537
+ }
538
+ /**
539
+ * v2 token diet, s3 — slice-grouped entity encoding for `standard`/`minimal`:
540
+ * `{ slice_id: { entity_id: name | null } }`. Lossless re-encoding of the
541
+ * classic entity list: `entity_type` is the list the map lives in,
542
+ * `slice_id` is the group key, `slice_family` is
543
+ * `activated_scope.slices[].objective_family` for that slice_id, and a `null`
544
+ * name means the full projection omits `name` (unnamed in rastreabilidade).
545
+ * Group/key order preserves the classic list order (insertion order).
546
+ */
547
+ export type SliceGroupedEntityNames = Record<string, Record<string, string | null>>;
548
+ /**
549
+ * v2 token diet, s3 — dieted evidence pattern: classic projection minus
550
+ * `source` (s1 legend) and minus the tool-computed `relevance_score` (the
551
+ * DETERMINISTIC list order — relevance_score desc, then id asc — already
552
+ * carries the ranking; documented in the codegen-instructions resource).
553
+ */
554
+ export type DietedEvidencePattern = Omit<G2ContextEvidencePattern, "source" | "relevance_score">;
555
+ export interface DietedG2Context {
556
+ control_objectives: SliceGroupedEntityNames;
557
+ mechanisms: SliceGroupedEntityNames;
558
+ practices: SliceGroupedEntityNames;
559
+ artifacts: SliceGroupedEntityNames;
560
+ /** Inline only with `include_relations: true` (s2); otherwise see relations_ref. */
561
+ relations?: Array<WithoutSource<G2ContextRelation>>;
562
+ /** Present when relations are elided (s2 default at standard/minimal). */
563
+ relations_ref?: RelationsRef;
564
+ /** s3: deterministic top-{@link STANDARD_EVIDENCE_PATTERN_CAP} prefix of the
565
+ * classic list (see completeness_report for the never-silent counts). */
566
+ evidence_patterns: DietedEvidencePattern[];
567
+ }
568
+ export interface DietedRegulatoryOverlayContext {
569
+ frameworks: Array<WithoutSource<RegulatoryOverlayContext["frameworks"][number]>>;
570
+ obligations: Array<WithoutSource<RegulatoryOverlayContext["obligations"][number]>>;
571
+ mappings: Array<WithoutSource<RegulatoryOverlayContext["mappings"][number]>>;
572
+ playbooks: Array<WithoutSource<RegulatoryOverlayContext["playbooks"][number]>>;
573
+ }
574
+ /**
575
+ * Inline legend for `standard`/`minimal` (s3: slim pointer — the full legend,
576
+ * including the section→source table and every derivation rule of the dieted
577
+ * encoding, lives in the `sbd://toe/codegen-instructions/{mode}` resource,
578
+ * section `detail_encoding`).
579
+ */
580
+ declare const PROVENANCE_LEGEND: {
581
+ readonly note: string;
582
+ };
583
+ export type ProvenanceLegend = typeof PROVENANCE_LEGEND;
584
+ /**
585
+ * v2 token diet, s4 — cheap turns, not fewer turns: short note (≈50 tokens)
586
+ * appended to every `standard`/`minimal` ready payload. The production
587
+ * write-test-edit loop is legitimate; what must not repeat is the cost of
588
+ * re-requesting THIS payload — an identical call returns a byte-identical
589
+ * result (deterministic, tested), so the context already in the session is
590
+ * the source for the loop. Follow-ups that genuinely need more go through
591
+ * `detail: "minimal"` or a targeted `consult_security_requirements` call —
592
+ * never a repeat of the full payload. `full` carries NO hint (byte-identical
593
+ * to the classic payload, EPIC invariant 1).
594
+ */
595
+ export declare const REPEAT_CALL_HINT: string;
596
+ /**
597
+ * v2 token diet, s3 — reference that replaces the inline
598
+ * `llm_codegen_instructions` + `security_rationale_template` boilerplate at
599
+ * `detail: "standard" | "minimal"` (both stay inline at `full`). The MCP
600
+ * resource carries, per mode, the exact instruction slots and the template
601
+ * skeleton; `active_conditions` lists which conditional slots apply to THIS
602
+ * call, so the inline full content is reconstructible byte-identically.
603
+ */
604
+ export interface CodegenInstructionsRef {
605
+ resource: string;
606
+ /** Conditional instruction slots active for this call (see the resource's
607
+ * `llm_codegen_instructions.slots[].when`). */
608
+ active_conditions: InstructionCondition[];
609
+ note: string;
610
+ }
611
+ /**
612
+ * v2 token diet, s3 — never-silent counter left in place of the elided
613
+ * `activation_trace` at `detail: "standard" | "minimal"` (the full trace is
614
+ * included when `debug: true`, and always at `detail: "full"`).
615
+ */
616
+ export interface ActivationTraceRef {
617
+ entries: number;
618
+ note: string;
619
+ }
620
+ /**
621
+ * v2 token diet, s3 — executable reference for retrieving the evidence
622
+ * patterns omitted by the standard cap (boundList discipline: the counts live
623
+ * in the same completeness_report; this says HOW to get the rest).
624
+ */
625
+ export interface EvidencePatternsRest {
626
+ tool: "prepare_sbd_toe_codegen_context";
627
+ /** Merge over this call's input_echo: same input, detail="full" (the
628
+ * classic top-25) at standard/minimal; detail="minimal" (the CHEAPEST level
629
+ * that returns patterns inline) at ultrathin (s3c). */
630
+ with: {
631
+ detail: "full";
632
+ } | {
633
+ detail: "minimal";
634
+ };
635
+ note: string;
636
+ }
637
+ /** Completeness report at `standard`/`minimal`: classic counters (with the
638
+ * s3 cap values) plus, when patterns were cut, the executable rest-reference. */
639
+ export type DietedCompletenessReport = CompletenessReport & {
640
+ evidence_patterns_rest?: EvidencePatternsRest;
641
+ };
642
+ /**
643
+ * v2 token diet, s3c — executable reference for the completeness diagnostics
644
+ * elided at `detail: "ultrathin"` (never silent: exact counts stay inline;
645
+ * detail="minimal" is the cheapest level whose completeness_report carries
646
+ * the full text arrays inline).
647
+ */
648
+ export interface V1DiagnosticsRef {
649
+ tool: "prepare_sbd_toe_codegen_context";
650
+ /** Merge over this call's input_echo: same input, detail="minimal". */
651
+ with: {
652
+ detail: "minimal";
653
+ };
654
+ note: string;
655
+ }
656
+ /**
657
+ * Completeness report at `detail: "ultrathin"` (s3c) — trimmed to the
658
+ * essentials that support the never-silent discipline. KEPT verbatim: every
659
+ * expected/returned count and m_recall (recall audit), named/unnamed entity
660
+ * counts, and the evidence counts (total / returned=0 / capped=total / cap=0)
661
+ * with the executable `evidence_patterns_rest`. CUT (serialization only, each
662
+ * replaced by its exact count + the executable `v1_diagnostics_ref` when any
663
+ * count > 0): the `v1_consistency_mismatches` and `v1_manifest_warnings` TEXT
664
+ * arrays (the verbose per-slice contract-warning strings, ~100 tokens/call).
665
+ */
666
+ export type UltrathinCompletenessReport = Omit<DietedCompletenessReport, "v1_consistency_mismatches" | "v1_manifest_warnings"> & {
667
+ /** Exact length of the elided v1_consistency_mismatches array (expected 0). */
668
+ v1_consistency_mismatches_count: number;
669
+ /** Exact length of the elided v1_manifest_warnings array. */
670
+ v1_manifest_warnings_count: number;
671
+ /** Present iff either count above is > 0: how to obtain the full texts. */
672
+ v1_diagnostics_ref?: V1DiagnosticsRef;
673
+ };
674
+ /**
675
+ * `ready_for_codegen` result at `detail: "standard" | "minimal"`. Same citable
676
+ * ID set as the full result (invariant 3) — the encoding is deduplicated (s1),
677
+ * relations are served on-demand (s2) and, since s3:
678
+ * - `g2_context.evidence_patterns` is capped 25→10 (deterministic prefix;
679
+ * never-silent counts + rest-reference in `completeness_report`);
680
+ * - `llm_codegen_instructions` + `security_rationale_template` move to the
681
+ * `sbd://toe/codegen-instructions/{mode}` MCP resource
682
+ * (`codegen_instructions_ref` carries the URI + active conditions);
683
+ * - `activation_trace` is included only with `debug: true`
684
+ * (`activation_trace_ref` keeps the never-silent count otherwise);
685
+ * - requirements and `direct` controls carry the verbatim published
686
+ * `description` (the "how"), and derivable fields (`category`,
687
+ * `entity_type`, `slice_family`, `relevance_score`, repeated citation ids)
688
+ * are elided per the resource's `detail_encoding` legend.
689
+ *
690
+ * s3b (revised per the 2026-07-05 operator ADENDA — NO top-N/subsetting):
691
+ * `minimal` diverges from `standard` ONLY in serialization of traceability,
692
+ * never in execution context. The activated scope (requirements + controls
693
+ * with descriptions, slices, obligations, g2 entities, citations,
694
+ * relations_ref) is byte-identical to `standard`; `minimal` additionally
695
+ * - caps `g2_context.evidence_patterns` 10→5 (same s3 mechanism: prefix,
696
+ * counts, rest-ref);
697
+ * - serves `manual_grounding` in the minimal form ({@link
698
+ * ManualGroundingMinimal}: counts + hoisted sha + executable groups_ref).
699
+ *
700
+ * s3c (`detail: "ultrathin"`, operator ADENDA 2026-07-05): one level below
701
+ * `minimal`, same rules (activated set COMPLETE, no top-k, nothing id-only,
702
+ * never silent). Diverges from `minimal` ONLY in:
703
+ * - requirements/controls WITHOUT the published `description` (fields kept:
704
+ * requirement {requirement_id, name, type}; control {control_id, name,
705
+ * domain, control_type, confidence}; the `category` lossless guard is
706
+ * unchanged) + executable `activated_scope.descriptions_ref`;
707
+ * - `g2_context.evidence_patterns` cap 5→0 (counts + rest-ref to the
708
+ * cheapest level that returns them: detail="minimal");
709
+ * - `manual_grounding` in the ultrathin form ({@link ManualGroundingUltrathin}:
710
+ * total + hoisted sha + executable groups_ref, group list elided);
711
+ * - `completeness_report` diagnostics trimmed ({@link
712
+ * UltrathinCompletenessReport}: text arrays → exact counts + executable ref).
713
+ * Everything else — g2 entity maps (id→name|null), relations_ref, citations,
714
+ * codegen_instructions_ref, repeat_call_hint, provenance, next — is
715
+ * byte-identical to the other dieted levels.
716
+ */
717
+ export interface PrepareCodegenContextResultReadyDieted {
718
+ status: "ready_for_codegen";
719
+ /** RF-H advisory band — adjacent tools the caller likely needs next. */
720
+ next?: Affordance[];
721
+ mode: CodegenMode;
722
+ input_echo: PrepareCodegenContextResultReady["input_echo"];
723
+ /** Present only with `debug: true` (s3); see activation_trace_ref otherwise. */
724
+ activation_trace?: ActivationTraceEntry[];
725
+ /** Present when activation_trace is elided (never-silent counter). */
726
+ activation_trace_ref?: ActivationTraceRef;
727
+ provenance_legend: ProvenanceLegend;
728
+ activated_scope: DietedActivatedScope;
729
+ g2_context: DietedG2Context;
730
+ /** Grouped (standard), minimal (s3b) or ultrathin form (s3c). */
731
+ manual_grounding: ManualGroundingGrouped | ManualGroundingMinimal | ManualGroundingUltrathin;
732
+ regulatory_overlay: DietedRegulatoryOverlayContext;
733
+ citations: CitationsBySource;
734
+ completeness_report: DietedCompletenessReport | UltrathinCompletenessReport;
735
+ codegen_instructions_ref: CodegenInstructionsRef;
736
+ /** s4 — reuse note ({@link REPEAT_CALL_HINT}): identical re-call is
737
+ * deterministic; the context already received is the loop's source. */
738
+ repeat_call_hint: string;
739
+ provenance: PrepareCodegenContextResultReady["provenance"];
740
+ debug?: PrepareCodegenContextResultReady["debug"];
741
+ }
742
+ export type PrepareCodegenContextResult = PrepareCodegenContextResultReady | PrepareCodegenContextResultReadyDieted | PrepareCodegenContextResultBlocked;
265
743
  declare const VALID_CONCERNS: readonly ["auth", "logging", "validation", "api", "config", "integrity", "distribution", "ide", "requirements", "architecture", "iac", "encryption", "secrets", "build", "supply_chain", "testing", "threat_modeling", "monitoring", "release", "deployment", "integration"];
266
744
  export type Concern = (typeof VALID_CONCERNS)[number];
745
+ /**
746
+ * Conditions under which a conditional instruction slot is included inline at
747
+ * `detail: "full"`. The dieted `codegen_instructions_ref.active_conditions`
748
+ * lists the conditions active for a given call, so a client reading the
749
+ * resource reconstructs the inline instruction list byte-identically.
750
+ */
751
+ export type InstructionCondition = "always" | "regulatory_overlay" | "risk_level:L1" | "risk_level:L2" | "risk_level:L3" | "citation_map_empty";
752
+ export interface InstructionSlot {
753
+ when: InstructionCondition;
754
+ text: string;
755
+ }
756
+ /**
757
+ * Ordered instruction slots for a mode. The emission order of
758
+ * {@link buildLlmInstructions} is EXACTLY this list filtered by active
759
+ * conditions — the classic (pre-s3) output is byte-identical by construction.
760
+ */
761
+ export declare function instructionSlotsForMode(mode: CodegenMode): InstructionSlot[];
762
+ export declare const CODEGEN_INSTRUCTION_MODES: readonly CodegenMode[];
763
+ export declare const CODEGEN_INSTRUCTIONS_RESOURCE_URI_PREFIX = "sbd://toe/codegen-instructions/";
764
+ export declare function codegenInstructionsResourceUri(mode: CodegenMode): string;
765
+ /**
766
+ * Full legend of the dieted (`standard`/`minimal`) encoding, published in the
767
+ * codegen-instructions resource. Every rule here is a lossless, deterministic
768
+ * derivation over the SAME payload (or an executable reference) — nothing is
769
+ * silently dropped (EPIC invariant 2) and no data changes, only serialization
770
+ * (EPIC invariant 4).
771
+ */
772
+ declare const DETAIL_ENCODING_LEGEND: {
773
+ readonly note: string;
774
+ readonly sources: {
775
+ readonly note: string;
776
+ readonly map: {
777
+ readonly "activated_scope.requirements": "runtime_v0";
778
+ readonly "activated_scope.controls": "runtime_v0";
779
+ readonly "activated_scope.slices": "runtime_v1";
780
+ readonly "activated_scope.regulatory_obligations": "overlay";
781
+ readonly "g2_context.control_objectives": "runtime_v1";
782
+ readonly "g2_context.mechanisms": "runtime_v1";
783
+ readonly "g2_context.practices": "runtime_v1";
784
+ readonly "g2_context.artifacts": "runtime_v1";
785
+ readonly "g2_context.relations": "runtime_v1";
786
+ readonly "g2_context.evidence_patterns": "runtime_v0";
787
+ readonly "manual_grounding.groups": "runtime_v1";
788
+ readonly "regulatory_overlay.frameworks": "overlay";
789
+ readonly "regulatory_overlay.obligations": "overlay";
790
+ readonly "regulatory_overlay.mappings": "overlay";
791
+ readonly "regulatory_overlay.playbooks": "overlay";
792
+ };
793
+ };
794
+ readonly citations: string;
795
+ readonly activated_scope_requirements: string;
796
+ readonly activated_scope_controls: string;
797
+ readonly g2_entities: string;
798
+ readonly evidence_patterns: string;
799
+ readonly manual_grounding_minimal: string;
800
+ readonly activation_trace: string;
801
+ readonly relations_ref: string;
802
+ readonly ultrathin: string;
803
+ };
804
+ export interface CodegenInstructionsResourceContent {
805
+ resource: string;
806
+ mode: CodegenMode;
807
+ note: string;
808
+ llm_codegen_instructions: {
809
+ assembly: string;
810
+ slots: InstructionSlot[];
811
+ };
812
+ security_rationale_template: {
813
+ assembly: string;
814
+ template: {
815
+ task: null;
816
+ } & Omit<SecurityRationaleTemplate, "task">;
817
+ };
818
+ detail_encoding: typeof DETAIL_ENCODING_LEGEND;
819
+ }
820
+ /**
821
+ * Content of the `sbd://toe/codegen-instructions/{mode}` MCP resource — the
822
+ * static-per-mode boilerplate that detail=standard/minimal payloads reference
823
+ * instead of carrying inline. Reconstructing the inline `full` content from
824
+ * this resource is byte-exact (tested):
825
+ * - llm_codegen_instructions = slots filtered by `when` ("always" +
826
+ * codegen_instructions_ref.active_conditions), in order;
827
+ * - security_rationale_template = template with `task` set to the trimmed
828
+ * task string (input_echo.task.trim()).
829
+ */
830
+ export declare function buildCodegenInstructionsResourceContent(mode: CodegenMode): CodegenInstructionsResourceContent;
267
831
  export declare function handlePrepareCodegenContext(raw: PrepareCodegenContextInput): PrepareCodegenContextResult;
268
832
  export declare const __wp5Lexicon: {
269
833
  VALID_CONCERNS: readonly ["auth", "logging", "validation", "api", "config", "integrity", "distribution", "ide", "requirements", "architecture", "iac", "encryption", "secrets", "build", "supply_chain", "testing", "threat_modeling", "monitoring", "release", "deployment", "integration"];