@ai-sdlc/orchestrator 0.10.0 → 0.13.0

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 (156) hide show
  1. package/dist/adapters.d.ts +42 -3
  2. package/dist/adapters.js +133 -3
  3. package/dist/admission-composite.d.ts +112 -1
  4. package/dist/admission-composite.js +85 -4
  5. package/dist/admission-enrichment.d.ts +12 -3
  6. package/dist/admission-enrichment.js +64 -13
  7. package/dist/admission-score.d.ts +30 -0
  8. package/dist/admission-score.js +4 -1
  9. package/dist/backlog-adapter.d.ts +45 -0
  10. package/dist/backlog-adapter.js +145 -1
  11. package/dist/calibration.d.ts +81 -0
  12. package/dist/calibration.js +76 -0
  13. package/dist/cli/commands/init-features.d.ts +301 -2
  14. package/dist/cli/commands/init-features.js +634 -7
  15. package/dist/cli/commands/init-templates.d.ts +198 -1
  16. package/dist/cli/commands/init-templates.js +943 -1
  17. package/dist/cli/commands/init.d.ts +45 -0
  18. package/dist/cli/commands/init.js +147 -5
  19. package/dist/cli/commands/run.js +9 -1
  20. package/dist/cli/index.d.ts +11 -0
  21. package/dist/cli/index.js +42 -8
  22. package/dist/compliance/composer.d.ts +79 -0
  23. package/dist/compliance/composer.js +258 -0
  24. package/dist/compliance/errors.d.ts +64 -0
  25. package/dist/compliance/errors.js +85 -0
  26. package/dist/compliance/loader.d.ts +52 -0
  27. package/dist/compliance/loader.js +124 -0
  28. package/dist/compliance/types.d.ts +184 -0
  29. package/dist/compliance/types.js +41 -0
  30. package/dist/compliance-clearance.d.ts +269 -0
  31. package/dist/compliance-clearance.js +269 -0
  32. package/dist/config.js +17 -0
  33. package/dist/cost-tracker.d.ts +22 -0
  34. package/dist/cost-tracker.js +41 -0
  35. package/dist/database/adapters/external.js +5 -1
  36. package/dist/embedding/adapters/openai-text-embedding-3-small.d.ts +71 -0
  37. package/dist/embedding/adapters/openai-text-embedding-3-small.js +190 -0
  38. package/dist/embedding/consumers/tessellation-drift.d.ts +74 -0
  39. package/dist/embedding/consumers/tessellation-drift.js +76 -0
  40. package/dist/embedding/cross-provider.d.ts +78 -0
  41. package/dist/embedding/cross-provider.js +75 -0
  42. package/dist/embedding/deprecation.d.ts +151 -0
  43. package/dist/embedding/deprecation.js +229 -0
  44. package/dist/embedding/errors.d.ts +90 -0
  45. package/dist/embedding/errors.js +150 -0
  46. package/dist/embedding/index.d.ts +29 -0
  47. package/dist/embedding/index.js +24 -0
  48. package/dist/embedding/pipeline-load.d.ts +146 -0
  49. package/dist/embedding/pipeline-load.js +178 -0
  50. package/dist/embedding/registry.d.ts +45 -0
  51. package/dist/embedding/registry.js +61 -0
  52. package/dist/embedding/stale-vector.d.ts +110 -0
  53. package/dist/embedding/stale-vector.js +92 -0
  54. package/dist/embedding/storage/index.d.ts +51 -0
  55. package/dist/embedding/storage/index.js +43 -0
  56. package/dist/embedding/storage/jsonl-backend.d.ts +150 -0
  57. package/dist/embedding/storage/jsonl-backend.js +332 -0
  58. package/dist/embedding/storage/types.d.ts +135 -0
  59. package/dist/embedding/storage/types.js +13 -0
  60. package/dist/embedding/types.d.ts +180 -0
  61. package/dist/embedding/types.js +10 -0
  62. package/dist/execute.d.ts +29 -2
  63. package/dist/execute.js +171 -30
  64. package/dist/index.d.ts +14 -2
  65. package/dist/index.js +19 -2
  66. package/dist/journey/inheritance-validator.d.ts +396 -0
  67. package/dist/journey/inheritance-validator.js +370 -0
  68. package/dist/journey/state-id-drift-rule.d.ts +137 -0
  69. package/dist/journey/state-id-drift-rule.js +245 -0
  70. package/dist/journey-sa2-router.d.ts +395 -0
  71. package/dist/journey-sa2-router.js +308 -0
  72. package/dist/runners/review-agent.js +6 -2
  73. package/dist/runners/runner-registry.d.ts +36 -0
  74. package/dist/runners/runner-registry.js +90 -0
  75. package/dist/runtime/attestations.d.ts +173 -13
  76. package/dist/runtime/attestations.js +252 -40
  77. package/dist/runtime/index.d.ts +1 -1
  78. package/dist/runtime/index.js +1 -1
  79. package/dist/sa-scoring/layer3-llm.js +6 -1
  80. package/dist/sa-scoring/revision-proposal-config.d.ts +178 -0
  81. package/dist/sa-scoring/revision-proposal-config.js +198 -0
  82. package/dist/sa-scoring/revision-proposal.d.ts +285 -0
  83. package/dist/sa-scoring/revision-proposal.js +417 -0
  84. package/dist/signal-ingestion/adapters/community-thread.d.ts +43 -0
  85. package/dist/signal-ingestion/adapters/community-thread.js +55 -0
  86. package/dist/signal-ingestion/adapters/in-app-feedback.d.ts +67 -0
  87. package/dist/signal-ingestion/adapters/in-app-feedback.js +51 -0
  88. package/dist/signal-ingestion/adapters/manual.d.ts +78 -0
  89. package/dist/signal-ingestion/adapters/manual.js +112 -0
  90. package/dist/signal-ingestion/adapters/support-ticket.d.ts +47 -0
  91. package/dist/signal-ingestion/adapters/support-ticket.js +51 -0
  92. package/dist/signal-ingestion/classifier.d.ts +205 -0
  93. package/dist/signal-ingestion/classifier.js +494 -0
  94. package/dist/signal-ingestion/clustering-types.d.ts +36 -0
  95. package/dist/signal-ingestion/clustering-types.js +14 -0
  96. package/dist/signal-ingestion/clustering.d.ts +200 -0
  97. package/dist/signal-ingestion/clustering.js +413 -0
  98. package/dist/signal-ingestion/config.d.ts +351 -0
  99. package/dist/signal-ingestion/config.js +587 -0
  100. package/dist/signal-ingestion/d1.d.ts +252 -0
  101. package/dist/signal-ingestion/d1.js +235 -0
  102. package/dist/signal-ingestion/errors.d.ts +73 -0
  103. package/dist/signal-ingestion/errors.js +108 -0
  104. package/dist/signal-ingestion/governance-events.d.ts +181 -0
  105. package/dist/signal-ingestion/governance-events.js +189 -0
  106. package/dist/signal-ingestion/index.d.ts +35 -0
  107. package/dist/signal-ingestion/index.js +53 -0
  108. package/dist/signal-ingestion/manual-share-metric.d.ts +93 -0
  109. package/dist/signal-ingestion/manual-share-metric.js +106 -0
  110. package/dist/signal-ingestion/registry.d.ts +40 -0
  111. package/dist/signal-ingestion/registry.js +137 -0
  112. package/dist/signal-ingestion/residency.d.ts +227 -0
  113. package/dist/signal-ingestion/residency.js +238 -0
  114. package/dist/signal-ingestion/significance.d.ts +554 -0
  115. package/dist/signal-ingestion/significance.js +555 -0
  116. package/dist/signal-ingestion/types.d.ts +191 -0
  117. package/dist/signal-ingestion/types.js +8 -0
  118. package/dist/substrate/drift-composition.d.ts +270 -0
  119. package/dist/substrate/drift-composition.js +306 -0
  120. package/dist/substrate/drift-tui-surface.d.ts +61 -0
  121. package/dist/substrate/drift-tui-surface.js +102 -0
  122. package/dist/substrate/identity-class.d.ts +176 -0
  123. package/dist/substrate/identity-class.js +201 -0
  124. package/dist/tessellation/cross-soul-provenance-rule.d.ts +133 -0
  125. package/dist/tessellation/cross-soul-provenance-rule.js +171 -0
  126. package/dist/tessellation/inter-soul-embedding-distance-rule.d.ts +61 -0
  127. package/dist/tessellation/inter-soul-embedding-distance-rule.js +67 -0
  128. package/dist/tessellation/rule-registry.d.ts +269 -0
  129. package/dist/tessellation/rule-registry.js +92 -0
  130. package/dist/tessellation/soul-slug-ast-scan-rule.d.ts +90 -0
  131. package/dist/tessellation/soul-slug-ast-scan-rule.js +158 -0
  132. package/dist/tessellation-admission.d.ts +162 -0
  133. package/dist/tessellation-admission.js +146 -0
  134. package/dist/tessellation-drift.d.ts +246 -0
  135. package/dist/tessellation-drift.js +250 -0
  136. package/dist/validate-config.js +13 -0
  137. package/dist/validate-issue.js +2 -2
  138. package/dist/variant/cardinality-activation.d.ts +126 -0
  139. package/dist/variant/cardinality-activation.js +101 -0
  140. package/dist/variant/deprecation-lifecycle.d.ts +184 -0
  141. package/dist/variant/deprecation-lifecycle.js +208 -0
  142. package/dist/variant/drift-extension.d.ts +136 -0
  143. package/dist/variant/drift-extension.js +164 -0
  144. package/dist/variant/engineering-review.d.ts +185 -0
  145. package/dist/variant/engineering-review.js +142 -0
  146. package/dist/variant/index.d.ts +32 -0
  147. package/dist/variant/index.js +32 -0
  148. package/dist/variant/inheritance-validator.d.ts +165 -0
  149. package/dist/variant/inheritance-validator.js +139 -0
  150. package/dist/variant/internal-adopter/index.d.ts +11 -0
  151. package/dist/variant/internal-adopter/index.js +10 -0
  152. package/dist/variant/internal-adopter/products.d.ts +156 -0
  153. package/dist/variant/internal-adopter/products.js +366 -0
  154. package/dist/variant-admission.d.ts +316 -0
  155. package/dist/variant-admission.js +247 -0
  156. package/package.json +10 -8
package/dist/index.js CHANGED
@@ -35,8 +35,12 @@ export { checkAction, enforceAction, DEFAULT_BLOCKED_ACTIONS, } from './action-e
35
35
  // Issue admission scoring
36
36
  export { scoreIssueForAdmission, mapIssueToPriorityInput, } from './admission-score.js';
37
37
  export { enrichAdmissionInput, computeDesignSystemReadiness, computeReadinessFromDesignSystemContext, computeDefectRiskFactor, computeAutonomyFactor, computeDesignAuthorityWeight, complexityToAutonomyLevel, } from './admission-enrichment.js';
38
- export { computeAdmissionComposite } from './admission-composite.js';
39
- export { parseBacklogTask, loadBacklogTaskFromRoot, mapBacklogTaskToAdmissionInput, loadSoulTracks, loadMaintainers, } from './backlog-adapter.js';
38
+ export { computeAdmissionComposite, } from './admission-composite.js';
39
+ export { resolveAffectedSouls, applyCrossSoulRule, computeTessellatedScores, } from './tessellation-admission.js';
40
+ export { detectTessellationDrift, DEFAULT_DIVERGENCE_THRESHOLD, } from './tessellation-drift.js';
41
+ export { parseTargetedVariantRef, resolveTargetedVariants, applyCrossVariantRule, computeVariantScopedScores, defaultCrossSoulVariantRule, } from './variant-admission.js';
42
+ export { combineVariantSaForSoulAlignment } from './admission-composite.js';
43
+ export { parseBacklogTask, loadBacklogTaskFromRoot, mapBacklogTaskToAdmissionInput, loadSoulTracks, loadMaintainers, extractCodeAreaFromReferences, parseBodyReferences, } from './backlog-adapter.js';
40
44
  export { computePillarBreakdown, detectTensions, pillarSignalScore, } from './pillar-breakdown.js';
41
45
  // RFC-0008 Addendum B — SA scoring (Layer 1/2/3 + composite)
42
46
  export { compileDid, validatePhase2bReadiness, hashDidSpec, canonicalJson, tokenize, serializeForStore, deserializeFromStore, } from './sa-scoring/did-compiler.js';
@@ -50,6 +54,7 @@ export { SAFeedbackStore, SA_FEEDBACK_LABELS, classifyLabel, recordOverrideFeedb
50
54
  export { computeCalibrationCoefficient, buildCategoryCoefficients, } from './calibration.js';
51
55
  export { autoCalibratePhaseWeights, computePhase3Weights, decideCalibrationDirection, renderCalibrationDiff, WEIGHT_FLOOR, WEIGHT_CEILING, DEFAULT_SHIFT_SIZE, DEFAULT_WINDOW_DAYS, PRECISION_DELTA_THRESHOLD, } from './sa-scoring/auto-calibrate.js';
52
56
  export { detectSoulDrift, computeWindowStats, computeTrend, describeDriftSource, DEFAULT_MEAN_THRESHOLD, DEFAULT_STDDEV_THRESHOLD, DEFAULT_CONSECUTIVE_WINDOWS, DEFAULT_RECOVERY_MS, } from './sa-scoring/drift-monitor.js';
57
+ export { classifyDrift, deriveApprovalPath, computeConfidence, evaluateRevisionProposal, triggerConditionMet, isFieldLocked, isProposalExpired, archiveExpiredProposals, recordRejection, computeRejectionPrecedentFactor, DEFAULT_DISMISS_THRESHOLD, DEFAULT_DEMAND_MISALIGNMENT_THRESHOLD, DEFAULT_DRIFT_EVENTS_THRESHOLD, DEFAULT_TRIGGER_WINDOW_DAYS, DEFAULT_PROPOSAL_EXPIRY_DAYS, HEALTHY_ICP_MATCH_MIN, UNHEALTHY_ICP_MATCH_MAX, } from './sa-scoring/revision-proposal.js';
53
58
  export { handleCoreIdentityChanged, } from './sa-scoring/rescore-orchestrator.js';
54
59
  export { scoreSoulAlignment, resolveSoulAlignmentOverride, } from './sa-scoring/index.js';
55
60
  // PR review orchestration
@@ -67,6 +72,12 @@ export { createPipelineReconciler, createGateReconciler, createAutonomyReconcile
67
72
  export { createFileAuditLog, verifyAuditIntegrity, loadAuditEntries, rotateAuditLog, computeAuditHash, } from './audit-extended.js';
68
73
  // Extended compliance
69
74
  export { checkFrameworkCompliance, getControlCatalog, getFrameworkMappings, listSupportedFrameworks, } from './compliance-extended.js';
75
+ // RFC-0009 Phase 4.1 — Eρ₅ Compliance Clearance
76
+ export { HARD_REGULATORY_REGIME_PREFIXES, isHardRegulatoryRegime, validateComplianceRegimes, computeComplianceClearance, } from './compliance-clearance.js';
77
+ // RFC-0022 Phase 1 — CompliancePosture schema + loader
78
+ export { loadCompliancePosture, DEFAULT_COMPLIANCE_MANIFEST_PATH, } from './compliance/loader.js';
79
+ export { MissingComplianceAttestation, MissingDerivedGateOverrideNotes, UnknownRegime, CompliancePostureValidationError, } from './compliance/errors.js';
80
+ export { BASELINE_DERIVED_GATES, BASELINE_POSTURE, } from './compliance/types.js';
70
81
  // Extended telemetry
71
82
  export { createSilentLogger, withPipelineSpanSync, getPipelineTracer, validateResourceSchema, } from './telemetry-extended.js';
72
83
  // Runners
@@ -124,6 +135,12 @@ export { HarnessRegistry, UnknownHarnessError, ClaudeCodeAdapter, CodexAdapter,
124
135
  export { SubscriptionLedger, validateTenantShares, evaluateSchedule, CalibrationStore, COLD_START_DEFAULT, buildBurnDownReport, analyzeTier, PLAN_COSTS_USD, isOffPeakAt, nextOffPeakStart, ageInDays, freshnessLevel, DEFAULT_TENANT, COLD_START_DEFAULT_INPUT, COLD_START_DEFAULT_OUTPUT, ESTIMATE_VARIANCE_THRESHOLD, ROLLING_WINDOW_SIZE, } from './scheduling/index.js';
125
136
  // RFC-0010 database branching (DatabaseBranchAdapter framework + 4 adapters)
126
137
  export { DatabaseAdapterRegistry, UnknownDatabaseAdapterError, SqliteCopyAdapter, NeonAdapter, PgSnapshotRestoreAdapter, ExternalAdapter, createDefaultDatabaseAdapterRegistry, buildInjectionOverrides, parsePostgresUrl, maskConnectionString, enforceTopologyGuard, buildMigrationDivergedEvent, DatabaseBranchAdapterError, BranchTopologyForbiddenError, } from './database/index.js';
138
+ // RFC-0030 Phase 1 — signal ingestion source adapters
139
+ export { AdapterCredentialInvalid, CommunityThreadSignalSourceAdapter, ManualSignalIncomplete, ManualSignalSourceAdapter, SignalSourceRegistry, SignalSourceUnavailable, SupportTicketSignalSourceAdapter, UnknownSignalSource, createDefaultSignalSourceRegistry, fetchSignalsFromAvailableAdapters, getSignalSourceAdapter, } from './signal-ingestion/index.js';
140
+ // RFC-0030 Phase 2 — classification (tier + ICP resonance + recency + language gate)
141
+ export { classifySignals, computeRecencyDecay, computeSignalWeight, resolveCustomerTier, resolveIcpResonance, tokenize as tokenizeSignalPayload, DEFAULT_SIGNAL_INGESTION_CONFIG, DEFAULT_SIGNAL_INGESTION_CONFIG_PATH, SignalIngestionConfigError, loadSignalIngestionConfig, } from './signal-ingestion/index.js';
142
+ // RFC-0030 Phase 5 — D1 formula reformulation + RFC-0008 PPA integration
143
+ export { aggregateD1FromClusters, composeD1Inputs, computeClusterD1, enrichDemandSignalFromClusters, } from './signal-ingestion/index.js';
127
144
  // RFC-0010 artifacts (heartbeat + event stream + atomic JSON + state listing)
128
145
  export { StateWriter, appendEvent, readEvents, atomicWriteJson, listActiveStates, HEARTBEAT_INTERVAL_MS, HEARTBEAT_STALE_MS, } from './artifacts/index.js';
129
146
  // RFC-0010 dispatch (worker pool + merge gate + requeue)
@@ -0,0 +1,396 @@
1
+ /**
2
+ * RFC-0018 Phase 1 — Journey Inheritance Validator.
3
+ *
4
+ * Implements RFC-0018 §5.3 bounded-inheritance enforcement for journey
5
+ * declarations on Soul DIDs and Variants. When a violation is detected the
6
+ * validator emits a `JourneyInheritanceViolation` event (RFC-0008 §C5).
7
+ *
8
+ * Covers the following AC items (AISDLC-465):
9
+ * AC #5: JourneyInheritanceViolation event emitted for all 5 violation classes.
10
+ * AC #7: Journey count thresholds emit Decisions (journey-count-soft-warning at >=10;
11
+ * journey-count-hard-limit-exceeded at >=50).
12
+ * AC #8: State count thresholds emit Decisions (journey-state-count-soft-warning at >=12
13
+ * with v1-workaround message; journey-state-count-hard-limit-exceeded at >=100).
14
+ * AC #9: Nested journeys[] rejected at schema validation (schema-enforced flat, OQ-3).
15
+ * AC #10: Decision: journey-sub-flow-activation-request Stage A counter wired.
16
+ *
17
+ * ### Bounded inheritance (§5.3)
18
+ *
19
+ * Journeys MUST NOT attempt to override the following fields inherited from
20
+ * the parent Soul DID (or Variant when scope=variant):
21
+ *
22
+ * 1. `complianceRegimes` — per-soul (locked at soul/variant level)
23
+ * 2. `targetAudience` — inherits from soul or variant
24
+ * 3. `substrateInvariants` — locked at soul level
25
+ * 4. `complianceFloor` — when scope=variant, MUST be 'inherit' (never a custom value)
26
+ * 5. `wcagLevel` lowering — journeys MAY raise WCAG above parent but NEVER lower it
27
+ *
28
+ * ### Count + state limits (OQ-1, OQ-2)
29
+ *
30
+ * Per-org configurable via `.ai-sdlc/journey-config.yaml`:
31
+ * journey.limits.softWarnAt (default 10) / journey.limits.hardLimit (default 50)
32
+ * journey.stateLimits.softWarnAt (default 12) / journey.stateLimits.hardLimit (default 100)
33
+ *
34
+ * ### Nested-journey rejection (OQ-3)
35
+ *
36
+ * Schema-enforced flat: a journey declaration MUST NOT contain a `journeys[]`
37
+ * field. Emits `NestedJourneyRejected` (blocking).
38
+ *
39
+ * ### Sub-flow activation counter (OQ-3)
40
+ *
41
+ * Tracks distinct adopter requests for journey-sub-flow activation. When a
42
+ * journey declaration contains a nested `journeys[]` field, the validator:
43
+ * 1. Emits `NestedJourneyRejected` (blocking).
44
+ * 2. Records the request in the sub-flow activation counter.
45
+ * 3. When distinctAdopterCount >= threshold (default 2), marks
46
+ * `promotedToOperatorReview: true` in the counter result, signalling
47
+ * that a follow-on RFC discussion should be surfaced.
48
+ *
49
+ * @see spec/rfcs/RFC-0018-in-soul-journey-pattern.md §5.3 + §10.1
50
+ * @see orchestrator/src/variant/inheritance-validator.ts — parallel RFC-0017 validator
51
+ */
52
+ /**
53
+ * Field names that are INHERITED from the parent Soul DID and cannot be
54
+ * overridden by any journey declaration. Attempting to declare these on a
55
+ * journey triggers a `JourneyInheritanceViolation`.
56
+ *
57
+ * Note: `complianceFloor` is validated separately (it must be 'inherit' when
58
+ * scope=variant, not merely absent) — see `validateComplianceFloor`.
59
+ */
60
+ export declare const JOURNEY_INHERITED_LOCKED_FIELDS: readonly ["complianceRegimes", "targetAudience", "substrateInvariants"];
61
+ export type JourneyInheritedLockedField = (typeof JOURNEY_INHERITED_LOCKED_FIELDS)[number];
62
+ /**
63
+ * Numeric ordering for WCAG levels. Higher = stricter.
64
+ * Used to detect lowering of WCAG level below parent.
65
+ */
66
+ export declare const WCAG_LEVEL_ORDER: Record<string, number>;
67
+ /**
68
+ * Discriminated event kind for journey-level events emitted to events.jsonl.
69
+ */
70
+ export type JourneyEventKind = 'JourneyInheritanceViolation' | 'JourneyCountSoftWarning' | 'JourneyCountHardLimitExceeded' | 'JourneyStateCountSoftWarning' | 'JourneyStateCountHardLimitExceeded' | 'NestedJourneyRejected';
71
+ /**
72
+ * The 5 violation classes per RFC-0018 §5.3 bounded inheritance.
73
+ *
74
+ * Each violation class corresponds to a field (or semantic constraint)
75
+ * that a journey may NOT override from its parent Soul DID or Variant.
76
+ */
77
+ export type JourneyViolationClass = 'complianceRegimes' | 'targetAudience' | 'substrateInvariants' | 'complianceFloor' | 'wcagLevel-lowered-below-parent';
78
+ /**
79
+ * Emitted when a journey attempts to override an inherited locked field per
80
+ * RFC-0018 §5.3. This is an Engineering vertex error (RFC-0008 §C5).
81
+ *
82
+ * The result is `blocking: true` — the declaring Soul DID is invalid until
83
+ * the offending override is removed.
84
+ */
85
+ export interface JourneyInheritanceViolation {
86
+ readonly kind: 'JourneyInheritanceViolation';
87
+ /** Identifier of the Soul DID that contains the offending journey. */
88
+ readonly soulId: string;
89
+ /** The journey's `id` field value. */
90
+ readonly journeyId: string;
91
+ /** The violation class (which inheritance constraint was broken). */
92
+ readonly violationClass: JourneyViolationClass;
93
+ /** Human-readable description of the violation. */
94
+ readonly message: string;
95
+ /** Always true — inheritance violations are blocking errors. */
96
+ readonly blocking: true;
97
+ readonly timestamp: string;
98
+ }
99
+ /**
100
+ * Non-blocking warning emitted when a Soul DID's journey count reaches the
101
+ * soft-warn threshold (default 10 per OQ-1). Routes through Decision Catalog
102
+ * as `Decision: journey-count-soft-warning` for operator batch review.
103
+ */
104
+ export interface JourneyCountSoftWarning {
105
+ readonly kind: 'JourneyCountSoftWarning';
106
+ readonly soulId: string;
107
+ readonly journeyCount: number;
108
+ readonly threshold: number;
109
+ readonly message: string;
110
+ readonly blocking: false;
111
+ readonly timestamp: string;
112
+ }
113
+ /**
114
+ * Hard-blocking rejection emitted when a Soul DID's journey count reaches the
115
+ * hard limit (default 50 per OQ-1). The Soul DID declaration is rejected.
116
+ * Routes through Decision Catalog as `Decision: journey-count-hard-limit-exceeded`
117
+ * plus a clarification task.
118
+ */
119
+ export interface JourneyCountHardLimitExceeded {
120
+ readonly kind: 'JourneyCountHardLimitExceeded';
121
+ readonly soulId: string;
122
+ readonly journeyCount: number;
123
+ readonly limit: number;
124
+ readonly message: string;
125
+ readonly blocking: true;
126
+ readonly timestamp: string;
127
+ }
128
+ /**
129
+ * Non-blocking warning emitted when a journey's state count reaches the
130
+ * soft-warn threshold (default 12 per OQ-2). Includes concrete v1 workaround
131
+ * message pointing at the split-journeys pattern.
132
+ */
133
+ export interface JourneyStateCountSoftWarning {
134
+ readonly kind: 'JourneyStateCountSoftWarning';
135
+ readonly soulId: string;
136
+ readonly journeyId: string;
137
+ readonly stateCount: number;
138
+ readonly threshold: number;
139
+ readonly message: string;
140
+ readonly v1WorkaroundMessage: string;
141
+ readonly blocking: false;
142
+ readonly timestamp: string;
143
+ }
144
+ /**
145
+ * Hard-blocking rejection emitted when a journey's state count reaches the
146
+ * hard limit (default 100 per OQ-2). This is a sanity guard (typo /
147
+ * runaway-loop), NOT an architectural constraint.
148
+ */
149
+ export interface JourneyStateCountHardLimitExceeded {
150
+ readonly kind: 'JourneyStateCountHardLimitExceeded';
151
+ readonly soulId: string;
152
+ readonly journeyId: string;
153
+ readonly stateCount: number;
154
+ readonly limit: number;
155
+ readonly message: string;
156
+ readonly blocking: true;
157
+ readonly timestamp: string;
158
+ }
159
+ /**
160
+ * Emitted when a nested `journeys[]` field is detected inside a journey
161
+ * declaration. Schema-enforced flat per RFC-0018 OQ-3. Blocking.
162
+ */
163
+ export interface NestedJourneyRejected {
164
+ readonly kind: 'NestedJourneyRejected';
165
+ readonly soulId: string;
166
+ readonly journeyId: string;
167
+ readonly message: string;
168
+ readonly blocking: true;
169
+ readonly timestamp: string;
170
+ }
171
+ export type JourneyEvent = JourneyInheritanceViolation | JourneyCountSoftWarning | JourneyCountHardLimitExceeded | JourneyStateCountSoftWarning | JourneyStateCountHardLimitExceeded | NestedJourneyRejected;
172
+ /**
173
+ * Result of the sub-flow activation counter check (OQ-3).
174
+ *
175
+ * Tracks distinct adopter requests for journey-sub-flow activation.
176
+ * When `distinctAdopterCount >= threshold`, `promotedToOperatorReview` is
177
+ * set to `true` — a signal to surface the topic for follow-on RFC discussion.
178
+ */
179
+ export interface SubFlowActivationCounterResult {
180
+ readonly decision: 'journey-sub-flow-activation-request';
181
+ readonly distinctAdopterCount: number;
182
+ readonly threshold: number;
183
+ readonly promotedToOperatorReview: boolean;
184
+ readonly adopters: readonly string[];
185
+ readonly recommendation: string;
186
+ }
187
+ /**
188
+ * Minimal representation of one state declaration as loaded from a journey.
189
+ */
190
+ export interface JourneyStateInput {
191
+ /** State identifier (kebab-case). */
192
+ id: string;
193
+ /** Whether this state is a terminal state. */
194
+ terminal?: boolean;
195
+ /** Whether this terminal state is a success state. */
196
+ successState?: boolean;
197
+ [key: string]: unknown;
198
+ }
199
+ /**
200
+ * Minimal accessibility block as loaded from a journey.
201
+ */
202
+ export interface JourneyAccessibilityInput {
203
+ /** WCAG level declared on this journey. */
204
+ wcagLevel?: string;
205
+ [key: string]: unknown;
206
+ }
207
+ /**
208
+ * Minimal representation of one journey declaration as loaded from a Soul DID
209
+ * or Variant. Mirrors the JSON Schema shape at
210
+ * `spec/schemas/journey.v1.schema.json`.
211
+ */
212
+ export interface JourneyDeclarationInput {
213
+ /** Kebab-case journey id. */
214
+ id: string;
215
+ /** Scope — 'soul' or 'variant:<id>'. */
216
+ scope?: string;
217
+ /** State declarations. */
218
+ states?: JourneyStateInput[];
219
+ /** Accessibility block (for WCAG-level inheritance check). */
220
+ accessibility?: JourneyAccessibilityInput;
221
+ /**
222
+ * Any additional fields present in the raw declaration — used to detect
223
+ * attempts to override locked inherited fields and nested journeys.
224
+ */
225
+ [key: string]: unknown;
226
+ }
227
+ /**
228
+ * Per-org journey count configuration. Loaded from
229
+ * `.ai-sdlc/journey-config.yaml` (`journey.limits`) with the defaults below.
230
+ */
231
+ export interface JourneyLimitsConfig {
232
+ /** Non-blocking soft warn threshold for journey count. Default: 10. */
233
+ softWarnAt?: number;
234
+ /** Hard-blocking rejection limit for journey count. Default: 50. */
235
+ hardLimit?: number;
236
+ }
237
+ /**
238
+ * Per-org journey state count configuration. Loaded from
239
+ * `.ai-sdlc/journey-config.yaml` (`journey.stateLimits`) with the defaults below.
240
+ */
241
+ export interface JourneyStateLimitsConfig {
242
+ /** Non-blocking soft warn threshold for state count per journey. Default: 12. */
243
+ softWarnAt?: number;
244
+ /** Hard-blocking rejection limit for state count per journey. Default: 100. */
245
+ hardLimit?: number;
246
+ /** Optional operator-actionable message shown with soft-warn Decision. */
247
+ softWarnMessage?: string;
248
+ }
249
+ /**
250
+ * Per-org sub-flow activation counter configuration.
251
+ * Loaded from `.ai-sdlc/journey-config.yaml` (`journey.subJourneys`).
252
+ */
253
+ export interface SubFlowActivationConfig {
254
+ /** Auto-promote threshold. Default: 2 distinct adopter requests. */
255
+ distinctAdopterRequestsThreshold?: number;
256
+ }
257
+ /**
258
+ * Options for `validateJourneyDeclarations`.
259
+ */
260
+ export interface ValidateJourneyDeclarationsOptions {
261
+ /** Identifier of the Soul DID being validated (for event attribution). */
262
+ soulId: string;
263
+ /** Raw journey declarations from the Soul DID's or Variant's `spec.journeys[]`. */
264
+ journeys: JourneyDeclarationInput[];
265
+ /** Per-org or per-Soul limit overrides for journey count. */
266
+ limits?: JourneyLimitsConfig;
267
+ /** Per-org or per-Soul limit overrides for state count per journey. */
268
+ stateLimits?: JourneyStateLimitsConfig;
269
+ /**
270
+ * Parent WCAG level. When set, journeys with wcagLevel BELOW this are in violation.
271
+ * Journeys may RAISE the WCAG level above parent but NEVER LOWER it (§5.3).
272
+ */
273
+ parentWcagLevel?: string;
274
+ /** ISO 8601 timestamp to stamp on emitted events. Defaults to now. */
275
+ now?: string;
276
+ }
277
+ /** OQ-1 default: soft warn at 10 journeys (Miller 7±2 + industry advisory). */
278
+ export declare const DEFAULT_JOURNEY_SOFT_WARN_AT = 10;
279
+ /** OQ-1 default: hard limit at 50 journeys (Salesforce-style enterprise ceiling). */
280
+ export declare const DEFAULT_JOURNEY_HARD_LIMIT = 50;
281
+ /** OQ-2 default: soft warn at 12 states (Miller 7±2 + XState advisory + IEEE readability). */
282
+ export declare const DEFAULT_STATE_SOFT_WARN_AT = 12;
283
+ /**
284
+ * OQ-2 default: hard limit at 100 states (sanity guard, NOT architectural constraint).
285
+ * Regulatory-submission journeys with 25-40 states are legitimate.
286
+ */
287
+ export declare const DEFAULT_STATE_HARD_LIMIT = 100;
288
+ /**
289
+ * OQ-2 default v1 workaround message: operator-actionable guidance when
290
+ * a journey's state count reaches the soft-warn threshold.
291
+ */
292
+ export declare const DEFAULT_STATE_SOFT_WARN_MESSAGE: string;
293
+ /** OQ-3 default: auto-promote sub-flow activation at 2 distinct adopter requests. */
294
+ export declare const DEFAULT_SUB_FLOW_ACTIVATION_THRESHOLD = 2;
295
+ /**
296
+ * Validate a Soul DID's (or Variant's) `journeys[]` declarations against
297
+ * RFC-0018 §5.3 rules.
298
+ *
299
+ * Returns all emitted events. Callers check `event.blocking` to determine
300
+ * whether the Soul DID should be rejected. Caller's responsibility to write
301
+ * events to events.jsonl via the artifact layer.
302
+ *
303
+ * Validation rules (in order):
304
+ *
305
+ * 1. **Hard-limit check (OQ-1)** — if `journeys.length >= hardLimit`, emit
306
+ * `JourneyCountHardLimitExceeded` (blocking). Continue to check individual
307
+ * journeys for completeness of the error report.
308
+ *
309
+ * 2. **Soft-warn check (OQ-1)** — if `journeys.length >= softWarnAt` AND
310
+ * below hard limit, emit `JourneyCountSoftWarning` (non-blocking).
311
+ *
312
+ * 3. **Per-journey checks** — for each journey:
313
+ * a. Nested-journey rejection (OQ-3) — if journey has `journeys` key,
314
+ * emit `NestedJourneyRejected` (blocking).
315
+ * b. Inheritance violation check (§5.3) — for each locked field
316
+ * (`complianceRegimes`, `targetAudience`, `substrateInvariants`), if
317
+ * present on the journey emit `JourneyInheritanceViolation` (blocking).
318
+ * c. `complianceFloor` check — if scope=variant and complianceFloor is
319
+ * present but not 'inherit', emit `JourneyInheritanceViolation` (blocking).
320
+ * d. WCAG-level lowering check — if parentWcagLevel provided and journey's
321
+ * wcagLevel is LOWER than parent, emit `JourneyInheritanceViolation`
322
+ * (blocking).
323
+ * e. State count checks (OQ-2) — per-journey state count against
324
+ * stateLimits.hardLimit / stateLimits.softWarnAt.
325
+ */
326
+ export declare function validateJourneyDeclarations(options: ValidateJourneyDeclarationsOptions): JourneyEvent[];
327
+ /**
328
+ * Convenience predicate: returns true when any event in the list is blocking.
329
+ * Use to decide whether to reject the Soul DID declaration.
330
+ */
331
+ export declare function hasBlockingJourneyViolations(events: JourneyEvent[]): boolean;
332
+ /**
333
+ * Represents a single adopter request for journey sub-flow (nested journey)
334
+ * activation. Used by `trackSubFlowActivationRequest` to accumulate distinct
335
+ * adopter signals.
336
+ */
337
+ export interface SubFlowActivationRequest {
338
+ /** Adopter identifier (e.g. org slug, soul id, adopter name). Used for deduplication. */
339
+ requestedBy: string;
340
+ /** Journey the request pertains to (for context; not used in deduplication). */
341
+ journeyId?: string;
342
+ /** Soul the request pertains to (for context; not used in deduplication). */
343
+ soulId?: string;
344
+ }
345
+ /**
346
+ * Track a stage-A counter of distinct adopter requests for journey sub-flow
347
+ * activation (RFC-0018 OQ-3 resolution, AISDLC-465 AC #10).
348
+ *
349
+ * v1 does NOT activate sub-flows — this is a pure counter. Its purpose is to
350
+ * accumulate demand signal until `threshold` distinct adopters have requested
351
+ * the capability, at which point `promotedToOperatorReview: true` signals that
352
+ * a follow-on RFC discussion should be opened.
353
+ *
354
+ * Adopter deduplication is based on `request.requestedBy`. Multiple requests
355
+ * from the same adopter count as one distinct request.
356
+ *
357
+ * All requests route through RFC-0035 G0 (non-blocking pipeline contract).
358
+ *
359
+ * ### Usage
360
+ *
361
+ * ```ts
362
+ * const result = trackSubFlowActivationRequests([
363
+ * { requestedBy: 'adopter-acme', journeyId: 'onboarding', soulId: 'spry-engage' },
364
+ * { requestedBy: 'adopter-beta' },
365
+ * ], { distinctAdopterRequestsThreshold: 2 });
366
+ *
367
+ * // result.distinctAdopterCount === 2
368
+ * // result.promotedToOperatorReview === true (threshold reached)
369
+ * ```
370
+ *
371
+ * @param requests Accumulated adopter activation requests (may include duplicates).
372
+ * @param config Per-org counter configuration (threshold defaults to 2).
373
+ */
374
+ export declare function trackSubFlowActivationRequests(requests: SubFlowActivationRequest[], config?: SubFlowActivationConfig): SubFlowActivationCounterResult;
375
+ /**
376
+ * Parse a `targetedJourneys` URI entry per RFC-0018 §6.1.
377
+ *
378
+ * Two forms:
379
+ * - Soul-scoped: `<soul-id>/<journey-id>`
380
+ * - Variant-scoped: `<soul-id>/<variant-id>/<journey-id>`
381
+ *
382
+ * Returns `null` when the URI does not match either form.
383
+ */
384
+ export interface ParsedTargetedJourneyRef {
385
+ readonly soulId: string;
386
+ readonly variantId?: string;
387
+ readonly journeyId: string;
388
+ }
389
+ /**
390
+ * Parse a `targetedJourneys` URI entry into its component parts.
391
+ *
392
+ * @param raw Raw URI string from the work item's `targetedJourneys[]` field.
393
+ * @returns Parsed components or null if the URI is malformed.
394
+ */
395
+ export declare function parseTargetedJourneyRef(raw: string): ParsedTargetedJourneyRef | null;
396
+ //# sourceMappingURL=inheritance-validator.d.ts.map