@principles/core 1.293.1 → 1.293.3

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 (59) hide show
  1. package/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts.map +1 -1
  2. package/dist/runtime-v2/adapter/artificer-l2-adapter.js +28 -9
  3. package/dist/runtime-v2/adapter/artificer-l2-adapter.js.map +1 -1
  4. package/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
  5. package/dist/runtime-v2/adapter/l2-agent-loop-adapter.js +29 -9
  6. package/dist/runtime-v2/adapter/l2-agent-loop-adapter.js.map +1 -1
  7. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +6 -0
  8. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  9. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +105 -1
  10. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  11. package/dist/runtime-v2/index.d.ts +6 -2
  12. package/dist/runtime-v2/index.d.ts.map +1 -1
  13. package/dist/runtime-v2/index.js +3 -1
  14. package/dist/runtime-v2/index.js.map +1 -1
  15. package/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts +154 -0
  16. package/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts.map +1 -0
  17. package/dist/runtime-v2/internalization/artificer-intent-preflight.js +686 -0
  18. package/dist/runtime-v2/internalization/artificer-intent-preflight.js.map +1 -0
  19. package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +21 -3
  20. package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  21. package/dist/runtime-v2/internalization/artificer-prompt-builder.js +48 -5
  22. package/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  23. package/dist/runtime-v2/internalization/artificer-runner.d.ts +17 -0
  24. package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  25. package/dist/runtime-v2/internalization/artificer-runner.js +45 -2
  26. package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  27. package/dist/runtime-v2/internalization/behavior-example-pack.d.ts +0 -19
  28. package/dist/runtime-v2/internalization/behavior-example-pack.d.ts.map +1 -1
  29. package/dist/runtime-v2/internalization/behavior-example-pack.js +31 -0
  30. package/dist/runtime-v2/internalization/behavior-example-pack.js.map +1 -1
  31. package/dist/runtime-v2/internalization/intent-contract.d.ts +31 -0
  32. package/dist/runtime-v2/internalization/intent-contract.d.ts.map +1 -1
  33. package/dist/runtime-v2/internalization/intent-contract.js +42 -0
  34. package/dist/runtime-v2/internalization/intent-contract.js.map +1 -1
  35. package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +14 -1
  36. package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
  37. package/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
  38. package/dist/runtime-v2/internalization/pitask-metadata.d.ts +64 -0
  39. package/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
  40. package/dist/runtime-v2/internalization/pitask-metadata.js +84 -0
  41. package/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
  42. package/dist/runtime-v2/internalization/scribe-output.d.ts +13 -1
  43. package/dist/runtime-v2/internalization/scribe-output.d.ts.map +1 -1
  44. package/dist/runtime-v2/internalization/scribe-output.js +13 -1
  45. package/dist/runtime-v2/internalization/scribe-output.js.map +1 -1
  46. package/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +15 -1
  47. package/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
  48. package/dist/runtime-v2/internalization/scribe-prompt-builder.js +29 -1
  49. package/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
  50. package/dist/runtime-v2/tools/agent-tool-contract.d.ts +2 -1
  51. package/dist/runtime-v2/tools/agent-tool-contract.d.ts.map +1 -1
  52. package/dist/runtime-v2/tools/agent-tool-contract.js +1 -1
  53. package/dist/runtime-v2/tools/agent-tool-contract.js.map +1 -1
  54. package/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts +1 -1
  55. package/dist/telemetry-event.d.ts +4 -2
  56. package/dist/telemetry-event.d.ts.map +1 -1
  57. package/dist/telemetry-event.js +12 -0
  58. package/dist/telemetry-event.js.map +1 -1
  59. package/package.json +3 -3
@@ -0,0 +1,154 @@
1
+ import { type ScribeExecutionConditionsV1 } from './intent-contract.js';
2
+ import type { StoreEventEmitter } from '../store/event-emitter.js';
3
+ import type { RuntimeStateManager } from '../store/runtime-state-manager.js';
4
+ import type { PIArtifactStore } from './pi-artifact.js';
5
+ import type { PITaskRecord } from './peer-runner-contracts.js';
6
+ import { SOURCE_FAULT_PERSISTENT_REASON_CODE, type IntentBasisVerificationRecordV1 } from './pitask-metadata.js';
7
+ /** SPEC 7.2 four-state resolution, fixed field meanings (see pitask-metadata.ts). */
8
+ export type { TrustedFactResolutionKind } from './pitask-metadata.js';
9
+ export interface TrustedFactResolution {
10
+ readonly resolution: 'approved' | 'not_approved' | 'not_required' | 'unknown';
11
+ /** Bounded human-readable context (rc-8); never carries credentials. */
12
+ readonly detail?: string;
13
+ }
14
+ /**
15
+ * Host-injected trusted-facts port (SPEC 8.3 seam — the B2/B3 provider
16
+ * surface). ABSENT in production today (Codex has no trusted approval
17
+ * source); absence + a declared required fact is an UNSUPPORTED stop, not a
18
+ * transient error. Implementations must be side-effect free and must never
19
+ * accept facts from the generating model.
20
+ */
21
+ export interface ArtificerTrustedFactsPort {
22
+ resolveRequiredFact(request: {
23
+ factKind: string;
24
+ taskId: string;
25
+ }): TrustedFactResolution;
26
+ }
27
+ /** Stable stop-point reason codes (Owner-facing vocabulary, SPEC 5.3). */
28
+ export type IntentBasisStopReasonCode = 'scribe_dependency_unresolved' | 'scribe_artifact_unparseable' | 'intent_contract_missing' | 'intent_contract_invalid' | 'execution_conditions_missing' | 'execution_conditions_invalid' | 'required_fact_conflict' | 'upstream_material_unavailable' | 'approval_dependency_undeclared' | 'textual_basis_unanchored' | 'trusted_fact_provider_absent' | 'trusted_fact_unknown' | typeof SOURCE_FAULT_PERSISTENT_REASON_CODE;
29
+ export type ArtificerIntentPreflightVerdict = {
30
+ readonly decision: 'executable';
31
+ readonly record: IntentBasisVerificationRecordV1;
32
+ /** Whether the record durably landed in task metadata (false = CAS lost to a concurrent writer). */
33
+ readonly recordPersisted: boolean;
34
+ } | {
35
+ readonly decision: 'blocked';
36
+ /** SPEC 5.3 logical result (stable coarse vocabulary). */
37
+ readonly logicalResult: 'intent_unverified' | 'intent_conflict' | 'unsupported' | 'needs_evidence';
38
+ /** Specific stable reason code (the actionable form of logicalResult). */
39
+ readonly reasonCode: IntentBasisStopReasonCode;
40
+ readonly detail: string;
41
+ readonly nextAction: string;
42
+ /** Whether the needs_human_review transition durably landed (CAS + read-back). */
43
+ readonly reviewPersisted: boolean;
44
+ } | {
45
+ /** Transient source I/O: task stays wake-eligible; bounded technical retry (Q21). */
46
+ readonly decision: 'source_error';
47
+ readonly reason: 'source_error';
48
+ readonly detail: string;
49
+ readonly nextAction: string;
50
+ } | {
51
+ /** 3rd consecutive transient fault: auto-retry ends (Q22), reviewable terminal. */
52
+ readonly decision: 'source_fault_persistent';
53
+ readonly reasonCode: typeof SOURCE_FAULT_PERSISTENT_REASON_CODE;
54
+ readonly detail: string;
55
+ readonly nextAction: string;
56
+ readonly reviewPersisted: boolean;
57
+ };
58
+ export interface ArtificerIntentPreflightParams {
59
+ readonly taskId: string;
60
+ /** Hydrated task record (channel already resolved by the caller). */
61
+ readonly piTask: PITaskRecord;
62
+ /** Lease-owner label for telemetry sessionId. */
63
+ readonly owner: string;
64
+ readonly workspaceDir?: string;
65
+ readonly stateManager: Pick<RuntimeStateManager, 'getTask' | 'updateTaskIfDiagnosticJsonUnchanged'> & {
66
+ piArtifactStore: PIArtifactStore;
67
+ };
68
+ readonly eventEmitter: StoreEventEmitter;
69
+ /** Optional host trusted-facts port; absent = host capability gap. */
70
+ readonly trustedFacts?: ArtificerTrustedFactsPort;
71
+ /**
72
+ * Test seam for store-fault injection: overrides the artifact listing used
73
+ * to resolve the scribe artifact. Production never passes it.
74
+ */
75
+ readonly artifactStore?: Pick<PIArtifactStore, 'listBySourceTaskId'>;
76
+ }
77
+ /**
78
+ * Lineage marker for intent NHR transitions (honest by construction — same
79
+ * convention as ARTIFICER_EVIDENCE_NHR_SOURCE_RUN_ID: no lease-minted run
80
+ * exists for a pure preflight block).
81
+ */
82
+ export declare const ARTIFICER_INTENT_NHR_SOURCE_RUN_ID = "intent-preflight";
83
+ type TaskWriteParams = Pick<ArtificerIntentPreflightParams, 'taskId' | 'piTask' | 'stateManager'>;
84
+ /**
85
+ * Shared upstream-material resolver (entry preflight AND the runner's
86
+ * defensive mirror use the SAME walk so the mirror can never be weaker than
87
+ * the gate).
88
+ */
89
+ export declare function collectUpstreamNormalisedText(getTask: (taskId: string) => Promise<{
90
+ taskKind: string;
91
+ status: string;
92
+ } | null>, listBySourceTaskId: (sourceTaskId: string) => Promise<readonly {
93
+ contentJson: string;
94
+ }[]>, scribeDependencyTaskIds: readonly string[]): Promise<{
95
+ normalisedText: string;
96
+ } | null>;
97
+ interface IntentAssessmentStop {
98
+ readonly status: 'intent_unverified' | 'intent_conflict' | 'unsupported' | 'needs_evidence';
99
+ readonly reasonCode: IntentBasisStopReasonCode;
100
+ readonly detail: string;
101
+ readonly nextAction: string;
102
+ }
103
+ interface IntentAssessmentExecutable {
104
+ readonly status: 'executable';
105
+ readonly conditions: ScribeExecutionConditionsV1;
106
+ readonly requiredFacts: readonly {
107
+ factKind: string;
108
+ resolution: TrustedFactResolution['resolution'];
109
+ }[];
110
+ }
111
+ type IntentAssessment = IntentAssessmentExecutable | IntentAssessmentStop;
112
+ /**
113
+ * The pure decision core (no I/O): assess the intent basis from the resolved
114
+ * scribe artifact. Deterministic — no LLM, no keyword approval detection; the
115
+ * condition basis is the scribe's structured declaration, never prose parsed
116
+ * at this gate.
117
+ */
118
+ export declare function assessIntentBasis(input: {
119
+ scribeArtifact: {
120
+ artifactId: string;
121
+ contentJson: string;
122
+ } | null;
123
+ /** Upstream (philosopher) material pool. null = unresolvable → STOP (R3: the verdict may never rest on the scribe artifact alone). */
124
+ upstreamMaterial: {
125
+ normalisedText: string;
126
+ } | null;
127
+ trustedFacts?: ArtificerTrustedFactsPort;
128
+ taskId: string;
129
+ }): IntentAssessment;
130
+ /**
131
+ * Run the intent-basis preflight for one code_tool_hook Artificer task.
132
+ * The caller owns channel resolution; this module never re-guesses channels.
133
+ */
134
+ export declare function preflightArtificerIntentBasis(params: ArtificerIntentPreflightParams): Promise<ArtificerIntentPreflightVerdict>;
135
+ /**
136
+ * Shared bounded source-fault advancement (SPEC §9) — used by the intent
137
+ * preflight AND the consumer cycle's evidence_source_error branch, so BOTH
138
+ * pre-model source faults share one restart-durable counter/terminal. Pure
139
+ * state layer: telemetry belongs to the caller.
140
+ *
141
+ * Returns true when the fault count reached the cap and the task durably
142
+ * landed in the source_fault_persistent needs_human_review terminal (the
143
+ * final backoff record rides the SAME atomic write); false while the task
144
+ * stays wake-eligible with an incremented counter and 1-then-2-cycle backoff.
145
+ */
146
+ export declare function advanceSourceFaultBackoff(params: TaskWriteParams, faultDetail: string): Promise<boolean>;
147
+ /**
148
+ * Consume one backoff skip cycle (consumer-cycle entry point): returns true
149
+ * when the task must be SKIPPED this cycle (a skip was pending and has been
150
+ * durably decremented). A failed decrement (CAS loss) reads as "do not skip"
151
+ * — the next preflight re-assesses with fresh state (rc-7).
152
+ */
153
+ export declare function consumeSourceFaultBackoffSkip(taskId: string, piTask: PITaskRecord, stateManager: Pick<RuntimeStateManager, 'getTask' | 'updateTaskIfDiagnosticJsonUnchanged'>): Promise<boolean>;
154
+ //# sourceMappingURL=artificer-intent-preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artificer-intent-preflight.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-intent-preflight.ts"],"names":[],"mappings":"AA4CA,OAAO,EAAq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