@riddledc/riddle-proof 0.8.82 → 0.8.83

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.
package/README.md CHANGED
@@ -93,6 +93,7 @@ produces no certificate:
93
93
  import {
94
94
  createRiddleProofSemanticCertificate,
95
95
  composeRiddleProofSemanticCertificates,
96
+ matchRiddleProofSemanticCertificate,
96
97
  } from "@riddledc/riddle-proof/semantic-certificate";
97
98
 
98
99
  const quiet = createRiddleProofSemanticCertificate({
@@ -131,6 +132,36 @@ const behavior = composeRiddleProofSemanticCertificates({
131
132
  });
132
133
  ```
133
134
 
135
+ A later agent can consume one exact certificate without reopening its receipt
136
+ files. The expected content ID must arrive through the consumer's trusted
137
+ handoff or configuration; copying it from the same untrusted certificate would
138
+ not add trust:
139
+
140
+ ```ts
141
+ const match = matchRiddleProofSemanticCertificate({
142
+ certificate: JSON.parse(serializedCertificate),
143
+ expected_certificate_id: trustedHandoffCertificateId,
144
+ expected_scope: scope,
145
+ expected_claim: observedWaveCollisionBehaviorClaim,
146
+ expected_assurance: "declared_runtime_rule",
147
+ });
148
+
149
+ if (!match.ok) throw new Error(match.error.message);
150
+ // match.certificate is the exact scoped certificate this consumer requested.
151
+ ```
152
+
153
+ Matching first reparses the envelope and its content ID, then compares the
154
+ trusted expected ID, all five scope fields, claim ID/version/parameters, and
155
+ top-level assurance. It does no filesystem or network I/O, and a successful
156
+ match does not authenticate the issuer or the referenced evidence.
157
+
158
+ This is an exact root-certificate handoff, not independent proof-tree
159
+ reconstruction. A composite certificate retains compact immediate-premise
160
+ snapshots, not the full transitive certificate bodies. A consumer that does not
161
+ already trust the expected root ID needs a complete certificate closure plus a
162
+ contract/rule identity policy before it can independently inspect the whole
163
+ derivation.
164
+
134
165
  Composition requires the declared premise claims and exact scope equality. It
135
166
  copies compact premise snapshots into the derivation and sets the higher
136
167
  certificate's evidence to the ordered concatenation of premise evidence. The
@@ -34,6 +34,17 @@ var CERTIFICATE_FIELDS = /* @__PURE__ */ new Set([
34
34
  function isRecord(value) {
35
35
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
36
36
  }
37
+ function safeErrorMessage(error) {
38
+ try {
39
+ if (error instanceof Error) return String(error.message);
40
+ } catch {
41
+ }
42
+ try {
43
+ return String(error);
44
+ } catch {
45
+ return "unprintable thrown value";
46
+ }
47
+ }
37
48
  function assertOnlyKeys(record, allowed, context) {
38
49
  const allowedSet = new Set(allowed);
39
50
  for (const key of Object.keys(record)) {
@@ -371,6 +382,110 @@ function parseRiddleProofSemanticCertificate(value) {
371
382
  }
372
383
  return { ...body, certificate_id: observedId };
373
384
  }
385
+ function matchRiddleProofSemanticCertificate(input) {
386
+ if (!isRecord(input)) throw new Error("Semantic certificate match input must be an object.");
387
+ assertOnlyKeys(
388
+ input,
389
+ [
390
+ "certificate",
391
+ "expected_certificate_id",
392
+ "expected_scope",
393
+ "expected_claim",
394
+ "expected_assurance"
395
+ ],
396
+ "semantic certificate match input"
397
+ );
398
+ const expectedCertificateId = requiredString(
399
+ input,
400
+ "expected_certificate_id",
401
+ "semantic certificate match input"
402
+ );
403
+ if (!/^rpsc_[0-9a-f]{64}$/u.test(expectedCertificateId)) {
404
+ throw new Error(
405
+ "Semantic certificate match input.expected_certificate_id must be a full rpsc content ID."
406
+ );
407
+ }
408
+ const expectedScope = parseScope(
409
+ input.expected_scope,
410
+ "semantic certificate match expected_scope"
411
+ );
412
+ const expectedClaim = parseClaimRef(
413
+ input.expected_claim,
414
+ "semantic certificate match expected_claim",
415
+ ["label"]
416
+ );
417
+ const expectedAssurance = requiredString(
418
+ input,
419
+ "expected_assurance",
420
+ "semantic certificate match input"
421
+ );
422
+ if (expectedAssurance !== "runtime_contract_accepted" && expectedAssurance !== "declared_runtime_rule") {
423
+ throw new Error(
424
+ "Semantic certificate match input.expected_assurance must be runtime_contract_accepted or declared_runtime_rule."
425
+ );
426
+ }
427
+ let certificate;
428
+ try {
429
+ certificate = parseRiddleProofSemanticCertificate(input.certificate);
430
+ } catch (error) {
431
+ return {
432
+ ok: false,
433
+ error: {
434
+ code: "invalid_certificate",
435
+ message: `Semantic certificate did not parse: ${safeErrorMessage(error)}`
436
+ }
437
+ };
438
+ }
439
+ if (certificate.certificate_id !== expectedCertificateId) {
440
+ return {
441
+ ok: false,
442
+ error: {
443
+ code: "certificate_id_mismatch",
444
+ expected: expectedCertificateId,
445
+ observed: certificate.certificate_id,
446
+ message: "Semantic certificate does not match the trusted expected content ID."
447
+ }
448
+ };
449
+ }
450
+ const scopeMismatch = firstScopeMismatch(expectedScope, certificate.scope);
451
+ if (scopeMismatch) {
452
+ return {
453
+ ok: false,
454
+ error: {
455
+ code: "scope_mismatch",
456
+ ...scopeMismatch,
457
+ message: `Semantic certificate has a different ${scopeMismatch.field} than the consumer expected.`
458
+ }
459
+ };
460
+ }
461
+ if (!sameClaimRef(expectedClaim, certificate.claim)) {
462
+ return {
463
+ ok: false,
464
+ error: {
465
+ code: "claim_mismatch",
466
+ expected: expectedClaim,
467
+ observed: parseClaimRef(
468
+ certificate.claim,
469
+ "semantic certificate match observed claim",
470
+ ["label"]
471
+ ),
472
+ message: "Semantic certificate does not state the claim the consumer expected."
473
+ }
474
+ };
475
+ }
476
+ if (certificate.derivation.assurance !== expectedAssurance) {
477
+ return {
478
+ ok: false,
479
+ error: {
480
+ code: "assurance_mismatch",
481
+ expected: expectedAssurance,
482
+ observed: certificate.derivation.assurance,
483
+ message: "Semantic certificate does not have the assurance the consumer expected."
484
+ }
485
+ };
486
+ }
487
+ return { ok: true, certificate };
488
+ }
374
489
  function firstScopeMismatch(expected, observed) {
375
490
  for (const field of SCOPE_FIELDS) {
376
491
  if (expected[field] !== observed[field]) {
@@ -465,5 +580,6 @@ export {
465
580
  riddleProofSemanticScopesEqual,
466
581
  createRiddleProofSemanticCertificate,
467
582
  parseRiddleProofSemanticCertificate,
583
+ matchRiddleProofSemanticCertificate,
468
584
  composeRiddleProofSemanticCertificates
469
585
  };
package/dist/index.cjs CHANGED
@@ -3520,6 +3520,7 @@ __export(index_exports, {
3520
3520
  isSuccessfulStatus: () => isSuccessfulStatus,
3521
3521
  isTerminalRiddleJobStatus: () => isTerminalRiddleJobStatus,
3522
3522
  isTerminalStatus: () => isTerminalStatus,
3523
+ matchRiddleProofSemanticCertificate: () => matchRiddleProofSemanticCertificate,
3523
3524
  migrateRiddleProofChangeReceipt: () => migrateRiddleProofChangeReceipt,
3524
3525
  nonEmptyString: () => nonEmptyString,
3525
3526
  normalizeCheckpointResponse: () => normalizeCheckpointResponse,
@@ -20607,6 +20608,17 @@ var CERTIFICATE_FIELDS = /* @__PURE__ */ new Set([
20607
20608
  function isRecord4(value) {
20608
20609
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
20609
20610
  }
20611
+ function safeErrorMessage(error) {
20612
+ try {
20613
+ if (error instanceof Error) return String(error.message);
20614
+ } catch {
20615
+ }
20616
+ try {
20617
+ return String(error);
20618
+ } catch {
20619
+ return "unprintable thrown value";
20620
+ }
20621
+ }
20610
20622
  function assertOnlyKeys(record, allowed, context) {
20611
20623
  const allowedSet = new Set(allowed);
20612
20624
  for (const key of Object.keys(record)) {
@@ -20944,6 +20956,110 @@ function parseRiddleProofSemanticCertificate(value) {
20944
20956
  }
20945
20957
  return { ...body, certificate_id: observedId };
20946
20958
  }
20959
+ function matchRiddleProofSemanticCertificate(input) {
20960
+ if (!isRecord4(input)) throw new Error("Semantic certificate match input must be an object.");
20961
+ assertOnlyKeys(
20962
+ input,
20963
+ [
20964
+ "certificate",
20965
+ "expected_certificate_id",
20966
+ "expected_scope",
20967
+ "expected_claim",
20968
+ "expected_assurance"
20969
+ ],
20970
+ "semantic certificate match input"
20971
+ );
20972
+ const expectedCertificateId = requiredString2(
20973
+ input,
20974
+ "expected_certificate_id",
20975
+ "semantic certificate match input"
20976
+ );
20977
+ if (!/^rpsc_[0-9a-f]{64}$/u.test(expectedCertificateId)) {
20978
+ throw new Error(
20979
+ "Semantic certificate match input.expected_certificate_id must be a full rpsc content ID."
20980
+ );
20981
+ }
20982
+ const expectedScope = parseScope(
20983
+ input.expected_scope,
20984
+ "semantic certificate match expected_scope"
20985
+ );
20986
+ const expectedClaim = parseClaimRef(
20987
+ input.expected_claim,
20988
+ "semantic certificate match expected_claim",
20989
+ ["label"]
20990
+ );
20991
+ const expectedAssurance = requiredString2(
20992
+ input,
20993
+ "expected_assurance",
20994
+ "semantic certificate match input"
20995
+ );
20996
+ if (expectedAssurance !== "runtime_contract_accepted" && expectedAssurance !== "declared_runtime_rule") {
20997
+ throw new Error(
20998
+ "Semantic certificate match input.expected_assurance must be runtime_contract_accepted or declared_runtime_rule."
20999
+ );
21000
+ }
21001
+ let certificate;
21002
+ try {
21003
+ certificate = parseRiddleProofSemanticCertificate(input.certificate);
21004
+ } catch (error) {
21005
+ return {
21006
+ ok: false,
21007
+ error: {
21008
+ code: "invalid_certificate",
21009
+ message: `Semantic certificate did not parse: ${safeErrorMessage(error)}`
21010
+ }
21011
+ };
21012
+ }
21013
+ if (certificate.certificate_id !== expectedCertificateId) {
21014
+ return {
21015
+ ok: false,
21016
+ error: {
21017
+ code: "certificate_id_mismatch",
21018
+ expected: expectedCertificateId,
21019
+ observed: certificate.certificate_id,
21020
+ message: "Semantic certificate does not match the trusted expected content ID."
21021
+ }
21022
+ };
21023
+ }
21024
+ const scopeMismatch = firstScopeMismatch(expectedScope, certificate.scope);
21025
+ if (scopeMismatch) {
21026
+ return {
21027
+ ok: false,
21028
+ error: {
21029
+ code: "scope_mismatch",
21030
+ ...scopeMismatch,
21031
+ message: `Semantic certificate has a different ${scopeMismatch.field} than the consumer expected.`
21032
+ }
21033
+ };
21034
+ }
21035
+ if (!sameClaimRef(expectedClaim, certificate.claim)) {
21036
+ return {
21037
+ ok: false,
21038
+ error: {
21039
+ code: "claim_mismatch",
21040
+ expected: expectedClaim,
21041
+ observed: parseClaimRef(
21042
+ certificate.claim,
21043
+ "semantic certificate match observed claim",
21044
+ ["label"]
21045
+ ),
21046
+ message: "Semantic certificate does not state the claim the consumer expected."
21047
+ }
21048
+ };
21049
+ }
21050
+ if (certificate.derivation.assurance !== expectedAssurance) {
21051
+ return {
21052
+ ok: false,
21053
+ error: {
21054
+ code: "assurance_mismatch",
21055
+ expected: expectedAssurance,
21056
+ observed: certificate.derivation.assurance,
21057
+ message: "Semantic certificate does not have the assurance the consumer expected."
21058
+ }
21059
+ };
21060
+ }
21061
+ return { ok: true, certificate };
21062
+ }
20947
21063
  function firstScopeMismatch(expected, observed) {
20948
21064
  for (const field of SCOPE_FIELDS) {
20949
21065
  if (expected[field] !== observed[field]) {
@@ -23161,6 +23277,7 @@ function buildRiddleProofPrCommentMarkdown(input) {
23161
23277
  isSuccessfulStatus,
23162
23278
  isTerminalRiddleJobStatus,
23163
23279
  isTerminalStatus,
23280
+ matchRiddleProofSemanticCertificate,
23164
23281
  migrateRiddleProofChangeReceipt,
23165
23282
  nonEmptyString,
23166
23283
  normalizeCheckpointResponse,
package/dist/index.d.cts CHANGED
@@ -14,7 +14,7 @@ export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_G
14
14
  export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_ORDERED_TRACE_OPERATORS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofOrderedTraceAssessment, RiddleProofOrderedTraceEvent, RiddleProofOrderedTraceOperator, RiddleProofOrderedTracePredicate, RiddleProofOrderedTraceWitness, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofOrderedTrace, assessRiddleProofOrderedTraceSetupResults, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.cjs';
15
15
  export { RIDDLE_PROOF_PROFILE_SUGGESTIONS_VERSION, RiddleProofProfileChangedTextInput, RiddleProofProfileSuggestion, RiddleProofProfileSuggestionInput, RiddleProofProfileSuggestionsResult, suggestRiddleProofProfileChecks } from './profile-suggestions.cjs';
16
16
  export { CreateRiddleProofObservationReceiptInput, RIDDLE_PREVIEW_RECEIPT_VERSION, RIDDLE_PROOF_OBSERVATION_RECEIPT_VERSION, RiddlePreviewReceipt, RiddleProofComparisonRole, RiddleProofExecutionPhase, RiddleProofExecutionTelemetry, RiddleProofObservationArtifact, RiddleProofObservationArtifactRole, RiddleProofObservationExecutor, RiddleProofObservationExecutorKind, RiddleProofObservationPublication, RiddleProofObservationReceipt, RiddleProofObservationTarget, RiddleProofSourceIdentity, createRiddleProofObservationReceipt, parseRiddlePreviewReceipt, parseRiddleProofObservationReceipt } from './receipts.cjs';
17
- export { ComposeRiddleProofSemanticCertificatesInput, CreateRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, RiddleProofSemanticCertificate, RiddleProofSemanticCertificationResult, RiddleProofSemanticClaim, RiddleProofSemanticClaimRef, RiddleProofSemanticCompositionDerivation, RiddleProofSemanticCompositionError, RiddleProofSemanticCompositionResult, RiddleProofSemanticContract, RiddleProofSemanticContractDerivation, RiddleProofSemanticContractError, RiddleProofSemanticContractRef, RiddleProofSemanticContractRejected, RiddleProofSemanticDerivation, RiddleProofSemanticEvidenceBundle, RiddleProofSemanticEvidenceRef, RiddleProofSemanticPremise, RiddleProofSemanticPremiseCountMismatch, RiddleProofSemanticPremiseMismatch, RiddleProofSemanticRule, RiddleProofSemanticRuntimeContract, RiddleProofSemanticScope, RiddleProofSemanticScopeField, RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual } from './semantic-certificate.cjs';
17
+ export { ComposeRiddleProofSemanticCertificatesInput, CreateRiddleProofSemanticCertificateInput, MatchRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, RiddleProofSemanticAssurance, RiddleProofSemanticCertificate, RiddleProofSemanticCertificateAssuranceMismatch, RiddleProofSemanticCertificateClaimMismatch, RiddleProofSemanticCertificateIdMismatch, RiddleProofSemanticCertificateInvalid, RiddleProofSemanticCertificateMatchError, RiddleProofSemanticCertificateMatchResult, RiddleProofSemanticCertificateMatchScopeMismatch, RiddleProofSemanticCertificationResult, RiddleProofSemanticClaim, RiddleProofSemanticClaimExpectation, RiddleProofSemanticClaimRef, RiddleProofSemanticCompositionDerivation, RiddleProofSemanticCompositionError, RiddleProofSemanticCompositionResult, RiddleProofSemanticContract, RiddleProofSemanticContractDerivation, RiddleProofSemanticContractError, RiddleProofSemanticContractRef, RiddleProofSemanticContractRejected, RiddleProofSemanticDerivation, RiddleProofSemanticEvidenceBundle, RiddleProofSemanticEvidenceRef, RiddleProofSemanticPremise, RiddleProofSemanticPremiseCountMismatch, RiddleProofSemanticPremiseMismatch, RiddleProofSemanticRule, RiddleProofSemanticRuntimeContract, RiddleProofSemanticScope, RiddleProofSemanticScopeField, RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, matchRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual } from './semantic-certificate.cjs';
18
18
  export { AssessRiddleProofChangeInput, CreateRiddleProofChangeReceiptInput, RIDDLE_PROOF_CHANGE_CONTRACT_VERSION, RIDDLE_PROOF_CHANGE_RECEIPT_V1_VERSION, RIDDLE_PROOF_CHANGE_RECEIPT_VERSION, RIDDLE_PROOF_CHANGE_RESULT_VERSION, RIDDLE_PROOF_HANDOFF_RECEIPT_VERSION, RiddleProofChangeContract, RiddleProofChangeDelta, RiddleProofChangeDeltaResult, RiddleProofChangeDeltaStatus, RiddleProofChangeGroupContract, RiddleProofChangeGroupResult, RiddleProofChangeProfileCheckStatus, RiddleProofChangeReceipt, RiddleProofChangeReceiptArtifact, RiddleProofChangeReceiptArtifactKind, RiddleProofChangeReceiptCheckCounts, RiddleProofChangeReceiptDelta, RiddleProofChangeReceiptSide, RiddleProofChangeReceiptVerdict, RiddleProofChangeRecommendation, RiddleProofChangeResult, RiddleProofChangeSide, RiddleProofChangeSourceBindingContract, RiddleProofChangeSourceBindingRequirement, RiddleProofChangeSourceBindingResult, RiddleProofChangeSourceBindingStatus, RiddleProofChangeStatus, RiddleProofCheckStatusTransitionDelta, RiddleProofHandoffReceipt, RiddleProofLegacyChangeReceipt, RiddleProofProfileStatusTransitionDelta, RiddleProofShippingAuthorization, assessRiddleProofChange, createRiddleProofChangeReceipt, createRiddleProofHandoffReceipt, migrateRiddleProofChangeReceipt, parseRiddleProofChangeReceipt, parseRiddleProofHandoffReceipt, riddleProofChangeReceiptHtml, riddleProofChangeReceiptMarkdown } from './change-proof.cjs';
19
19
  export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RIDDLE_UNSUBMITTED_WAKE_HINT, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployOptions, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, detectRiddlePreviewSource, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.cjs';
20
20
  export { RIDDLE_PROOF_PR_COMMENT_MARKER, RiddleProofPrCommentArtifact, RiddleProofPrCommentArtifactKind, RiddleProofPrCommentCheckpointSummary, RiddleProofPrCommentInput, RiddleProofPrCommentPageSummary, RiddleProofPrCommentSummary, buildRiddleProofHandoffPrCommentMarkdown, buildRiddleProofPrCommentMarkdown, summarizeRiddleProofPrComment } from './pr-comment.cjs';
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_G
14
14
  export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_ORDERED_TRACE_OPERATORS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofOrderedTraceAssessment, RiddleProofOrderedTraceEvent, RiddleProofOrderedTraceOperator, RiddleProofOrderedTracePredicate, RiddleProofOrderedTraceWitness, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofOrderedTrace, assessRiddleProofOrderedTraceSetupResults, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.js';
15
15
  export { RIDDLE_PROOF_PROFILE_SUGGESTIONS_VERSION, RiddleProofProfileChangedTextInput, RiddleProofProfileSuggestion, RiddleProofProfileSuggestionInput, RiddleProofProfileSuggestionsResult, suggestRiddleProofProfileChecks } from './profile-suggestions.js';
16
16
  export { CreateRiddleProofObservationReceiptInput, RIDDLE_PREVIEW_RECEIPT_VERSION, RIDDLE_PROOF_OBSERVATION_RECEIPT_VERSION, RiddlePreviewReceipt, RiddleProofComparisonRole, RiddleProofExecutionPhase, RiddleProofExecutionTelemetry, RiddleProofObservationArtifact, RiddleProofObservationArtifactRole, RiddleProofObservationExecutor, RiddleProofObservationExecutorKind, RiddleProofObservationPublication, RiddleProofObservationReceipt, RiddleProofObservationTarget, RiddleProofSourceIdentity, createRiddleProofObservationReceipt, parseRiddlePreviewReceipt, parseRiddleProofObservationReceipt } from './receipts.js';
17
- export { ComposeRiddleProofSemanticCertificatesInput, CreateRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, RiddleProofSemanticCertificate, RiddleProofSemanticCertificationResult, RiddleProofSemanticClaim, RiddleProofSemanticClaimRef, RiddleProofSemanticCompositionDerivation, RiddleProofSemanticCompositionError, RiddleProofSemanticCompositionResult, RiddleProofSemanticContract, RiddleProofSemanticContractDerivation, RiddleProofSemanticContractError, RiddleProofSemanticContractRef, RiddleProofSemanticContractRejected, RiddleProofSemanticDerivation, RiddleProofSemanticEvidenceBundle, RiddleProofSemanticEvidenceRef, RiddleProofSemanticPremise, RiddleProofSemanticPremiseCountMismatch, RiddleProofSemanticPremiseMismatch, RiddleProofSemanticRule, RiddleProofSemanticRuntimeContract, RiddleProofSemanticScope, RiddleProofSemanticScopeField, RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual } from './semantic-certificate.js';
17
+ export { ComposeRiddleProofSemanticCertificatesInput, CreateRiddleProofSemanticCertificateInput, MatchRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, RiddleProofSemanticAssurance, RiddleProofSemanticCertificate, RiddleProofSemanticCertificateAssuranceMismatch, RiddleProofSemanticCertificateClaimMismatch, RiddleProofSemanticCertificateIdMismatch, RiddleProofSemanticCertificateInvalid, RiddleProofSemanticCertificateMatchError, RiddleProofSemanticCertificateMatchResult, RiddleProofSemanticCertificateMatchScopeMismatch, RiddleProofSemanticCertificationResult, RiddleProofSemanticClaim, RiddleProofSemanticClaimExpectation, RiddleProofSemanticClaimRef, RiddleProofSemanticCompositionDerivation, RiddleProofSemanticCompositionError, RiddleProofSemanticCompositionResult, RiddleProofSemanticContract, RiddleProofSemanticContractDerivation, RiddleProofSemanticContractError, RiddleProofSemanticContractRef, RiddleProofSemanticContractRejected, RiddleProofSemanticDerivation, RiddleProofSemanticEvidenceBundle, RiddleProofSemanticEvidenceRef, RiddleProofSemanticPremise, RiddleProofSemanticPremiseCountMismatch, RiddleProofSemanticPremiseMismatch, RiddleProofSemanticRule, RiddleProofSemanticRuntimeContract, RiddleProofSemanticScope, RiddleProofSemanticScopeField, RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, matchRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual } from './semantic-certificate.js';
18
18
  export { AssessRiddleProofChangeInput, CreateRiddleProofChangeReceiptInput, RIDDLE_PROOF_CHANGE_CONTRACT_VERSION, RIDDLE_PROOF_CHANGE_RECEIPT_V1_VERSION, RIDDLE_PROOF_CHANGE_RECEIPT_VERSION, RIDDLE_PROOF_CHANGE_RESULT_VERSION, RIDDLE_PROOF_HANDOFF_RECEIPT_VERSION, RiddleProofChangeContract, RiddleProofChangeDelta, RiddleProofChangeDeltaResult, RiddleProofChangeDeltaStatus, RiddleProofChangeGroupContract, RiddleProofChangeGroupResult, RiddleProofChangeProfileCheckStatus, RiddleProofChangeReceipt, RiddleProofChangeReceiptArtifact, RiddleProofChangeReceiptArtifactKind, RiddleProofChangeReceiptCheckCounts, RiddleProofChangeReceiptDelta, RiddleProofChangeReceiptSide, RiddleProofChangeReceiptVerdict, RiddleProofChangeRecommendation, RiddleProofChangeResult, RiddleProofChangeSide, RiddleProofChangeSourceBindingContract, RiddleProofChangeSourceBindingRequirement, RiddleProofChangeSourceBindingResult, RiddleProofChangeSourceBindingStatus, RiddleProofChangeStatus, RiddleProofCheckStatusTransitionDelta, RiddleProofHandoffReceipt, RiddleProofLegacyChangeReceipt, RiddleProofProfileStatusTransitionDelta, RiddleProofShippingAuthorization, assessRiddleProofChange, createRiddleProofChangeReceipt, createRiddleProofHandoffReceipt, migrateRiddleProofChangeReceipt, parseRiddleProofChangeReceipt, parseRiddleProofHandoffReceipt, riddleProofChangeReceiptHtml, riddleProofChangeReceiptMarkdown } from './change-proof.js';
19
19
  export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RIDDLE_UNSUBMITTED_WAKE_HINT, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployOptions, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, detectRiddlePreviewSource, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.js';
20
20
  export { RIDDLE_PROOF_PR_COMMENT_MARKER, RiddleProofPrCommentArtifact, RiddleProofPrCommentArtifactKind, RiddleProofPrCommentCheckpointSummary, RiddleProofPrCommentInput, RiddleProofPrCommentPageSummary, RiddleProofPrCommentSummary, buildRiddleProofHandoffPrCommentMarkdown, buildRiddleProofPrCommentMarkdown, summarizeRiddleProofPrComment } from './pr-comment.js';
package/dist/index.js CHANGED
@@ -15,9 +15,10 @@ import {
15
15
  RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION,
16
16
  composeRiddleProofSemanticCertificates,
17
17
  createRiddleProofSemanticCertificate,
18
+ matchRiddleProofSemanticCertificate,
18
19
  parseRiddleProofSemanticCertificate,
19
20
  riddleProofSemanticScopesEqual
20
- } from "./chunk-ZZ6UNKJQ.js";
21
+ } from "./chunk-DB5ZHRUP.js";
21
22
  import {
22
23
  RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION,
23
24
  RIDDLE_PROOF_PLAYABILITY_VERSION,
@@ -323,6 +324,7 @@ export {
323
324
  isSuccessfulStatus,
324
325
  isTerminalRiddleJobStatus,
325
326
  isTerminalStatus,
327
+ matchRiddleProofSemanticCertificate,
326
328
  migrateRiddleProofChangeReceipt,
327
329
  nonEmptyString,
328
330
  normalizeCheckpointResponse,
@@ -23,6 +23,7 @@ __export(semantic_certificate_exports, {
23
23
  RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION: () => RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION,
24
24
  composeRiddleProofSemanticCertificates: () => composeRiddleProofSemanticCertificates,
25
25
  createRiddleProofSemanticCertificate: () => createRiddleProofSemanticCertificate,
26
+ matchRiddleProofSemanticCertificate: () => matchRiddleProofSemanticCertificate,
26
27
  parseRiddleProofSemanticCertificate: () => parseRiddleProofSemanticCertificate,
27
28
  riddleProofSemanticScopesEqual: () => riddleProofSemanticScopesEqual
28
29
  });
@@ -62,6 +63,17 @@ var CERTIFICATE_FIELDS = /* @__PURE__ */ new Set([
62
63
  function isRecord(value) {
63
64
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
64
65
  }
66
+ function safeErrorMessage(error) {
67
+ try {
68
+ if (error instanceof Error) return String(error.message);
69
+ } catch {
70
+ }
71
+ try {
72
+ return String(error);
73
+ } catch {
74
+ return "unprintable thrown value";
75
+ }
76
+ }
65
77
  function assertOnlyKeys(record, allowed, context) {
66
78
  const allowedSet = new Set(allowed);
67
79
  for (const key of Object.keys(record)) {
@@ -399,6 +411,110 @@ function parseRiddleProofSemanticCertificate(value) {
399
411
  }
400
412
  return { ...body, certificate_id: observedId };
401
413
  }
414
+ function matchRiddleProofSemanticCertificate(input) {
415
+ if (!isRecord(input)) throw new Error("Semantic certificate match input must be an object.");
416
+ assertOnlyKeys(
417
+ input,
418
+ [
419
+ "certificate",
420
+ "expected_certificate_id",
421
+ "expected_scope",
422
+ "expected_claim",
423
+ "expected_assurance"
424
+ ],
425
+ "semantic certificate match input"
426
+ );
427
+ const expectedCertificateId = requiredString(
428
+ input,
429
+ "expected_certificate_id",
430
+ "semantic certificate match input"
431
+ );
432
+ if (!/^rpsc_[0-9a-f]{64}$/u.test(expectedCertificateId)) {
433
+ throw new Error(
434
+ "Semantic certificate match input.expected_certificate_id must be a full rpsc content ID."
435
+ );
436
+ }
437
+ const expectedScope = parseScope(
438
+ input.expected_scope,
439
+ "semantic certificate match expected_scope"
440
+ );
441
+ const expectedClaim = parseClaimRef(
442
+ input.expected_claim,
443
+ "semantic certificate match expected_claim",
444
+ ["label"]
445
+ );
446
+ const expectedAssurance = requiredString(
447
+ input,
448
+ "expected_assurance",
449
+ "semantic certificate match input"
450
+ );
451
+ if (expectedAssurance !== "runtime_contract_accepted" && expectedAssurance !== "declared_runtime_rule") {
452
+ throw new Error(
453
+ "Semantic certificate match input.expected_assurance must be runtime_contract_accepted or declared_runtime_rule."
454
+ );
455
+ }
456
+ let certificate;
457
+ try {
458
+ certificate = parseRiddleProofSemanticCertificate(input.certificate);
459
+ } catch (error) {
460
+ return {
461
+ ok: false,
462
+ error: {
463
+ code: "invalid_certificate",
464
+ message: `Semantic certificate did not parse: ${safeErrorMessage(error)}`
465
+ }
466
+ };
467
+ }
468
+ if (certificate.certificate_id !== expectedCertificateId) {
469
+ return {
470
+ ok: false,
471
+ error: {
472
+ code: "certificate_id_mismatch",
473
+ expected: expectedCertificateId,
474
+ observed: certificate.certificate_id,
475
+ message: "Semantic certificate does not match the trusted expected content ID."
476
+ }
477
+ };
478
+ }
479
+ const scopeMismatch = firstScopeMismatch(expectedScope, certificate.scope);
480
+ if (scopeMismatch) {
481
+ return {
482
+ ok: false,
483
+ error: {
484
+ code: "scope_mismatch",
485
+ ...scopeMismatch,
486
+ message: `Semantic certificate has a different ${scopeMismatch.field} than the consumer expected.`
487
+ }
488
+ };
489
+ }
490
+ if (!sameClaimRef(expectedClaim, certificate.claim)) {
491
+ return {
492
+ ok: false,
493
+ error: {
494
+ code: "claim_mismatch",
495
+ expected: expectedClaim,
496
+ observed: parseClaimRef(
497
+ certificate.claim,
498
+ "semantic certificate match observed claim",
499
+ ["label"]
500
+ ),
501
+ message: "Semantic certificate does not state the claim the consumer expected."
502
+ }
503
+ };
504
+ }
505
+ if (certificate.derivation.assurance !== expectedAssurance) {
506
+ return {
507
+ ok: false,
508
+ error: {
509
+ code: "assurance_mismatch",
510
+ expected: expectedAssurance,
511
+ observed: certificate.derivation.assurance,
512
+ message: "Semantic certificate does not have the assurance the consumer expected."
513
+ }
514
+ };
515
+ }
516
+ return { ok: true, certificate };
517
+ }
402
518
  function firstScopeMismatch(expected, observed) {
403
519
  for (const field of SCOPE_FIELDS) {
404
520
  if (expected[field] !== observed[field]) {
@@ -492,6 +608,7 @@ function composeRiddleProofSemanticCertificates(input) {
492
608
  RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION,
493
609
  composeRiddleProofSemanticCertificates,
494
610
  createRiddleProofSemanticCertificate,
611
+ matchRiddleProofSemanticCertificate,
495
612
  parseRiddleProofSemanticCertificate,
496
613
  riddleProofSemanticScopesEqual
497
614
  });
@@ -17,6 +17,9 @@ interface RiddleProofSemanticClaimRef {
17
17
  interface RiddleProofSemanticClaim extends RiddleProofSemanticClaimRef {
18
18
  label: string;
19
19
  }
20
+ interface RiddleProofSemanticClaimExpectation extends RiddleProofSemanticClaimRef {
21
+ label?: string;
22
+ }
20
23
  interface RiddleProofSemanticEvidenceRef {
21
24
  receipt_id: string;
22
25
  artifact_digest: string;
@@ -46,10 +49,11 @@ interface RiddleProofSemanticRule {
46
49
  premises: [RiddleProofSemanticClaimRef, ...RiddleProofSemanticClaimRef[]];
47
50
  conclusion: RiddleProofSemanticClaim;
48
51
  }
52
+ type RiddleProofSemanticAssurance = "runtime_contract_accepted" | "declared_runtime_rule";
49
53
  interface RiddleProofSemanticPremise {
50
54
  certificate_id: string;
51
55
  derivation_kind: RiddleProofSemanticDerivation["kind"];
52
- assurance: RiddleProofSemanticDerivation["assurance"];
56
+ assurance: RiddleProofSemanticAssurance;
53
57
  scope: RiddleProofSemanticScope;
54
58
  claim: RiddleProofSemanticClaim;
55
59
  evidence: RiddleProofSemanticEvidenceBundle;
@@ -134,9 +138,54 @@ type RiddleProofSemanticCompositionResult = {
134
138
  ok: false;
135
139
  error: RiddleProofSemanticCompositionError;
136
140
  };
141
+ interface MatchRiddleProofSemanticCertificateInput {
142
+ certificate: unknown;
143
+ expected_certificate_id: string;
144
+ expected_scope: RiddleProofSemanticScope;
145
+ expected_claim: RiddleProofSemanticClaimExpectation;
146
+ expected_assurance: RiddleProofSemanticAssurance;
147
+ }
148
+ interface RiddleProofSemanticCertificateInvalid {
149
+ code: "invalid_certificate";
150
+ message: string;
151
+ }
152
+ interface RiddleProofSemanticCertificateIdMismatch {
153
+ code: "certificate_id_mismatch";
154
+ expected: string;
155
+ observed: string;
156
+ message: string;
157
+ }
158
+ interface RiddleProofSemanticCertificateMatchScopeMismatch {
159
+ code: "scope_mismatch";
160
+ field: RiddleProofSemanticScopeField;
161
+ expected: string;
162
+ observed: string;
163
+ message: string;
164
+ }
165
+ interface RiddleProofSemanticCertificateClaimMismatch {
166
+ code: "claim_mismatch";
167
+ expected: RiddleProofSemanticClaimRef;
168
+ observed: RiddleProofSemanticClaimRef;
169
+ message: string;
170
+ }
171
+ interface RiddleProofSemanticCertificateAssuranceMismatch {
172
+ code: "assurance_mismatch";
173
+ expected: RiddleProofSemanticAssurance;
174
+ observed: RiddleProofSemanticAssurance;
175
+ message: string;
176
+ }
177
+ type RiddleProofSemanticCertificateMatchError = RiddleProofSemanticCertificateInvalid | RiddleProofSemanticCertificateIdMismatch | RiddleProofSemanticCertificateMatchScopeMismatch | RiddleProofSemanticCertificateClaimMismatch | RiddleProofSemanticCertificateAssuranceMismatch;
178
+ type RiddleProofSemanticCertificateMatchResult = {
179
+ ok: true;
180
+ certificate: RiddleProofSemanticCertificate;
181
+ } | {
182
+ ok: false;
183
+ error: RiddleProofSemanticCertificateMatchError;
184
+ };
137
185
  declare function riddleProofSemanticScopesEqual(left: RiddleProofSemanticScope, right: RiddleProofSemanticScope): boolean;
138
186
  declare function createRiddleProofSemanticCertificate<Observation>(input: CreateRiddleProofSemanticCertificateInput<Observation>): RiddleProofSemanticCertificationResult;
139
187
  declare function parseRiddleProofSemanticCertificate(value: unknown): RiddleProofSemanticCertificate;
188
+ declare function matchRiddleProofSemanticCertificate(input: MatchRiddleProofSemanticCertificateInput): RiddleProofSemanticCertificateMatchResult;
140
189
  declare function composeRiddleProofSemanticCertificates(input: ComposeRiddleProofSemanticCertificatesInput): RiddleProofSemanticCompositionResult;
141
190
 
142
- export { type ComposeRiddleProofSemanticCertificatesInput, type CreateRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, type RiddleProofSemanticCertificate, type RiddleProofSemanticCertificationResult, type RiddleProofSemanticClaim, type RiddleProofSemanticClaimRef, type RiddleProofSemanticCompositionDerivation, type RiddleProofSemanticCompositionError, type RiddleProofSemanticCompositionResult, type RiddleProofSemanticContract, type RiddleProofSemanticContractDerivation, type RiddleProofSemanticContractError, type RiddleProofSemanticContractRef, type RiddleProofSemanticContractRejected, type RiddleProofSemanticDerivation, type RiddleProofSemanticEvidenceBundle, type RiddleProofSemanticEvidenceRef, type RiddleProofSemanticPremise, type RiddleProofSemanticPremiseCountMismatch, type RiddleProofSemanticPremiseMismatch, type RiddleProofSemanticRule, type RiddleProofSemanticRuntimeContract, type RiddleProofSemanticScope, type RiddleProofSemanticScopeField, type RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual };
191
+ export { type ComposeRiddleProofSemanticCertificatesInput, type CreateRiddleProofSemanticCertificateInput, type MatchRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, type RiddleProofSemanticAssurance, type RiddleProofSemanticCertificate, type RiddleProofSemanticCertificateAssuranceMismatch, type RiddleProofSemanticCertificateClaimMismatch, type RiddleProofSemanticCertificateIdMismatch, type RiddleProofSemanticCertificateInvalid, type RiddleProofSemanticCertificateMatchError, type RiddleProofSemanticCertificateMatchResult, type RiddleProofSemanticCertificateMatchScopeMismatch, type RiddleProofSemanticCertificationResult, type RiddleProofSemanticClaim, type RiddleProofSemanticClaimExpectation, type RiddleProofSemanticClaimRef, type RiddleProofSemanticCompositionDerivation, type RiddleProofSemanticCompositionError, type RiddleProofSemanticCompositionResult, type RiddleProofSemanticContract, type RiddleProofSemanticContractDerivation, type RiddleProofSemanticContractError, type RiddleProofSemanticContractRef, type RiddleProofSemanticContractRejected, type RiddleProofSemanticDerivation, type RiddleProofSemanticEvidenceBundle, type RiddleProofSemanticEvidenceRef, type RiddleProofSemanticPremise, type RiddleProofSemanticPremiseCountMismatch, type RiddleProofSemanticPremiseMismatch, type RiddleProofSemanticRule, type RiddleProofSemanticRuntimeContract, type RiddleProofSemanticScope, type RiddleProofSemanticScopeField, type RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, matchRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual };
@@ -17,6 +17,9 @@ interface RiddleProofSemanticClaimRef {
17
17
  interface RiddleProofSemanticClaim extends RiddleProofSemanticClaimRef {
18
18
  label: string;
19
19
  }
20
+ interface RiddleProofSemanticClaimExpectation extends RiddleProofSemanticClaimRef {
21
+ label?: string;
22
+ }
20
23
  interface RiddleProofSemanticEvidenceRef {
21
24
  receipt_id: string;
22
25
  artifact_digest: string;
@@ -46,10 +49,11 @@ interface RiddleProofSemanticRule {
46
49
  premises: [RiddleProofSemanticClaimRef, ...RiddleProofSemanticClaimRef[]];
47
50
  conclusion: RiddleProofSemanticClaim;
48
51
  }
52
+ type RiddleProofSemanticAssurance = "runtime_contract_accepted" | "declared_runtime_rule";
49
53
  interface RiddleProofSemanticPremise {
50
54
  certificate_id: string;
51
55
  derivation_kind: RiddleProofSemanticDerivation["kind"];
52
- assurance: RiddleProofSemanticDerivation["assurance"];
56
+ assurance: RiddleProofSemanticAssurance;
53
57
  scope: RiddleProofSemanticScope;
54
58
  claim: RiddleProofSemanticClaim;
55
59
  evidence: RiddleProofSemanticEvidenceBundle;
@@ -134,9 +138,54 @@ type RiddleProofSemanticCompositionResult = {
134
138
  ok: false;
135
139
  error: RiddleProofSemanticCompositionError;
136
140
  };
141
+ interface MatchRiddleProofSemanticCertificateInput {
142
+ certificate: unknown;
143
+ expected_certificate_id: string;
144
+ expected_scope: RiddleProofSemanticScope;
145
+ expected_claim: RiddleProofSemanticClaimExpectation;
146
+ expected_assurance: RiddleProofSemanticAssurance;
147
+ }
148
+ interface RiddleProofSemanticCertificateInvalid {
149
+ code: "invalid_certificate";
150
+ message: string;
151
+ }
152
+ interface RiddleProofSemanticCertificateIdMismatch {
153
+ code: "certificate_id_mismatch";
154
+ expected: string;
155
+ observed: string;
156
+ message: string;
157
+ }
158
+ interface RiddleProofSemanticCertificateMatchScopeMismatch {
159
+ code: "scope_mismatch";
160
+ field: RiddleProofSemanticScopeField;
161
+ expected: string;
162
+ observed: string;
163
+ message: string;
164
+ }
165
+ interface RiddleProofSemanticCertificateClaimMismatch {
166
+ code: "claim_mismatch";
167
+ expected: RiddleProofSemanticClaimRef;
168
+ observed: RiddleProofSemanticClaimRef;
169
+ message: string;
170
+ }
171
+ interface RiddleProofSemanticCertificateAssuranceMismatch {
172
+ code: "assurance_mismatch";
173
+ expected: RiddleProofSemanticAssurance;
174
+ observed: RiddleProofSemanticAssurance;
175
+ message: string;
176
+ }
177
+ type RiddleProofSemanticCertificateMatchError = RiddleProofSemanticCertificateInvalid | RiddleProofSemanticCertificateIdMismatch | RiddleProofSemanticCertificateMatchScopeMismatch | RiddleProofSemanticCertificateClaimMismatch | RiddleProofSemanticCertificateAssuranceMismatch;
178
+ type RiddleProofSemanticCertificateMatchResult = {
179
+ ok: true;
180
+ certificate: RiddleProofSemanticCertificate;
181
+ } | {
182
+ ok: false;
183
+ error: RiddleProofSemanticCertificateMatchError;
184
+ };
137
185
  declare function riddleProofSemanticScopesEqual(left: RiddleProofSemanticScope, right: RiddleProofSemanticScope): boolean;
138
186
  declare function createRiddleProofSemanticCertificate<Observation>(input: CreateRiddleProofSemanticCertificateInput<Observation>): RiddleProofSemanticCertificationResult;
139
187
  declare function parseRiddleProofSemanticCertificate(value: unknown): RiddleProofSemanticCertificate;
188
+ declare function matchRiddleProofSemanticCertificate(input: MatchRiddleProofSemanticCertificateInput): RiddleProofSemanticCertificateMatchResult;
140
189
  declare function composeRiddleProofSemanticCertificates(input: ComposeRiddleProofSemanticCertificatesInput): RiddleProofSemanticCompositionResult;
141
190
 
142
- export { type ComposeRiddleProofSemanticCertificatesInput, type CreateRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, type RiddleProofSemanticCertificate, type RiddleProofSemanticCertificationResult, type RiddleProofSemanticClaim, type RiddleProofSemanticClaimRef, type RiddleProofSemanticCompositionDerivation, type RiddleProofSemanticCompositionError, type RiddleProofSemanticCompositionResult, type RiddleProofSemanticContract, type RiddleProofSemanticContractDerivation, type RiddleProofSemanticContractError, type RiddleProofSemanticContractRef, type RiddleProofSemanticContractRejected, type RiddleProofSemanticDerivation, type RiddleProofSemanticEvidenceBundle, type RiddleProofSemanticEvidenceRef, type RiddleProofSemanticPremise, type RiddleProofSemanticPremiseCountMismatch, type RiddleProofSemanticPremiseMismatch, type RiddleProofSemanticRule, type RiddleProofSemanticRuntimeContract, type RiddleProofSemanticScope, type RiddleProofSemanticScopeField, type RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual };
191
+ export { type ComposeRiddleProofSemanticCertificatesInput, type CreateRiddleProofSemanticCertificateInput, type MatchRiddleProofSemanticCertificateInput, RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION, type RiddleProofSemanticAssurance, type RiddleProofSemanticCertificate, type RiddleProofSemanticCertificateAssuranceMismatch, type RiddleProofSemanticCertificateClaimMismatch, type RiddleProofSemanticCertificateIdMismatch, type RiddleProofSemanticCertificateInvalid, type RiddleProofSemanticCertificateMatchError, type RiddleProofSemanticCertificateMatchResult, type RiddleProofSemanticCertificateMatchScopeMismatch, type RiddleProofSemanticCertificationResult, type RiddleProofSemanticClaim, type RiddleProofSemanticClaimExpectation, type RiddleProofSemanticClaimRef, type RiddleProofSemanticCompositionDerivation, type RiddleProofSemanticCompositionError, type RiddleProofSemanticCompositionResult, type RiddleProofSemanticContract, type RiddleProofSemanticContractDerivation, type RiddleProofSemanticContractError, type RiddleProofSemanticContractRef, type RiddleProofSemanticContractRejected, type RiddleProofSemanticDerivation, type RiddleProofSemanticEvidenceBundle, type RiddleProofSemanticEvidenceRef, type RiddleProofSemanticPremise, type RiddleProofSemanticPremiseCountMismatch, type RiddleProofSemanticPremiseMismatch, type RiddleProofSemanticRule, type RiddleProofSemanticRuntimeContract, type RiddleProofSemanticScope, type RiddleProofSemanticScopeField, type RiddleProofSemanticScopeMismatch, composeRiddleProofSemanticCertificates, createRiddleProofSemanticCertificate, matchRiddleProofSemanticCertificate, parseRiddleProofSemanticCertificate, riddleProofSemanticScopesEqual };
@@ -2,14 +2,16 @@ import {
2
2
  RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION,
3
3
  composeRiddleProofSemanticCertificates,
4
4
  createRiddleProofSemanticCertificate,
5
+ matchRiddleProofSemanticCertificate,
5
6
  parseRiddleProofSemanticCertificate,
6
7
  riddleProofSemanticScopesEqual
7
- } from "./chunk-ZZ6UNKJQ.js";
8
+ } from "./chunk-DB5ZHRUP.js";
8
9
  import "./chunk-MLKGABMK.js";
9
10
  export {
10
11
  RIDDLE_PROOF_SEMANTIC_CERTIFICATE_VERSION,
11
12
  composeRiddleProofSemanticCertificates,
12
13
  createRiddleProofSemanticCertificate,
14
+ matchRiddleProofSemanticCertificate,
13
15
  parseRiddleProofSemanticCertificate,
14
16
  riddleProofSemanticScopesEqual
15
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.8.82",
3
+ "version": "0.8.83",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",