@dailephd/my-frontend-observer 0.8.1
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/CHANGELOG.md +397 -0
- package/LICENSE +21 -0
- package/README.md +255 -0
- package/dist/application/browserCaptureService.d.ts +11 -0
- package/dist/application/browserCaptureService.js +12 -0
- package/dist/application/browserCaptureService.js.map +1 -0
- package/dist/application/comparisonService.d.ts +56 -0
- package/dist/application/comparisonService.js +77 -0
- package/dist/application/comparisonService.js.map +1 -0
- package/dist/application/externalReferencePersistenceService.d.ts +75 -0
- package/dist/application/externalReferencePersistenceService.js +182 -0
- package/dist/application/externalReferencePersistenceService.js.map +1 -0
- package/dist/application/frontendContractEvaluationService.d.ts +49 -0
- package/dist/application/frontendContractEvaluationService.js +112 -0
- package/dist/application/frontendContractEvaluationService.js.map +1 -0
- package/dist/application/frontendContractPersistenceService.d.ts +56 -0
- package/dist/application/frontendContractPersistenceService.js +91 -0
- package/dist/application/frontendContractPersistenceService.js.map +1 -0
- package/dist/application/observationPersistence.d.ts +59 -0
- package/dist/application/observationPersistence.js +79 -0
- package/dist/application/observationPersistence.js.map +1 -0
- package/dist/application/projectCheckService.d.ts +3 -0
- package/dist/application/projectCheckService.js +169 -0
- package/dist/application/projectCheckService.js.map +1 -0
- package/dist/application/projectWorkflowService.d.ts +46 -0
- package/dist/application/projectWorkflowService.js +92 -0
- package/dist/application/projectWorkflowService.js.map +1 -0
- package/dist/application/referenceFidelityEvaluationService.d.ts +28 -0
- package/dist/application/referenceFidelityEvaluationService.js +45 -0
- package/dist/application/referenceFidelityEvaluationService.js.map +1 -0
- package/dist/artifacts/artifactReader.d.ts +19 -0
- package/dist/artifacts/artifactReader.js +36 -0
- package/dist/artifacts/artifactReader.js.map +1 -0
- package/dist/artifacts/artifactWriter.d.ts +25 -0
- package/dist/artifacts/artifactWriter.js +68 -0
- package/dist/artifacts/artifactWriter.js.map +1 -0
- package/dist/artifacts/comparisonArtifactReader.d.ts +18 -0
- package/dist/artifacts/comparisonArtifactReader.js +35 -0
- package/dist/artifacts/comparisonArtifactReader.js.map +1 -0
- package/dist/artifacts/comparisonArtifactWriter.d.ts +41 -0
- package/dist/artifacts/comparisonArtifactWriter.js +67 -0
- package/dist/artifacts/comparisonArtifactWriter.js.map +1 -0
- package/dist/artifacts/externalReferenceArtifactReader.d.ts +18 -0
- package/dist/artifacts/externalReferenceArtifactReader.js +35 -0
- package/dist/artifacts/externalReferenceArtifactReader.js.map +1 -0
- package/dist/artifacts/externalReferenceArtifactWriter.d.ts +44 -0
- package/dist/artifacts/externalReferenceArtifactWriter.js +77 -0
- package/dist/artifacts/externalReferenceArtifactWriter.js.map +1 -0
- package/dist/artifacts/frontendContractArtifactReader.d.ts +24 -0
- package/dist/artifacts/frontendContractArtifactReader.js +47 -0
- package/dist/artifacts/frontendContractArtifactReader.js.map +1 -0
- package/dist/artifacts/frontendContractArtifactWriter.d.ts +34 -0
- package/dist/artifacts/frontendContractArtifactWriter.js +70 -0
- package/dist/artifacts/frontendContractArtifactWriter.js.map +1 -0
- package/dist/artifacts/frontendContractEvaluationArtifactReader.d.ts +17 -0
- package/dist/artifacts/frontendContractEvaluationArtifactReader.js +34 -0
- package/dist/artifacts/frontendContractEvaluationArtifactReader.js.map +1 -0
- package/dist/artifacts/frontendContractEvaluationArtifactWriter.d.ts +32 -0
- package/dist/artifacts/frontendContractEvaluationArtifactWriter.js +58 -0
- package/dist/artifacts/frontendContractEvaluationArtifactWriter.js.map +1 -0
- package/dist/artifacts/types.d.ts +17 -0
- package/dist/artifacts/types.js +2 -0
- package/dist/artifacts/types.js.map +1 -0
- package/dist/browser/chromiumAdapter.d.ts +21 -0
- package/dist/browser/chromiumAdapter.js +204 -0
- package/dist/browser/chromiumAdapter.js.map +1 -0
- package/dist/browser/evidenceCapture.d.ts +62 -0
- package/dist/browser/evidenceCapture.js +500 -0
- package/dist/browser/evidenceCapture.js.map +1 -0
- package/dist/browser/scrollCapture.d.ts +32 -0
- package/dist/browser/scrollCapture.js +163 -0
- package/dist/browser/scrollCapture.js.map +1 -0
- package/dist/browser/types.d.ts +24 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +2411 -0
- package/dist/cli.js.map +1 -0
- package/dist/domain/boundedAgentContext.d.ts +226 -0
- package/dist/domain/boundedAgentContext.js +355 -0
- package/dist/domain/boundedAgentContext.js.map +1 -0
- package/dist/domain/boundedAgentContextCorrelation.d.ts +74 -0
- package/dist/domain/boundedAgentContextCorrelation.js +441 -0
- package/dist/domain/boundedAgentContextCorrelation.js.map +1 -0
- package/dist/domain/boundedAgentContextIdentity.d.ts +26 -0
- package/dist/domain/boundedAgentContextIdentity.js +69 -0
- package/dist/domain/boundedAgentContextIdentity.js.map +1 -0
- package/dist/domain/boundedAgentContextProjection.d.ts +71 -0
- package/dist/domain/boundedAgentContextProjection.js +477 -0
- package/dist/domain/boundedAgentContextProjection.js.map +1 -0
- package/dist/domain/comparison.d.ts +220 -0
- package/dist/domain/comparison.js +350 -0
- package/dist/domain/comparison.js.map +1 -0
- package/dist/domain/comparisonEngine.d.ts +76 -0
- package/dist/domain/comparisonEngine.js +734 -0
- package/dist/domain/comparisonEngine.js.map +1 -0
- package/dist/domain/comparisonIdentity.d.ts +13 -0
- package/dist/domain/comparisonIdentity.js +46 -0
- package/dist/domain/comparisonIdentity.js.map +1 -0
- package/dist/domain/completion.d.ts +30 -0
- package/dist/domain/completion.js +22 -0
- package/dist/domain/completion.js.map +1 -0
- package/dist/domain/diagnostics.d.ts +17 -0
- package/dist/domain/diagnostics.js +77 -0
- package/dist/domain/diagnostics.js.map +1 -0
- package/dist/domain/evidence.d.ts +29 -0
- package/dist/domain/evidence.js +59 -0
- package/dist/domain/evidence.js.map +1 -0
- package/dist/domain/explicitState.d.ts +40 -0
- package/dist/domain/explicitState.js +54 -0
- package/dist/domain/explicitState.js.map +1 -0
- package/dist/domain/externalReference.d.ts +158 -0
- package/dist/domain/externalReference.js +167 -0
- package/dist/domain/externalReference.js.map +1 -0
- package/dist/domain/externalReferenceApplicability.d.ts +43 -0
- package/dist/domain/externalReferenceApplicability.js +52 -0
- package/dist/domain/externalReferenceApplicability.js.map +1 -0
- package/dist/domain/externalReferenceCompatibility.d.ts +40 -0
- package/dist/domain/externalReferenceCompatibility.js +48 -0
- package/dist/domain/externalReferenceCompatibility.js.map +1 -0
- package/dist/domain/externalReferenceFidelity.d.ts +171 -0
- package/dist/domain/externalReferenceFidelity.js +419 -0
- package/dist/domain/externalReferenceFidelity.js.map +1 -0
- package/dist/domain/externalReferenceIdentity.d.ts +38 -0
- package/dist/domain/externalReferenceIdentity.js +70 -0
- package/dist/domain/externalReferenceIdentity.js.map +1 -0
- package/dist/domain/externalReferenceImage.d.ts +35 -0
- package/dist/domain/externalReferenceImage.js +160 -0
- package/dist/domain/externalReferenceImage.js.map +1 -0
- package/dist/domain/externalReferenceRegionRelationships.d.ts +63 -0
- package/dist/domain/externalReferenceRegionRelationships.js +98 -0
- package/dist/domain/externalReferenceRegionRelationships.js.map +1 -0
- package/dist/domain/externalReferenceRegions.d.ts +65 -0
- package/dist/domain/externalReferenceRegions.js +105 -0
- package/dist/domain/externalReferenceRegions.js.map +1 -0
- package/dist/domain/externalReferenceRequirementIdentity.d.ts +12 -0
- package/dist/domain/externalReferenceRequirementIdentity.js +35 -0
- package/dist/domain/externalReferenceRequirementIdentity.js.map +1 -0
- package/dist/domain/externalReferenceRequirements.d.ts +215 -0
- package/dist/domain/externalReferenceRequirements.js +401 -0
- package/dist/domain/externalReferenceRequirements.js.map +1 -0
- package/dist/domain/externalReferenceRuntimeBinding.d.ts +146 -0
- package/dist/domain/externalReferenceRuntimeBinding.js +183 -0
- package/dist/domain/externalReferenceRuntimeBinding.js.map +1 -0
- package/dist/domain/frontendContractEvaluation.d.ts +57 -0
- package/dist/domain/frontendContractEvaluation.js +454 -0
- package/dist/domain/frontendContractEvaluation.js.map +1 -0
- package/dist/domain/frontendContractEvaluationArtifact.d.ts +65 -0
- package/dist/domain/frontendContractEvaluationArtifact.js +108 -0
- package/dist/domain/frontendContractEvaluationArtifact.js.map +1 -0
- package/dist/domain/frontendContractIdentity.d.ts +39 -0
- package/dist/domain/frontendContractIdentity.js +70 -0
- package/dist/domain/frontendContractIdentity.js.map +1 -0
- package/dist/domain/frontendContracts.d.ts +188 -0
- package/dist/domain/frontendContracts.js +260 -0
- package/dist/domain/frontendContracts.js.map +1 -0
- package/dist/domain/identity.d.ts +21 -0
- package/dist/domain/identity.js +47 -0
- package/dist/domain/identity.js.map +1 -0
- package/dist/domain/referenceCorrectionIdentity.d.ts +40 -0
- package/dist/domain/referenceCorrectionIdentity.js +77 -0
- package/dist/domain/referenceCorrectionIdentity.js.map +1 -0
- package/dist/domain/referenceCorrectionWorkflow.d.ts +160 -0
- package/dist/domain/referenceCorrectionWorkflow.js +165 -0
- package/dist/domain/referenceCorrectionWorkflow.js.map +1 -0
- package/dist/domain/referenceFidelityProjection.d.ts +65 -0
- package/dist/domain/referenceFidelityProjection.js +135 -0
- package/dist/domain/referenceFidelityProjection.js.map +1 -0
- package/dist/domain/relationships.d.ts +210 -0
- package/dist/domain/relationships.js +352 -0
- package/dist/domain/relationships.js.map +1 -0
- package/dist/domain/schema.d.ts +269 -0
- package/dist/domain/schema.js +442 -0
- package/dist/domain/schema.js.map +1 -0
- package/dist/domain/scrollEvidence.d.ts +51 -0
- package/dist/domain/scrollEvidence.js +134 -0
- package/dist/domain/scrollEvidence.js.map +1 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/projectWorkflow/aliasCatalog.d.ts +21 -0
- package/dist/projectWorkflow/aliasCatalog.js +67 -0
- package/dist/projectWorkflow/aliasCatalog.js.map +1 -0
- package/dist/projectWorkflow/checkAcceptance.d.ts +25 -0
- package/dist/projectWorkflow/checkAcceptance.js +55 -0
- package/dist/projectWorkflow/checkAcceptance.js.map +1 -0
- package/dist/projectWorkflow/checkResult.d.ts +85 -0
- package/dist/projectWorkflow/checkResult.js +101 -0
- package/dist/projectWorkflow/checkResult.js.map +1 -0
- package/dist/projectWorkflow/projectConfig.d.ts +43 -0
- package/dist/projectWorkflow/projectConfig.js +84 -0
- package/dist/projectWorkflow/projectConfig.js.map +1 -0
- package/dist/projectWorkflow/projectDiscovery.d.ts +9 -0
- package/dist/projectWorkflow/projectDiscovery.js +20 -0
- package/dist/projectWorkflow/projectDiscovery.js.map +1 -0
- package/dist/projectWorkflow/projectPaths.d.ts +8 -0
- package/dist/projectWorkflow/projectPaths.js +23 -0
- package/dist/projectWorkflow/projectPaths.js.map +1 -0
- package/dist/request/paths.d.ts +14 -0
- package/dist/request/paths.js +33 -0
- package/dist/request/paths.js.map +1 -0
- package/dist/request/request.d.ts +111 -0
- package/dist/request/request.js +464 -0
- package/dist/request/request.js.map +1 -0
- package/dist/safety/policy.d.ts +14 -0
- package/dist/safety/policy.js +81 -0
- package/dist/safety/policy.js.map +1 -0
- package/dist/viewer/assets/index-CN_yb9Uf.css +1 -0
- package/dist/viewer/assets/index-D98S1_2d.js +9 -0
- package/dist/viewer/icons/icon-192.png +0 -0
- package/dist/viewer/icons/icon-512.png +0 -0
- package/dist/viewer/index.html +15 -0
- package/dist/viewer/manifest.webmanifest +1 -0
- package/dist/viewer/registerSW.js +1 -0
- package/dist/viewer/sw.js +1 -0
- package/dist/viewer/workbox-9c191d2f.js +1 -0
- package/dist/viewerServer/context.d.ts +48 -0
- package/dist/viewerServer/context.js +60 -0
- package/dist/viewerServer/context.js.map +1 -0
- package/dist/viewerServer/evidence/classify.d.ts +59 -0
- package/dist/viewerServer/evidence/classify.js +124 -0
- package/dist/viewerServer/evidence/classify.js.map +1 -0
- package/dist/viewerServer/evidence/comparisonView.d.ts +28 -0
- package/dist/viewerServer/evidence/comparisonView.js +43 -0
- package/dist/viewerServer/evidence/comparisonView.js.map +1 -0
- package/dist/viewerServer/evidence/contextSourceView.d.ts +25 -0
- package/dist/viewerServer/evidence/contextSourceView.js +20 -0
- package/dist/viewerServer/evidence/contextSourceView.js.map +1 -0
- package/dist/viewerServer/evidence/discovery.d.ts +31 -0
- package/dist/viewerServer/evidence/discovery.js +78 -0
- package/dist/viewerServer/evidence/discovery.js.map +1 -0
- package/dist/viewerServer/evidence/evaluationView.d.ts +32 -0
- package/dist/viewerServer/evidence/evaluationView.js +50 -0
- package/dist/viewerServer/evidence/evaluationView.js.map +1 -0
- package/dist/viewerServer/evidence/handles.d.ts +21 -0
- package/dist/viewerServer/evidence/handles.js +43 -0
- package/dist/viewerServer/evidence/handles.js.map +1 -0
- package/dist/viewerServer/evidence/index.d.ts +41 -0
- package/dist/viewerServer/evidence/index.js +82 -0
- package/dist/viewerServer/evidence/index.js.map +1 -0
- package/dist/viewerServer/evidence/limits.d.ts +27 -0
- package/dist/viewerServer/evidence/limits.js +28 -0
- package/dist/viewerServer/evidence/limits.js.map +1 -0
- package/dist/viewerServer/evidence/linkedEvidence.d.ts +43 -0
- package/dist/viewerServer/evidence/linkedEvidence.js +151 -0
- package/dist/viewerServer/evidence/linkedEvidence.js.map +1 -0
- package/dist/viewerServer/evidence/mediaResolver.d.ts +16 -0
- package/dist/viewerServer/evidence/mediaResolver.js +85 -0
- package/dist/viewerServer/evidence/mediaResolver.js.map +1 -0
- package/dist/viewerServer/evidence/observationView.d.ts +29 -0
- package/dist/viewerServer/evidence/observationView.js +46 -0
- package/dist/viewerServer/evidence/observationView.js.map +1 -0
- package/dist/viewerServer/evidence/pathSafety.d.ts +11 -0
- package/dist/viewerServer/evidence/pathSafety.js +31 -0
- package/dist/viewerServer/evidence/pathSafety.js.map +1 -0
- package/dist/viewerServer/evidence/projection.d.ts +55 -0
- package/dist/viewerServer/evidence/projection.js +152 -0
- package/dist/viewerServer/evidence/projection.js.map +1 -0
- package/dist/viewerServer/evidence/referenceView.d.ts +133 -0
- package/dist/viewerServer/evidence/referenceView.js +169 -0
- package/dist/viewerServer/evidence/referenceView.js.map +1 -0
- package/dist/viewerServer/httpServer.d.ts +27 -0
- package/dist/viewerServer/httpServer.js +381 -0
- package/dist/viewerServer/httpServer.js.map +1 -0
- package/dist/viewerServer/openBrowser.d.ts +7 -0
- package/dist/viewerServer/openBrowser.js +32 -0
- package/dist/viewerServer/openBrowser.js.map +1 -0
- package/dist/viewerServer/port.d.ts +16 -0
- package/dist/viewerServer/port.js +19 -0
- package/dist/viewerServer/port.js.map +1 -0
- package/dist/viewerServer/viewerService.d.ts +62 -0
- package/dist/viewerServer/viewerService.js +88 -0
- package/dist/viewerServer/viewerService.js.map +1 -0
- package/docs/ARCHITECTURE.md +1286 -0
- package/docs/CI_CD.md +250 -0
- package/docs/COMMANDS.md +972 -0
- package/docs/CONTRACTS.md +1856 -0
- package/docs/CURRENT_STATE.md +1049 -0
- package/docs/DEVELOPMENT.md +202 -0
- package/docs/DOCUMENTATION_PRESERVATION_POLICY.md +50 -0
- package/docs/PROJECT_DESCRIPTION.md +2221 -0
- package/docs/PROJECT_MILESTONES.md +2526 -0
- package/docs/PROJECT_OVERVIEW.md +150 -0
- package/docs/QUICKSTART.md +83 -0
- package/docs/RELEASE.md +27 -0
- package/docs/ROADMAP.md +641 -0
- package/docs/SECURITY.md +218 -0
- package/docs/WORKFLOWS.md +642 -0
- package/docs/plans/v0.8-implementation-plan.md +655 -0
- package/docs/plans/v0.8.1-cli-usability-patch-plan.md +505 -0
- package/docs/reports/v0.7-bounded-fidelity-context-prompt7.md +243 -0
- package/docs/reports/v0.7-implementation-completeness-documentation-reconciliation.md +497 -0
- package/docs/reports/v0.7-pre-release-readiness.md +337 -0
- package/docs/reports/v0.7-reference-binding-prompt5.md +223 -0
- package/docs/reports/v0.7-reference-compatibility-prompt4.md +234 -0
- package/docs/reports/v0.7-reference-correction-workflow-prompt8.md +222 -0
- package/docs/reports/v0.7-reference-fidelity-prompt6.md +216 -0
- package/docs/reports/v0.7-reference-foundation-prompt1.md +151 -0
- package/docs/reports/v0.7-reference-regions-prompt2.md +195 -0
- package/docs/reports/v0.7-reference-requirements-prompt3.md +217 -0
- package/docs/reports/v0.7-release-prep.md +423 -0
- package/docs/reports/v0.8-binding-fidelity-interaction-batch6.md +279 -0
- package/docs/reports/v0.8-bounded-context-correlation-batch7.md +233 -0
- package/docs/reports/v0.8-comparison-contract-inspection-batch4.md +279 -0
- package/docs/reports/v0.8-evidence-index-readers-batch2.md +247 -0
- package/docs/reports/v0.8-implementation-completeness-documentation-reconciliation.md +741 -0
- package/docs/reports/v0.8-integrated-viewer-acceptance-batch8.md +128 -0
- package/docs/reports/v0.8-observation-svg-inspection-batch3.md +223 -0
- package/docs/reports/v0.8-prerelease-readiness-cross-platform-security-code-rot.md +687 -0
- package/docs/reports/v0.8-reference-candidate-inspection-batch5.md +232 -0
- package/docs/reports/v0.8-viewer-runtime-pwa-batch1.md +278 -0
- package/docs/reports/v0.8.1-check-orchestration-prompt2.md +69 -0
- package/docs/reports/v0.8.1-implementation-completeness-documentation-reconciliation.md +114 -0
- package/docs/reports/v0.8.1-prerelease-readiness-cross-platform-security-code-rot.md +170 -0
- package/docs/reports/v0.8.1-project-workflow-foundation-prompt1.md +66 -0
- package/package.json +58 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { isValidExternalReferenceArtifact, isApprovedExternalReferenceArtifact } from './externalReference.js';
|
|
2
|
+
import { isValidObservationArtifact } from './schema.js';
|
|
3
|
+
import { isValidPersistentBaselineContract, isValidPerChangeContract } from './frontendContracts.js';
|
|
4
|
+
import { compareObservations } from './comparisonEngine.js';
|
|
5
|
+
import { evaluateFrontendContract } from './frontendContractEvaluation.js';
|
|
6
|
+
import { isValidReferenceRuntimeBindingDeclarations } from './externalReferenceRuntimeBinding.js';
|
|
7
|
+
import { evaluateReferenceCandidateFidelity } from './externalReferenceFidelity.js';
|
|
8
|
+
import { projectBoundedAgentContext } from './boundedAgentContextProjection.js';
|
|
9
|
+
import { buildReferenceCorrectionReviewIdentity, buildReferenceCorrectionAttemptIdentity } from './referenceCorrectionIdentity.js';
|
|
10
|
+
function isNonEmptyString(value) {
|
|
11
|
+
return typeof value === 'string' && value.length > 0;
|
|
12
|
+
}
|
|
13
|
+
function validateCommon(input) {
|
|
14
|
+
const referenceValidation = isValidExternalReferenceArtifact(input.reference);
|
|
15
|
+
if (!referenceValidation.valid)
|
|
16
|
+
return `reference is invalid: ${referenceValidation.reason}`;
|
|
17
|
+
if (!isApprovedExternalReferenceArtifact(input.reference)) {
|
|
18
|
+
return 'reference must be approved (lifecycle.state !== "approved") - an imported-but-unapproved reference is never treated as an authoritative target design by this workflow';
|
|
19
|
+
}
|
|
20
|
+
const baselineObservationValidation = isValidObservationArtifact(input.baselineObservation);
|
|
21
|
+
if (!baselineObservationValidation.valid)
|
|
22
|
+
return `baselineObservation is invalid: ${baselineObservationValidation.reason}`;
|
|
23
|
+
const baselineContractValidation = isValidPersistentBaselineContract(input.baselineContract);
|
|
24
|
+
if (!baselineContractValidation.valid)
|
|
25
|
+
return `baselineContract is invalid: ${baselineContractValidation.reason}`;
|
|
26
|
+
if (input.baselineContract.sourceObservation.observationId !== input.baselineObservation.observationId) {
|
|
27
|
+
return 'baselineContract.sourceObservation.observationId does not match the supplied baselineObservation';
|
|
28
|
+
}
|
|
29
|
+
const changeContractValidation = isValidPerChangeContract(input.changeContract);
|
|
30
|
+
if (!changeContractValidation.valid)
|
|
31
|
+
return `changeContract is invalid: ${changeContractValidation.reason}`;
|
|
32
|
+
const bindingsValidation = isValidReferenceRuntimeBindingDeclarations(input.bindingDeclarations, input.reference);
|
|
33
|
+
if (!bindingsValidation.valid)
|
|
34
|
+
return `bindingDeclarations is invalid: ${bindingsValidation.reason}`;
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
function reviewIdentityFor(input) {
|
|
38
|
+
return buildReferenceCorrectionReviewIdentity(input.reference.referenceRequestId, input.baselineObservation.observationId, input.baselineContract.baselineId, input.baselineContract.clauses, input.changeContract.contractId, input.changeContract.clauses, input.bindingDeclarations);
|
|
39
|
+
}
|
|
40
|
+
const VERIFICATION_PLAN = [
|
|
41
|
+
'A fresh candidate observation will be captured through the existing real-Chromium observation pipeline after the external edit.',
|
|
42
|
+
'The approved external reference will be re-evaluated against that fresh candidate using the same explicit runtime-target bindings (v0.7 Prompt 6 reference fidelity).',
|
|
43
|
+
'The same approved baseline observation will be compared against the fresh candidate using canonical v0.4 comparison, then evaluated against the still-active baseline and per-change contracts using canonical v0.5 contract evaluation.',
|
|
44
|
+
'Overall PASS requires both reference fidelity PASS and v0.5 contract evaluation PASS - matching the reference alone is necessary but not sufficient.',
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Pure and synchronous: no browser, no filesystem, no network, no remote AI
|
|
48
|
+
* call. Evaluates the approved reference against the supplied current
|
|
49
|
+
* (pre-change) observation via Prompt 6, then - only when that evaluation
|
|
50
|
+
* actually produced a result (`state !== 'not-evaluated'`) - projects it
|
|
51
|
+
* into a bounded coding-agent context via Prompt 7/v0.6 and returns the
|
|
52
|
+
* handoff. A `not-evaluated` fidelity (inadequate reference, or reference/
|
|
53
|
+
* candidate incompatible state) is reported honestly as `blocked-not-
|
|
54
|
+
* evaluated`, carrying the full Prompt 6 result for inspection, but never a
|
|
55
|
+
* fabricated handoff that pretends evidence is adequate.
|
|
56
|
+
*/
|
|
57
|
+
export function prepareReferenceCorrection(input) {
|
|
58
|
+
const commonError = validateCommon(input);
|
|
59
|
+
if (commonError)
|
|
60
|
+
return { ok: false, reason: commonError };
|
|
61
|
+
const currentValidation = isValidObservationArtifact(input.currentObservation);
|
|
62
|
+
if (!currentValidation.valid)
|
|
63
|
+
return { ok: false, reason: `currentObservation is invalid: ${currentValidation.reason}` };
|
|
64
|
+
if (!isNonEmptyString(input.generatedAt))
|
|
65
|
+
return { ok: false, reason: 'generatedAt must be a non-empty string' };
|
|
66
|
+
if (!isNonEmptyString(input.producerVersion))
|
|
67
|
+
return { ok: false, reason: 'producerVersion must be a non-empty string' };
|
|
68
|
+
const reviewRequestId = reviewIdentityFor(input);
|
|
69
|
+
const geometryOptions = input.fidelityGeometryTolerancePx !== undefined ? { geometryTolerancePx: input.fidelityGeometryTolerancePx } : {};
|
|
70
|
+
const fidelityResult = evaluateReferenceCandidateFidelity(input.reference, input.currentObservation, input.bindingDeclarations, geometryOptions);
|
|
71
|
+
if (!fidelityResult.ok)
|
|
72
|
+
return { ok: false, reason: `reference fidelity could not be evaluated: ${fidelityResult.reason}` };
|
|
73
|
+
const fidelity = fidelityResult.evaluation;
|
|
74
|
+
if (fidelity.state === 'not-evaluated') {
|
|
75
|
+
return { ok: true, status: 'blocked-not-evaluated', reviewRequestId, fidelity };
|
|
76
|
+
}
|
|
77
|
+
const boundedContextResult = projectBoundedAgentContext({
|
|
78
|
+
generatedAt: input.generatedAt,
|
|
79
|
+
producerVersion: input.producerVersion,
|
|
80
|
+
projectionProfile: input.projectionProfile,
|
|
81
|
+
focusTargetIds: [],
|
|
82
|
+
observation: input.currentObservation,
|
|
83
|
+
fidelity,
|
|
84
|
+
});
|
|
85
|
+
if (!boundedContextResult.ok)
|
|
86
|
+
return { ok: false, reason: `bounded context could not be constructed: ${boundedContextResult.reason}` };
|
|
87
|
+
const handoff = {
|
|
88
|
+
reviewRequestId,
|
|
89
|
+
referenceId: input.reference.referenceId,
|
|
90
|
+
referenceRequestId: input.reference.referenceRequestId,
|
|
91
|
+
baselineObservationId: input.baselineObservation.observationId,
|
|
92
|
+
currentObservationId: input.currentObservation.observationId,
|
|
93
|
+
boundedContext: boundedContextResult.artifact,
|
|
94
|
+
verificationPlan: VERIFICATION_PLAN,
|
|
95
|
+
};
|
|
96
|
+
return { ok: true, status: 'handoff-ready', reviewRequestId, fidelity, handoff };
|
|
97
|
+
}
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// C/D. REVIEW: fresh post-edit candidate -> one overall attempt result
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
export const REFERENCE_CORRECTION_OVERALL_STATES = ['not-evaluated', 'pass', 'fail'];
|
|
102
|
+
/**
|
|
103
|
+
* Pure and synchronous: no browser, no filesystem, no network, no remote AI
|
|
104
|
+
* call, no source access. Consumes exactly one already-captured candidate
|
|
105
|
+
* `ObservationArtifact` (the caller is responsible for capturing it through
|
|
106
|
+
* the existing real-Chromium observation pipeline after the external actor
|
|
107
|
+
* has edited target source) and composes the canonical v0.4 comparison,
|
|
108
|
+
* v0.7 Prompt 6 fidelity, and v0.5 contract evaluation into one overall
|
|
109
|
+
* result - reimplementing none of them. Every attempt evaluates the
|
|
110
|
+
* candidate against the *same* supplied `baselineObservation`/
|
|
111
|
+
* `baselineContract`/`changeContract` - this function has no mechanism to
|
|
112
|
+
* compare against a prior attempt's candidate instead, so accumulated
|
|
113
|
+
* drift from the approved baseline can never be hidden.
|
|
114
|
+
*/
|
|
115
|
+
export function reviewReferenceCorrectionAttempt(input) {
|
|
116
|
+
const commonError = validateCommon(input);
|
|
117
|
+
if (commonError)
|
|
118
|
+
return { ok: false, reason: commonError };
|
|
119
|
+
const candidateValidation = isValidObservationArtifact(input.candidateObservation);
|
|
120
|
+
if (!candidateValidation.valid)
|
|
121
|
+
return { ok: false, reason: `candidateObservation is invalid: ${candidateValidation.reason}` };
|
|
122
|
+
if (!isNonEmptyString(input.reviewRequestId))
|
|
123
|
+
return { ok: false, reason: 'reviewRequestId must be a non-empty string' };
|
|
124
|
+
const expectedReviewRequestId = reviewIdentityFor(input);
|
|
125
|
+
if (input.reviewRequestId !== expectedReviewRequestId) {
|
|
126
|
+
return { ok: false, reason: 'reviewRequestId does not match the supplied reference/baseline/contracts/bindings (it must be the exact id prepareReferenceCorrection returned for this same semantic review)' };
|
|
127
|
+
}
|
|
128
|
+
const comparisonResult = compareObservations(input.baselineObservation, input.candidateObservation, input.comparisonConfig ?? {});
|
|
129
|
+
if (!comparisonResult.ok)
|
|
130
|
+
return { ok: false, reason: `baseline/candidate comparison could not be computed: ${comparisonResult.reason}` };
|
|
131
|
+
const comparison = comparisonResult.artifact;
|
|
132
|
+
const geometryOptions = input.fidelityGeometryTolerancePx !== undefined ? { geometryTolerancePx: input.fidelityGeometryTolerancePx } : {};
|
|
133
|
+
const fidelityResult = evaluateReferenceCandidateFidelity(input.reference, input.candidateObservation, input.bindingDeclarations, geometryOptions);
|
|
134
|
+
if (!fidelityResult.ok)
|
|
135
|
+
return { ok: false, reason: `reference fidelity could not be evaluated: ${fidelityResult.reason}` };
|
|
136
|
+
const fidelity = fidelityResult.evaluation;
|
|
137
|
+
const contractEvaluationResult = evaluateFrontendContract({
|
|
138
|
+
before: input.baselineObservation,
|
|
139
|
+
after: input.candidateObservation,
|
|
140
|
+
comparison,
|
|
141
|
+
baseline: input.baselineContract,
|
|
142
|
+
change: input.changeContract,
|
|
143
|
+
});
|
|
144
|
+
if (!contractEvaluationResult.ok)
|
|
145
|
+
return { ok: false, reason: `contract evaluation could not be computed: ${contractEvaluationResult.reason}` };
|
|
146
|
+
const contractEvaluation = contractEvaluationResult.evaluation;
|
|
147
|
+
const overallState = fidelity.state === 'not-evaluated' ? 'not-evaluated' : fidelity.state === 'pass' && contractEvaluation.overallVerdict === 'PASS' ? 'pass' : 'fail';
|
|
148
|
+
const attemptId = buildReferenceCorrectionAttemptIdentity(input.reviewRequestId, input.candidateObservation.observationId);
|
|
149
|
+
const attempt = {
|
|
150
|
+
reviewRequestId: input.reviewRequestId,
|
|
151
|
+
attemptId,
|
|
152
|
+
...(input.priorAttemptId !== undefined ? { priorAttemptId: input.priorAttemptId } : {}),
|
|
153
|
+
referenceId: input.reference.referenceId,
|
|
154
|
+
referenceRequestId: input.reference.referenceRequestId,
|
|
155
|
+
baselineObservationId: input.baselineObservation.observationId,
|
|
156
|
+
candidateObservationId: input.candidateObservation.observationId,
|
|
157
|
+
comparison,
|
|
158
|
+
fidelity,
|
|
159
|
+
contractEvaluation,
|
|
160
|
+
overallState,
|
|
161
|
+
approvalEligible: overallState === 'pass',
|
|
162
|
+
};
|
|
163
|
+
return { ok: true, attempt };
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=referenceCorrectionWorkflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceCorrectionWorkflow.js","sourceRoot":"","sources":["../../src/domain/referenceCorrectionWorkflow.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,gCAAgC,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAE/G,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAErG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,0CAA0C,EAAE,MAAM,sCAAsC,CAAC;AAElG,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,sCAAsC,EAAE,uCAAuC,EAAE,MAAM,kCAAkC,CAAC;AAEnI,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAcD,SAAS,cAAc,CAAC,KAAkB;IACxC,MAAM,mBAAmB,GAAG,gCAAgC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9E,IAAI,CAAC,mBAAmB,CAAC,KAAK;QAAE,OAAO,yBAAyB,mBAAmB,CAAC,MAAM,EAAE,CAAC;IAC7F,IAAI,CAAC,mCAAmC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1D,OAAO,wKAAwK,CAAC;IAClL,CAAC;IAED,MAAM,6BAA6B,GAAG,0BAA0B,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC5F,IAAI,CA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B,EAAE,KAAK,CAAC,SAAS,CAAC,kBAAkB;QACtD,qBAAqB,EAAE,KAAK,CAAC,mBAAmB,CAAC,aAAa;QAC9D,sBAAsB,EAAE,KAAK,CAAC,oBAAoB,CAAC,aAAa;QAChE,UAAU;QACV,QAAQ;QACR,kBAAkB;QAClB,YAAY;QACZ,gBAAgB,EAAE,YAAY,KAAK,MAAM;KAC1C,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v0.7 Prompt 7 bounded reference-fidelity projection. Consumes an
|
|
3
|
+
* already-computed `ReferenceCandidateFidelityEvaluation` (v0.7 Prompt 6)
|
|
4
|
+
* and selects a small, bounded, deterministically-prioritized subset of it
|
|
5
|
+
* suitable for a coding agent's bounded context - never a second fidelity-
|
|
6
|
+
* evaluation engine, never a recomputation of adequacy/compatibility/
|
|
7
|
+
* binding/tolerance/relationship logic (all reused verbatim from their
|
|
8
|
+
* existing Prompt 3/4/5/6 owners).
|
|
9
|
+
*
|
|
10
|
+
* This module is pure and synchronous: no browser, no filesystem, no
|
|
11
|
+
* network, no my-dev-kit invocation. It mutates none of its inputs.
|
|
12
|
+
*
|
|
13
|
+
* Output shape (`BoundedReferenceFidelityProjection`) is frozen by
|
|
14
|
+
* `domain/boundedAgentContext.ts`; this module only derives one, plus the
|
|
15
|
+
* runtime-target-id/omission/truncation side effects
|
|
16
|
+
* `boundedAgentContextProjection.ts` needs to fold into its own existing
|
|
17
|
+
* required/permitted-target allocation and adequacy computation - it never
|
|
18
|
+
* builds a second, parallel bounded-context artifact.
|
|
19
|
+
*/
|
|
20
|
+
import type { BoundedReferenceFidelityProjection, OmissionRecord, TruncationRecord } from './boundedAgentContext.js';
|
|
21
|
+
import type { ReferenceCandidateFidelityEvaluation } from './externalReferenceFidelity.js';
|
|
22
|
+
export interface ProjectReferenceFidelityOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Whether this bounded-context request's coding-agent task depends on
|
|
25
|
+
* reference-fidelity evidence. Defaults to `true`: supplying a fidelity
|
|
26
|
+
* evaluation to be projected at all is itself the signal that the task
|
|
27
|
+
* cares about it, mirroring `CorrelationTargetInput.required`'s existing
|
|
28
|
+
* v0.6 convention. Set `false` only when fidelity is included purely as
|
|
29
|
+
* incidental context whose unavailability must never affect adequacy.
|
|
30
|
+
*/
|
|
31
|
+
required?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ProjectReferenceFidelityOutput {
|
|
34
|
+
projection: BoundedReferenceFidelityProjection;
|
|
35
|
+
/** Runtime target ids the caller should fold into its own required-tier target set (contributed by required-tier mismatches only). */
|
|
36
|
+
requiredTargetIds: string[];
|
|
37
|
+
/** Runtime target ids the caller should fold into its own permitted-tier target set (contributed by optional-tier mismatches and by protected/preserved context). */
|
|
38
|
+
permittedTargetIds: string[];
|
|
39
|
+
omissions: OmissionRecord[];
|
|
40
|
+
truncations: TruncationRecord[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Selects, prioritizes, and bounds one fidelity evaluation's non-passing
|
|
44
|
+
* requirement results plus its passing protected/preserved context, per the
|
|
45
|
+
* documented selection policy (see docs/CONTRACTS.md "v0.7 Prompt 7"):
|
|
46
|
+
*
|
|
47
|
+
* 1. failed required-tier requirements
|
|
48
|
+
* 2. unavailable required-tier requirements
|
|
49
|
+
* 3. any other non-pass (optional-tier) requirement
|
|
50
|
+
*
|
|
51
|
+
* Within a priority class, authored/Prompt-6 order is preserved (a stable
|
|
52
|
+
* sort by priority rank only, never a secondary re-sort). Passing
|
|
53
|
+
* requirements are never dumped by default - only passing `protected`/
|
|
54
|
+
* `preserved` results are surfaced, as bounded "do not break this" context,
|
|
55
|
+
* disjoint from `mismatches` (a *failing* protected/preserved requirement
|
|
56
|
+
* already appears there, at the highest priority, so it is never
|
|
57
|
+
* duplicated into `protectedContext` too).
|
|
58
|
+
*
|
|
59
|
+
* A `not-evaluated` fidelity state never produces `mismatches`/
|
|
60
|
+
* `protectedContext` content - the blocker is preserved via `blockedBy`,
|
|
61
|
+
* and (when `options.required` is true, the default) an explicit
|
|
62
|
+
* `required: true` omission is recorded so a caller folding this into its
|
|
63
|
+
* own adequacy computation can never end up falsely `adequate`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function projectReferenceFidelity(fidelity: ReferenceCandidateFidelityEvaluation, options?: ProjectReferenceFidelityOptions): ProjectReferenceFidelityOutput;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { MAX_FIDELITY_MISMATCHES, MAX_FIDELITY_PROTECTED_CONTEXT } from './boundedAgentContext.js';
|
|
2
|
+
/**
|
|
3
|
+
* Mirrors `boundedAgentContextProjection.ts#clauseTier`'s exact rule
|
|
4
|
+
* (duplicated, not imported, per this repository's established per-module
|
|
5
|
+
* small-helper-ownership convention): `protected`/`preserved` are always
|
|
6
|
+
* required; `expected-dependent` is required only in `'required'` mode
|
|
7
|
+
* (`'permitted'` mode is optional); `requested` is always optional. Reused
|
|
8
|
+
* verbatim rather than reinvented, per this prompt's explicit instruction
|
|
9
|
+
* not to create reference-specific protected/preserved semantics.
|
|
10
|
+
*/
|
|
11
|
+
function fidelityRequirementTier(category, mode) {
|
|
12
|
+
if (category === 'protected' || category === 'preserved')
|
|
13
|
+
return 'required';
|
|
14
|
+
if (category === 'expected-dependent')
|
|
15
|
+
return mode === 'required' ? 'required' : 'optional';
|
|
16
|
+
return 'optional'; // 'requested'
|
|
17
|
+
}
|
|
18
|
+
function dedupePreservingOrder(ids) {
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const result = [];
|
|
21
|
+
for (const id of ids) {
|
|
22
|
+
if (seen.has(id))
|
|
23
|
+
continue;
|
|
24
|
+
seen.add(id);
|
|
25
|
+
result.push(id);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
function baseProjectionFields(fidelity) {
|
|
30
|
+
return {
|
|
31
|
+
referenceId: fidelity.referenceId,
|
|
32
|
+
referenceRequestId: fidelity.referenceRequestId,
|
|
33
|
+
candidateObservationId: fidelity.candidateObservationId,
|
|
34
|
+
candidateRequestId: fidelity.candidateRequestId,
|
|
35
|
+
adequacy: fidelity.adequacy,
|
|
36
|
+
...(fidelity.compatibility !== undefined ? { compatibility: fidelity.compatibility } : {}),
|
|
37
|
+
state: fidelity.state,
|
|
38
|
+
...(fidelity.blockedBy !== undefined ? { blockedBy: fidelity.blockedBy } : {}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Selects, prioritizes, and bounds one fidelity evaluation's non-passing
|
|
43
|
+
* requirement results plus its passing protected/preserved context, per the
|
|
44
|
+
* documented selection policy (see docs/CONTRACTS.md "v0.7 Prompt 7"):
|
|
45
|
+
*
|
|
46
|
+
* 1. failed required-tier requirements
|
|
47
|
+
* 2. unavailable required-tier requirements
|
|
48
|
+
* 3. any other non-pass (optional-tier) requirement
|
|
49
|
+
*
|
|
50
|
+
* Within a priority class, authored/Prompt-6 order is preserved (a stable
|
|
51
|
+
* sort by priority rank only, never a secondary re-sort). Passing
|
|
52
|
+
* requirements are never dumped by default - only passing `protected`/
|
|
53
|
+
* `preserved` results are surfaced, as bounded "do not break this" context,
|
|
54
|
+
* disjoint from `mismatches` (a *failing* protected/preserved requirement
|
|
55
|
+
* already appears there, at the highest priority, so it is never
|
|
56
|
+
* duplicated into `protectedContext` too).
|
|
57
|
+
*
|
|
58
|
+
* A `not-evaluated` fidelity state never produces `mismatches`/
|
|
59
|
+
* `protectedContext` content - the blocker is preserved via `blockedBy`,
|
|
60
|
+
* and (when `options.required` is true, the default) an explicit
|
|
61
|
+
* `required: true` omission is recorded so a caller folding this into its
|
|
62
|
+
* own adequacy computation can never end up falsely `adequate`.
|
|
63
|
+
*/
|
|
64
|
+
export function projectReferenceFidelity(fidelity, options = {}) {
|
|
65
|
+
const required = options.required ?? true;
|
|
66
|
+
const base = baseProjectionFields(fidelity);
|
|
67
|
+
if (fidelity.state === 'not-evaluated') {
|
|
68
|
+
const omissions = [
|
|
69
|
+
{
|
|
70
|
+
subject: 'fidelity',
|
|
71
|
+
reason: 'unsupported-or-unavailable',
|
|
72
|
+
required,
|
|
73
|
+
detail: `reference fidelity could not be evaluated (blockedBy: ${fidelity.blockedBy ?? 'unknown'})`,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
return {
|
|
77
|
+
projection: { ...base, mismatches: [], protectedContext: [] },
|
|
78
|
+
requiredTargetIds: [],
|
|
79
|
+
permittedTargetIds: [],
|
|
80
|
+
omissions,
|
|
81
|
+
truncations: [],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const omissions = [];
|
|
85
|
+
const truncations = [];
|
|
86
|
+
const nonPass = fidelity.requirementResults.filter((r) => r.status !== 'pass');
|
|
87
|
+
const ranked = nonPass.map((result, index) => {
|
|
88
|
+
const tier = fidelityRequirementTier(result.category, result.expectedDependentMode);
|
|
89
|
+
const rank = result.status === 'fail' && tier === 'required' ? 0 : result.status === 'unavailable' && tier === 'required' ? 1 : 2;
|
|
90
|
+
return { result, tier, rank, index };
|
|
91
|
+
});
|
|
92
|
+
const orderedRanked = [...ranked].sort((a, b) => (a.rank !== b.rank ? a.rank - b.rank : a.index - b.index));
|
|
93
|
+
const includedRanked = orderedRanked.slice(0, MAX_FIDELITY_MISMATCHES);
|
|
94
|
+
const droppedRanked = orderedRanked.slice(MAX_FIDELITY_MISMATCHES);
|
|
95
|
+
for (const dropped of droppedRanked) {
|
|
96
|
+
if (dropped.tier === 'required') {
|
|
97
|
+
omissions.push({ subject: `fidelity-mismatch:${dropped.result.requirementId}`, reason: 'required-evidence-lost-by-bound', required: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (droppedRanked.length > 0) {
|
|
101
|
+
truncations.push({
|
|
102
|
+
subject: 'fidelity-mismatches',
|
|
103
|
+
limit: MAX_FIDELITY_MISMATCHES,
|
|
104
|
+
actualCount: nonPass.length,
|
|
105
|
+
required: droppedRanked.some((d) => d.tier === 'required'),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Reported order is priority-first (failed-required, then unavailable-required, then other
|
|
109
|
+
// non-pass), with Prompt-6 authored order preserved only as the tie-breaker within one priority
|
|
110
|
+
// class - `includedRanked` is already exactly this order (see the sort above).
|
|
111
|
+
const mismatches = includedRanked.map((r) => r.result);
|
|
112
|
+
const protectedCandidates = fidelity.requirementResults.filter((r) => r.status === 'pass' && (r.category === 'protected' || r.category === 'preserved'));
|
|
113
|
+
const protectedContext = protectedCandidates.slice(0, MAX_FIDELITY_PROTECTED_CONTEXT);
|
|
114
|
+
if (protectedCandidates.length > MAX_FIDELITY_PROTECTED_CONTEXT) {
|
|
115
|
+
truncations.push({
|
|
116
|
+
subject: 'fidelity-protected-context',
|
|
117
|
+
limit: MAX_FIDELITY_PROTECTED_CONTEXT,
|
|
118
|
+
actualCount: protectedCandidates.length,
|
|
119
|
+
required: false,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const requiredTargetIds = dedupePreservingOrder(mismatches.filter((m) => fidelityRequirementTier(m.category, m.expectedDependentMode) === 'required').flatMap((m) => m.boundRuntimeTargets));
|
|
123
|
+
const requiredSet = new Set(requiredTargetIds);
|
|
124
|
+
const permittedTargetIds = dedupePreservingOrder([...mismatches.filter((m) => fidelityRequirementTier(m.category, m.expectedDependentMode) === 'optional'), ...protectedContext]
|
|
125
|
+
.flatMap((m) => m.boundRuntimeTargets)
|
|
126
|
+
.filter((id) => !requiredSet.has(id)));
|
|
127
|
+
return {
|
|
128
|
+
projection: { ...base, mismatches, protectedContext },
|
|
129
|
+
requiredTargetIds,
|
|
130
|
+
permittedTargetIds,
|
|
131
|
+
omissions,
|
|
132
|
+
truncations,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=referenceFidelityProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AAqB,CAC9C,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC,KAAK,UAAU,CAAC,EAAE,GAAG,gBAAgB,CAAC;SAC5H,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACrC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CACxC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE;QACrD,iBAAiB;QACjB,kBAAkB;QAClB,SAAS;QACT,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v0.4 Batch 1 layout-relationship contract, plus the Batch 2 pure
|
|
3
|
+
* derivation engine (`deriveLayoutRelationships`) that consumes it. This
|
|
4
|
+
* module owns geometry tolerance (needed directly by the engine below, so it
|
|
5
|
+
* cannot be imported from domain/comparison.ts without a cycle - see the
|
|
6
|
+
* re-export there) and never imports domain/comparison.ts.
|
|
7
|
+
*/
|
|
8
|
+
import type { ObservationArtifact, TargetEvidenceRecord, TargetGeometry } from './schema.js';
|
|
9
|
+
/** Suppresses insignificant geometry noise only - never a design contract, never permission for changes. */
|
|
10
|
+
export declare const GEOMETRY_TOLERANCE_DEFAULT_PX = 0.5;
|
|
11
|
+
export declare const GEOMETRY_TOLERANCE_MIN_PX = 0;
|
|
12
|
+
export declare const GEOMETRY_TOLERANCE_MAX_PX = 10;
|
|
13
|
+
export declare function isValidGeometryTolerancePx(value: unknown): value is number;
|
|
14
|
+
export declare const HORIZONTAL_ORDER_RELATIONSHIPS: readonly ["left-of", "right-of", "horizontally-overlapping"];
|
|
15
|
+
export type HorizontalOrderRelationship = (typeof HORIZONTAL_ORDER_RELATIONSHIPS)[number];
|
|
16
|
+
export declare const VERTICAL_ORDER_RELATIONSHIPS: readonly ["above", "below", "vertically-overlapping"];
|
|
17
|
+
export type VerticalOrderRelationship = (typeof VERTICAL_ORDER_RELATIONSHIPS)[number];
|
|
18
|
+
export declare const AREA_OVERLAP_RELATIONSHIPS: readonly ["overlaps", "does-not-overlap"];
|
|
19
|
+
export type AreaOverlapRelationship = (typeof AREA_OVERLAP_RELATIONSHIPS)[number];
|
|
20
|
+
export declare const RELATIVE_WIDTH_RELATIONSHIPS: readonly ["wider-than", "narrower-than", "equal-width-within-tolerance"];
|
|
21
|
+
export type RelativeWidthRelationship = (typeof RELATIVE_WIDTH_RELATIONSHIPS)[number];
|
|
22
|
+
export declare const GEOMETRIC_FIT_RELATIONSHIPS: readonly ["fits-inside", "does-not-fit-inside"];
|
|
23
|
+
export type GeometricFitRelationship = (typeof GEOMETRIC_FIT_RELATIONSHIPS)[number];
|
|
24
|
+
/** Rendered-geometry sequencing only - never source DOM order (see docs/CONTRACTS.md target containment discussion). */
|
|
25
|
+
export declare const VERTICAL_SEQUENCE_RELATIONSHIPS: readonly ["follows-vertically"];
|
|
26
|
+
export type VerticalSequenceRelationship = (typeof VERTICAL_SEQUENCE_RELATIONSHIPS)[number];
|
|
27
|
+
export declare const PAGE_WIDTH_RELATIONSHIPS: readonly ["document-width-fits-viewport", "document-width-exceeds-viewport"];
|
|
28
|
+
export type PageWidthRelationship = (typeof PAGE_WIDTH_RELATIONSHIPS)[number];
|
|
29
|
+
/** Every pairwise (two-target) relationship kind this batch freezes. Deliberately bounded - not a general-purpose spatial language. */
|
|
30
|
+
export declare const PAIRWISE_RELATIONSHIP_KINDS: readonly ["left-of", "right-of", "horizontally-overlapping", "above", "below", "vertically-overlapping", "overlaps", "does-not-overlap", "wider-than", "narrower-than", "equal-width-within-tolerance", "fits-inside", "does-not-fit-inside", "follows-vertically"];
|
|
31
|
+
export type PairwiseRelationshipKind = (typeof PAIRWISE_RELATIONSHIP_KINDS)[number];
|
|
32
|
+
/** Every page-level (no target pair) relationship kind this batch freezes. */
|
|
33
|
+
export declare const PAGE_LEVEL_RELATIONSHIP_KINDS: readonly ["document-width-fits-viewport", "document-width-exceeds-viewport"];
|
|
34
|
+
export type PageLevelRelationshipKind = (typeof PAGE_LEVEL_RELATIONSHIP_KINDS)[number];
|
|
35
|
+
/** Points at the supporting observation evidence a derived relationship/difference was computed from (e.g. `targetEvidence.workspace.geometry`, `pageEvidence.documentSize`) - never a duplicated copy of the measurement itself. */
|
|
36
|
+
export interface EvidenceReference {
|
|
37
|
+
path: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function isValidEvidenceReference(value: unknown): value is EvidenceReference;
|
|
40
|
+
/** One derived spatial relationship between two configured targets, with explicit supporting evidence provenance. */
|
|
41
|
+
export interface PairwiseLayoutRelationship {
|
|
42
|
+
kind: PairwiseRelationshipKind;
|
|
43
|
+
subjectTarget: string;
|
|
44
|
+
relatedTarget: string;
|
|
45
|
+
evidence: EvidenceReference[];
|
|
46
|
+
}
|
|
47
|
+
export declare function isValidPairwiseLayoutRelationship(value: unknown): value is PairwiseLayoutRelationship;
|
|
48
|
+
/** One derived page-level (no target pair) relationship. */
|
|
49
|
+
export interface PageLevelLayoutRelationship {
|
|
50
|
+
kind: PageLevelRelationshipKind;
|
|
51
|
+
evidence: EvidenceReference[];
|
|
52
|
+
}
|
|
53
|
+
export declare function isValidPageLevelLayoutRelationship(value: unknown): value is PageLevelLayoutRelationship;
|
|
54
|
+
/** A configured target excluded from relationship derivation because it lacks usable geometry - never a fabricated zero-sized rectangle. */
|
|
55
|
+
export declare const UNRESOLVED_TARGET_REASONS: readonly ["not-found", "ambiguous", "unavailable", "hidden"];
|
|
56
|
+
export type UnresolvedTargetReason = (typeof UNRESOLVED_TARGET_REASONS)[number];
|
|
57
|
+
export interface UnresolvedRelationshipTarget {
|
|
58
|
+
target: string;
|
|
59
|
+
reason: UnresolvedTargetReason;
|
|
60
|
+
}
|
|
61
|
+
export declare function isValidUnresolvedRelationshipTarget(value: unknown): value is UnresolvedRelationshipTarget;
|
|
62
|
+
/**
|
|
63
|
+
* Bounded structured relationship graph for one observation. Existing
|
|
64
|
+
* requests allow at most 20 configured targets, so the pairwise layer is
|
|
65
|
+
* bounded at 20*19/2 = 190 unordered pairs; this contract never traverses
|
|
66
|
+
* arbitrary DOM nodes or derives relationships for unconfigured elements.
|
|
67
|
+
*/
|
|
68
|
+
export interface LayoutRelationshipGraph {
|
|
69
|
+
observationId: string;
|
|
70
|
+
requestId: string;
|
|
71
|
+
geometryTolerancePx: number;
|
|
72
|
+
targets: string[];
|
|
73
|
+
unresolvedTargets: UnresolvedRelationshipTarget[];
|
|
74
|
+
pairwiseRelationships: PairwiseLayoutRelationship[];
|
|
75
|
+
pageRelationships: PageLevelLayoutRelationship[];
|
|
76
|
+
}
|
|
77
|
+
export declare const MAX_CONFIGURED_TARGETS_FOR_RELATIONSHIPS = 20;
|
|
78
|
+
export declare const MAX_PAIRWISE_RELATIONSHIP_PAIRS: number;
|
|
79
|
+
/**
|
|
80
|
+
* A single unordered pair can carry up to one record per independent
|
|
81
|
+
* pairwise relationship family (horizontal-order, vertical-order,
|
|
82
|
+
* area-overlap, relative-width, geometric-fit, vertical-sequence - see
|
|
83
|
+
* `deriveLayoutRelationships` below), never more than one per family per
|
|
84
|
+
* pair. This is the resulting bound on `pairwiseRelationships.length`, not a
|
|
85
|
+
* second target-count configuration.
|
|
86
|
+
*/
|
|
87
|
+
export declare const PAIRWISE_RELATIONSHIP_FAMILY_COUNT = 6;
|
|
88
|
+
export declare const MAX_PAIRWISE_RELATIONSHIP_RECORDS: number;
|
|
89
|
+
export declare function isValidLayoutRelationshipGraph(value: unknown): value is LayoutRelationshipGraph;
|
|
90
|
+
/**
|
|
91
|
+
* Bounded derived clipping concept (docs/PROJECT_MILESTONES.md Milestone 4).
|
|
92
|
+
* `clipped` requires both actual dimensional overflow on that axis AND a
|
|
93
|
+
* computed `overflow` value of `hidden`/`clip` on that axis - `auto`,
|
|
94
|
+
* `scroll`, and `visible` never classify as clipped solely from dimensional
|
|
95
|
+
* overflow. `unavailable` when the underlying overflow/geometry evidence
|
|
96
|
+
* cannot support a conclusion - never guessed.
|
|
97
|
+
*/
|
|
98
|
+
export declare const CLIPPING_STATES: readonly ["clipped", "not-clipped", "unavailable"];
|
|
99
|
+
export type ClippingState = (typeof CLIPPING_STATES)[number];
|
|
100
|
+
export declare const CLIPPING_OVERFLOW_STYLES: readonly ["hidden", "clip"];
|
|
101
|
+
export type ClippingOverflowStyle = (typeof CLIPPING_OVERFLOW_STYLES)[number];
|
|
102
|
+
export interface TargetClippingEvidence {
|
|
103
|
+
horizontal: ClippingState;
|
|
104
|
+
vertical: ClippingState;
|
|
105
|
+
}
|
|
106
|
+
export declare function isValidTargetClippingEvidence(value: unknown): value is TargetClippingEvidence;
|
|
107
|
+
/**
|
|
108
|
+
* Pure per-target clipping derivation from one target's own existing
|
|
109
|
+
* `layout`/`style` evidence (never a scroll scenario - normal target
|
|
110
|
+
* evidence already carries `scrollWidth`/`scrollHeight`/`clientWidth`/
|
|
111
|
+
* `clientHeight`/`overflowX`/`overflowY`). `TargetClippingEvidence` has no
|
|
112
|
+
* slot in `LayoutRelationshipGraph` (that graph is spatial/page-level only,
|
|
113
|
+
* per the frozen Batch 1 vocabulary) - this is a standalone per-target
|
|
114
|
+
* derivation for callers (e.g. a later comparison engine) that need it
|
|
115
|
+
* directly from an `ObservationArtifact`'s `targetEvidence`, one target at a
|
|
116
|
+
* time. `unavailable` (never guessed) when the underlying layout/style
|
|
117
|
+
* evidence is not itself available - this naturally covers an unresolved
|
|
118
|
+
* target without any special-casing. A resolved-but-`display:none` target
|
|
119
|
+
* naturally computes `not-clipped` too: its `scrollWidth`/`clientWidth` are
|
|
120
|
+
* both `0`, so `scrollWidth > clientWidth` is false - clipping is never
|
|
121
|
+
* inferred from hidden-ness itself.
|
|
122
|
+
*/
|
|
123
|
+
export declare function deriveTargetClipping(record: TargetEvidenceRecord): TargetClippingEvidence;
|
|
124
|
+
/**
|
|
125
|
+
* Pure tolerance-aware geometry predicates (Batch 1's frozen rules,
|
|
126
|
+
* verbatim). Every predicate is a total function over exactly one relation
|
|
127
|
+
* family, so it can never itself produce a contradictory pair of values
|
|
128
|
+
* (e.g. `left-of` and `right-of` for the same call) - the caller decides
|
|
129
|
+
* `subject`/`related` once per pair and each family is evaluated exactly
|
|
130
|
+
* once for that fixed direction.
|
|
131
|
+
*/
|
|
132
|
+
/**
|
|
133
|
+
* Exported (v0.7 Prompt 2 addition, additive-only - no formula changed) so
|
|
134
|
+
* that domain/externalReferenceRegionRelationships.ts can derive the same
|
|
135
|
+
* geometry-only relationship families for reference-image regions without
|
|
136
|
+
* duplicating these formulas. Every parameter is structurally just
|
|
137
|
+
* `{x,y,width,height,right,bottom}` - these predicates have never depended on
|
|
138
|
+
* anything runtime/browser-specific, so reusing them for a reference
|
|
139
|
+
* region's derived rectangle is exact reuse, not a reinterpretation.
|
|
140
|
+
*/
|
|
141
|
+
export declare function horizontalOrderOf(a: TargetGeometry, b: TargetGeometry, tolerance: number): HorizontalOrderRelationship;
|
|
142
|
+
export declare function verticalOrderOf(a: TargetGeometry, b: TargetGeometry, tolerance: number): VerticalOrderRelationship;
|
|
143
|
+
export declare function areaOverlapOf(a: TargetGeometry, b: TargetGeometry, tolerance: number): AreaOverlapRelationship;
|
|
144
|
+
export declare function relativeWidthOf(a: TargetGeometry, b: TargetGeometry, tolerance: number): RelativeWidthRelationship;
|
|
145
|
+
export declare function geometricFitOf(a: TargetGeometry, b: TargetGeometry, tolerance: number): GeometricFitRelationship;
|
|
146
|
+
/**
|
|
147
|
+
* `follows-vertically` is the one family whose vocabulary has a single
|
|
148
|
+
* value (not a total 3-way partition like the others), so it is emitted
|
|
149
|
+
* only when one target's geometry actually precedes the other's - never for
|
|
150
|
+
* both directions, never when they vertically overlap. The direction is
|
|
151
|
+
* decided by actual rendered geometry, not configured target order:
|
|
152
|
+
* `above(x, y)` and "y follows x" share the same tolerance-relative
|
|
153
|
+
* condition, so whichever of the pair is algebraically "above" the other
|
|
154
|
+
* becomes `relatedTarget` and the one that follows becomes `subjectTarget`.
|
|
155
|
+
*/
|
|
156
|
+
export declare function verticalSequenceOf(x: {
|
|
157
|
+
name: string;
|
|
158
|
+
geometry: TargetGeometry;
|
|
159
|
+
}, y: {
|
|
160
|
+
name: string;
|
|
161
|
+
geometry: TargetGeometry;
|
|
162
|
+
}, tolerance: number): {
|
|
163
|
+
subjectTarget: string;
|
|
164
|
+
relatedTarget: string;
|
|
165
|
+
} | undefined;
|
|
166
|
+
export type DeriveLayoutRelationshipsOptions = {
|
|
167
|
+
geometryTolerancePx?: number;
|
|
168
|
+
};
|
|
169
|
+
export type DeriveLayoutRelationshipsResult = {
|
|
170
|
+
ok: true;
|
|
171
|
+
graph: LayoutRelationshipGraph;
|
|
172
|
+
} | {
|
|
173
|
+
ok: false;
|
|
174
|
+
reason: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The one canonical pure derivation from an already-captured
|
|
178
|
+
* `ObservationArtifact` to a `LayoutRelationshipGraph` (real Chromium ->
|
|
179
|
+
* ObservationArtifact -> **relationship derivation** -> comparability ->
|
|
180
|
+
* comparison -> ComparisonArtifact, see docs/ARCHITECTURE.md). Deterministic
|
|
181
|
+
* and synchronous: same `observation`/`geometryTolerancePx` in, same graph
|
|
182
|
+
* out, every time - no Chromium, target re-resolution, DOM access, randomness,
|
|
183
|
+
* clock, filesystem, or network involved, and `observation` is never
|
|
184
|
+
* mutated.
|
|
185
|
+
*
|
|
186
|
+
* Scope, by construction:
|
|
187
|
+
* - only targets present in `observation.requestConfig.targets` are ever
|
|
188
|
+
* considered (bounded at the existing 20-target/190-pair request limit -
|
|
189
|
+
* never arbitrary DOM/accessibility-tree traversal);
|
|
190
|
+
* - a configured target missing usable geometry (never resolved, or
|
|
191
|
+
* resolved but reported not-visible) becomes an `unresolvedTargets` entry
|
|
192
|
+
* with an honest reason, never a fabricated zero-sized relation;
|
|
193
|
+
* - for each unordered pair of geometry-eligible targets, exactly one
|
|
194
|
+
* record per relationship family is derived, with `subjectTarget`/
|
|
195
|
+
* `relatedTarget` fixed to that pair's configured order (earlier
|
|
196
|
+
* configured target is always `subjectTarget`) for every family except
|
|
197
|
+
* `follows-vertically` (see `verticalSequenceOf`) - so
|
|
198
|
+
* `pairwiseRelationships.length` never exceeds
|
|
199
|
+
* `MAX_PAIRWISE_RELATIONSHIP_RECORDS`;
|
|
200
|
+
* - DOM containment is deliberately not re-derived here: it already exists
|
|
201
|
+
* as `targetEvidence.<name>.containment` on the observation itself (see
|
|
202
|
+
* `TargetContainment` in domain/schema.ts, explicitly documented there as
|
|
203
|
+
* "never a layout/relationship graph") and stays separate from
|
|
204
|
+
* `fits-inside`/`does-not-fit-inside`, which is geometry-only;
|
|
205
|
+
* - the page-width relationship is derived only when both
|
|
206
|
+
* `pageEvidence.documentWidth` and `pageEvidence.viewportWidth` are
|
|
207
|
+
* themselves available - never defaulted to "fits" when evidence is
|
|
208
|
+
* missing.
|
|
209
|
+
*/
|
|
210
|
+
export declare function deriveLayoutRelationships(observation: ObservationArtifact, options?: DeriveLayoutRelationshipsOptions): DeriveLayoutRelationshipsResult;
|