artifact-graph 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -652,6 +652,126 @@ declare function prepareManagedHookBlock(options: ManagedHookBlockOptions): Prom
652
652
  declare function applyPreparedManagedHookBlocks(prepared: readonly PreparedManagedHookBlock[]): Promise<HookInstallResult[]>;
653
653
  declare function installManagedHookBlock(options: ManagedHookBlockOptions): Promise<HookInstallResult>;
654
654
 
655
+ /**
656
+ * Review Result Protocol validator.
657
+ * @feature ACA16 @scenario S-46
658
+ *
659
+ * Validates a JSON object against the review-result.schema.json constraints.
660
+ * Does NOT use ajv or any JSON-schema library — pure deterministic checks
661
+ * for zero-dependency CLI use.
662
+ */
663
+ interface ValidationError {
664
+ path: string;
665
+ message: string;
666
+ }
667
+ /**
668
+ * Validate a review result object against the v1.0 protocol.
669
+ *
670
+ * @param input - Parsed JSON to validate (not a string).
671
+ * @returns Array of validation errors. Empty = valid.
672
+ */
673
+ declare function validateReviewResult(input: unknown): ValidationError[];
674
+
675
+ /**
676
+ * Review Result Protocol v1.0 — TypeScript types.
677
+ *
678
+ * Canonical schema: schemas/review-result.schema.json
679
+ * These types are the programmatic equivalent; keep both in sync.
680
+ */
681
+ type ReviewStatus = 'SUCCEEDED' | 'FAILED' | 'BLOCKED' | 'NEEDS_INPUT' | 'SKIPPED';
682
+ type ReviewDecision = 'PASS' | 'FAIL' | 'PASS_WITH_RESIDUAL_MINOR' | 'BLOCKED' | 'NEEDS_INPUT' | 'NOT_APPLICABLE';
683
+ type FindingSeverity = 'block' | 'warn' | 'info';
684
+ type FindingStatus = 'open' | 'resolved' | 'accepted' | 'superseded';
685
+ type ExecutorType = 'script' | 'worker' | 'agent' | 'manual' | 'cli';
686
+ interface FindingLocation {
687
+ file?: string;
688
+ line?: number;
689
+ column?: number;
690
+ }
691
+ interface Finding {
692
+ id: string;
693
+ severity: FindingSeverity;
694
+ category?: string;
695
+ message: string;
696
+ location?: FindingLocation;
697
+ artifact_id?: string;
698
+ evidence?: string;
699
+ suggested_fix?: string;
700
+ status?: FindingStatus;
701
+ resolved_by?: string;
702
+ }
703
+ interface EvidenceObject {
704
+ type: string;
705
+ path: string;
706
+ status?: string;
707
+ decision?: string;
708
+ summary?: string;
709
+ command?: string;
710
+ result?: string;
711
+ }
712
+ type Evidence = string | EvidenceObject;
713
+ interface Producer {
714
+ executor: ExecutorType;
715
+ name: string;
716
+ skill?: string;
717
+ }
718
+ interface BatchDefinition {
719
+ id: string;
720
+ files: string[];
721
+ chars?: number;
722
+ }
723
+ interface ReviewMetrics {
724
+ files_reviewed?: number;
725
+ files_scanned?: number;
726
+ findings_count?: number;
727
+ deterministic_findings_count?: number;
728
+ semantic_findings_count?: number;
729
+ block_count?: number;
730
+ warn_count?: number;
731
+ info_count?: number;
732
+ resolved_count?: number;
733
+ batch_count?: number;
734
+ scenario_count?: number;
735
+ }
736
+ interface ReviewData {
737
+ source_files?: string[];
738
+ files?: string[];
739
+ batches?: BatchDefinition[];
740
+ metrics?: ReviewMetrics;
741
+ findings?: Finding[];
742
+ resolved_findings?: Finding[];
743
+ repair_worker_needed?: boolean;
744
+ }
745
+ interface RepairValidation {
746
+ command?: string;
747
+ exit_code?: number;
748
+ findings_remaining?: number;
749
+ }
750
+ interface RepairData {
751
+ source_review_run_id?: string;
752
+ source_review_stage_id?: string;
753
+ findings_addressed?: Finding[];
754
+ files_modified?: string[];
755
+ validation_after_repair?: RepairValidation;
756
+ }
757
+ interface ReviewResult {
758
+ schema_version: '1.0';
759
+ run_id: string;
760
+ stage_id?: string;
761
+ attempt?: number;
762
+ status: ReviewStatus;
763
+ decision: ReviewDecision;
764
+ summary: string;
765
+ outputs?: string[];
766
+ warnings?: string[];
767
+ blocking_reason?: string | null;
768
+ degradation?: string | null;
769
+ producer?: Producer;
770
+ evidence?: Evidence[];
771
+ review?: ReviewData;
772
+ repair?: RepairData;
773
+ }
774
+
655
775
  interface ArtifactNode {
656
776
  uid: string;
657
777
  type: string;
@@ -829,4 +949,4 @@ declare function discoverTargets(graph: ArtifactGraph, options?: DiscoverOptions
829
949
  declare function resolveArtifactContext(graph: ArtifactGraph, opts: ContextOptions): ContextManifest;
830
950
  declare function formatContextMarkdown(manifest: ContextManifest): string;
831
951
 
832
- export { ALWAYS_PRESENT_ITEMS as ALWAYS_PRESENT, type ArtifactChainDoctorReport, type ArtifactEdge, type ArtifactEdgeRule, type ArtifactExtraFieldSchema, type ArtifactGraph, type ArtifactGraphCliCandidate, type ArtifactGraphCliResolution, type ArtifactGraphCliSource, type ArtifactNode, type ArtifactSchema, type ArtifactTarget, type ArtifactTypeMetadata, type ArtifactTypeRole, type ArtifactTypeSchema, BASELINE_CONSTRAINTS, BASELINE_CONSTRAINTS_COUNT, BASELINE_ITEMS_COUNT, type CollectChangedPathsOptions, type ContextItem, type ContextManifest, type ContextMode, type ContextOptions, type ContextTier, DEFAULT_MAX_CHARS, DEFAULT_SCHEMA, type DiscoverOptions, type GitChangeMode, type GitChangeResult, type GitHookName, type HookInstallResult, type ImplementationBlueprintDraft, type ImplementationPacket, MIN_PROMPT_CHARS, type ManagedHookBlockOptions, type MissingDetail, type PacketAuditEntry, type PacketAuditSummary, type PacketCategory, type PacketItem, type PacketOmittedItem, type PacketOptions, type PacketPromptError, type PacketPromptOptions, type PacketTarget, type PacketTargetType, type PacketValidationIssue, type PacketValidationResult, type PreparedManagedHookBlock, type PromptValidationIssue, type PromptValidationResult, type QueryOptions, type ResolveArtifactGraphCliOptions, type ReviewOrderStep, type RiskChecklistItem, TARGET_ARTIFACT_TYPES, type TargetArtifactType, type TraceVersionResult, VALID_PACKET_TARGET_TYPES, VERSION_INDEX_SCHEMA_VERSION, VERSION_LOCK_PATH, VERSION_LOCK_SCHEMA_VERSION, type ValidationIssue, type VersionEdgeKind, type VersionIndex, type VersionLockAuditResult, type VersionLockBootstrapOptions, type VersionLockEntry, type VersionLockFile, type VersionLockIssue, type VersionLockRef, type VersionLockRefreshOptions, type VersionLockRefreshResult, type VersionLockSourceRef, type VersionLockStatus, type VersionLockUpdateOptions, type VersionSourceKind, type VersionedEdge, type VersionedNode, applyPreparedManagedHookBlocks, assemblePacket, auditPackets, auditVersionLock, bootstrapVersionLock, buildGraph, buildVersionIndex, collectChangedPaths, discoverAndAuditPackets, discoverTargets, doctorArtifactChain, formatContextMarkdown, getArtifactTypeMetadata, getTargetArtifactTypes, installManagedHookBlock, isPacketTargetType, isPacketTargetTypeDynamic, isTargetArtifactType, loadConfig, nextId, parseTargetSelector, parseTargetsFile, prepareManagedHookBlock, queryGraph, refreshVersionLock, renderDoctorMarkdown, renderMermaid, renderPacketMarkdown, renderPacketPrompt, renderTraceVersionMarkdown, renderVersionLockAuditMarkdown, renderVersionLockRefreshMarkdown, resolveArtifactContext, resolveArtifactGraphCli, resolveArtifactTypeName, resolveCliTarget, resolveGitHookPath, resolveMatrixEdges, scanArtifacts, traceVersion, updateVersionLock, validateExecutableTraceability, validateGraph, validatePacket, validatePacketMarkdown, validatePacketPrompt, validateScenarioPrdLinkIndex, validateScenarioPrdLinks, writeGraphCache };
952
+ export { ALWAYS_PRESENT_ITEMS as ALWAYS_PRESENT, type ArtifactChainDoctorReport, type ArtifactEdge, type ArtifactEdgeRule, type ArtifactExtraFieldSchema, type ArtifactGraph, type ArtifactGraphCliCandidate, type ArtifactGraphCliResolution, type ArtifactGraphCliSource, type ArtifactNode, type ArtifactSchema, type ArtifactTarget, type ArtifactTypeMetadata, type ArtifactTypeRole, type ArtifactTypeSchema, BASELINE_CONSTRAINTS, BASELINE_CONSTRAINTS_COUNT, BASELINE_ITEMS_COUNT, type BatchDefinition, type CollectChangedPathsOptions, type ContextItem, type ContextManifest, type ContextMode, type ContextOptions, type ContextTier, DEFAULT_MAX_CHARS, DEFAULT_SCHEMA, type DiscoverOptions, type Evidence, type EvidenceObject, type ExecutorType, type Finding, type FindingLocation, type FindingSeverity, type FindingStatus, type GitChangeMode, type GitChangeResult, type GitHookName, type HookInstallResult, type ImplementationBlueprintDraft, type ImplementationPacket, MIN_PROMPT_CHARS, type ManagedHookBlockOptions, type MissingDetail, type PacketAuditEntry, type PacketAuditSummary, type PacketCategory, type PacketItem, type PacketOmittedItem, type PacketOptions, type PacketPromptError, type PacketPromptOptions, type PacketTarget, type PacketTargetType, type PacketValidationIssue, type PacketValidationResult, type PreparedManagedHookBlock, type Producer, type PromptValidationIssue, type PromptValidationResult, type QueryOptions, type RepairData, type RepairValidation, type ResolveArtifactGraphCliOptions, type ReviewData, type ReviewDecision, type ReviewMetrics, type ReviewOrderStep, type ReviewResult, type ReviewStatus, type RiskChecklistItem, TARGET_ARTIFACT_TYPES, type TargetArtifactType, type TraceVersionResult, VALID_PACKET_TARGET_TYPES, VERSION_INDEX_SCHEMA_VERSION, VERSION_LOCK_PATH, VERSION_LOCK_SCHEMA_VERSION, type ValidationError, type ValidationIssue, type VersionEdgeKind, type VersionIndex, type VersionLockAuditResult, type VersionLockBootstrapOptions, type VersionLockEntry, type VersionLockFile, type VersionLockIssue, type VersionLockRef, type VersionLockRefreshOptions, type VersionLockRefreshResult, type VersionLockSourceRef, type VersionLockStatus, type VersionLockUpdateOptions, type VersionSourceKind, type VersionedEdge, type VersionedNode, applyPreparedManagedHookBlocks, assemblePacket, auditPackets, auditVersionLock, bootstrapVersionLock, buildGraph, buildVersionIndex, collectChangedPaths, discoverAndAuditPackets, discoverTargets, doctorArtifactChain, formatContextMarkdown, getArtifactTypeMetadata, getTargetArtifactTypes, installManagedHookBlock, isPacketTargetType, isPacketTargetTypeDynamic, isTargetArtifactType, loadConfig, nextId, parseTargetSelector, parseTargetsFile, prepareManagedHookBlock, queryGraph, refreshVersionLock, renderDoctorMarkdown, renderMermaid, renderPacketMarkdown, renderPacketPrompt, renderTraceVersionMarkdown, renderVersionLockAuditMarkdown, renderVersionLockRefreshMarkdown, resolveArtifactContext, resolveArtifactGraphCli, resolveArtifactTypeName, resolveCliTarget, resolveGitHookPath, resolveMatrixEdges, scanArtifacts, traceVersion, updateVersionLock, validateExecutableTraceability, validateGraph, validatePacket, validatePacketMarkdown, validatePacketPrompt, validateReviewResult, validateScenarioPrdLinkIndex, validateScenarioPrdLinks, writeGraphCache };
package/dist/index.d.ts CHANGED
@@ -652,6 +652,126 @@ declare function prepareManagedHookBlock(options: ManagedHookBlockOptions): Prom
652
652
  declare function applyPreparedManagedHookBlocks(prepared: readonly PreparedManagedHookBlock[]): Promise<HookInstallResult[]>;
653
653
  declare function installManagedHookBlock(options: ManagedHookBlockOptions): Promise<HookInstallResult>;
654
654
 
655
+ /**
656
+ * Review Result Protocol validator.
657
+ * @feature ACA16 @scenario S-46
658
+ *
659
+ * Validates a JSON object against the review-result.schema.json constraints.
660
+ * Does NOT use ajv or any JSON-schema library — pure deterministic checks
661
+ * for zero-dependency CLI use.
662
+ */
663
+ interface ValidationError {
664
+ path: string;
665
+ message: string;
666
+ }
667
+ /**
668
+ * Validate a review result object against the v1.0 protocol.
669
+ *
670
+ * @param input - Parsed JSON to validate (not a string).
671
+ * @returns Array of validation errors. Empty = valid.
672
+ */
673
+ declare function validateReviewResult(input: unknown): ValidationError[];
674
+
675
+ /**
676
+ * Review Result Protocol v1.0 — TypeScript types.
677
+ *
678
+ * Canonical schema: schemas/review-result.schema.json
679
+ * These types are the programmatic equivalent; keep both in sync.
680
+ */
681
+ type ReviewStatus = 'SUCCEEDED' | 'FAILED' | 'BLOCKED' | 'NEEDS_INPUT' | 'SKIPPED';
682
+ type ReviewDecision = 'PASS' | 'FAIL' | 'PASS_WITH_RESIDUAL_MINOR' | 'BLOCKED' | 'NEEDS_INPUT' | 'NOT_APPLICABLE';
683
+ type FindingSeverity = 'block' | 'warn' | 'info';
684
+ type FindingStatus = 'open' | 'resolved' | 'accepted' | 'superseded';
685
+ type ExecutorType = 'script' | 'worker' | 'agent' | 'manual' | 'cli';
686
+ interface FindingLocation {
687
+ file?: string;
688
+ line?: number;
689
+ column?: number;
690
+ }
691
+ interface Finding {
692
+ id: string;
693
+ severity: FindingSeverity;
694
+ category?: string;
695
+ message: string;
696
+ location?: FindingLocation;
697
+ artifact_id?: string;
698
+ evidence?: string;
699
+ suggested_fix?: string;
700
+ status?: FindingStatus;
701
+ resolved_by?: string;
702
+ }
703
+ interface EvidenceObject {
704
+ type: string;
705
+ path: string;
706
+ status?: string;
707
+ decision?: string;
708
+ summary?: string;
709
+ command?: string;
710
+ result?: string;
711
+ }
712
+ type Evidence = string | EvidenceObject;
713
+ interface Producer {
714
+ executor: ExecutorType;
715
+ name: string;
716
+ skill?: string;
717
+ }
718
+ interface BatchDefinition {
719
+ id: string;
720
+ files: string[];
721
+ chars?: number;
722
+ }
723
+ interface ReviewMetrics {
724
+ files_reviewed?: number;
725
+ files_scanned?: number;
726
+ findings_count?: number;
727
+ deterministic_findings_count?: number;
728
+ semantic_findings_count?: number;
729
+ block_count?: number;
730
+ warn_count?: number;
731
+ info_count?: number;
732
+ resolved_count?: number;
733
+ batch_count?: number;
734
+ scenario_count?: number;
735
+ }
736
+ interface ReviewData {
737
+ source_files?: string[];
738
+ files?: string[];
739
+ batches?: BatchDefinition[];
740
+ metrics?: ReviewMetrics;
741
+ findings?: Finding[];
742
+ resolved_findings?: Finding[];
743
+ repair_worker_needed?: boolean;
744
+ }
745
+ interface RepairValidation {
746
+ command?: string;
747
+ exit_code?: number;
748
+ findings_remaining?: number;
749
+ }
750
+ interface RepairData {
751
+ source_review_run_id?: string;
752
+ source_review_stage_id?: string;
753
+ findings_addressed?: Finding[];
754
+ files_modified?: string[];
755
+ validation_after_repair?: RepairValidation;
756
+ }
757
+ interface ReviewResult {
758
+ schema_version: '1.0';
759
+ run_id: string;
760
+ stage_id?: string;
761
+ attempt?: number;
762
+ status: ReviewStatus;
763
+ decision: ReviewDecision;
764
+ summary: string;
765
+ outputs?: string[];
766
+ warnings?: string[];
767
+ blocking_reason?: string | null;
768
+ degradation?: string | null;
769
+ producer?: Producer;
770
+ evidence?: Evidence[];
771
+ review?: ReviewData;
772
+ repair?: RepairData;
773
+ }
774
+
655
775
  interface ArtifactNode {
656
776
  uid: string;
657
777
  type: string;
@@ -829,4 +949,4 @@ declare function discoverTargets(graph: ArtifactGraph, options?: DiscoverOptions
829
949
  declare function resolveArtifactContext(graph: ArtifactGraph, opts: ContextOptions): ContextManifest;
830
950
  declare function formatContextMarkdown(manifest: ContextManifest): string;
831
951
 
832
- export { ALWAYS_PRESENT_ITEMS as ALWAYS_PRESENT, type ArtifactChainDoctorReport, type ArtifactEdge, type ArtifactEdgeRule, type ArtifactExtraFieldSchema, type ArtifactGraph, type ArtifactGraphCliCandidate, type ArtifactGraphCliResolution, type ArtifactGraphCliSource, type ArtifactNode, type ArtifactSchema, type ArtifactTarget, type ArtifactTypeMetadata, type ArtifactTypeRole, type ArtifactTypeSchema, BASELINE_CONSTRAINTS, BASELINE_CONSTRAINTS_COUNT, BASELINE_ITEMS_COUNT, type CollectChangedPathsOptions, type ContextItem, type ContextManifest, type ContextMode, type ContextOptions, type ContextTier, DEFAULT_MAX_CHARS, DEFAULT_SCHEMA, type DiscoverOptions, type GitChangeMode, type GitChangeResult, type GitHookName, type HookInstallResult, type ImplementationBlueprintDraft, type ImplementationPacket, MIN_PROMPT_CHARS, type ManagedHookBlockOptions, type MissingDetail, type PacketAuditEntry, type PacketAuditSummary, type PacketCategory, type PacketItem, type PacketOmittedItem, type PacketOptions, type PacketPromptError, type PacketPromptOptions, type PacketTarget, type PacketTargetType, type PacketValidationIssue, type PacketValidationResult, type PreparedManagedHookBlock, type PromptValidationIssue, type PromptValidationResult, type QueryOptions, type ResolveArtifactGraphCliOptions, type ReviewOrderStep, type RiskChecklistItem, TARGET_ARTIFACT_TYPES, type TargetArtifactType, type TraceVersionResult, VALID_PACKET_TARGET_TYPES, VERSION_INDEX_SCHEMA_VERSION, VERSION_LOCK_PATH, VERSION_LOCK_SCHEMA_VERSION, type ValidationIssue, type VersionEdgeKind, type VersionIndex, type VersionLockAuditResult, type VersionLockBootstrapOptions, type VersionLockEntry, type VersionLockFile, type VersionLockIssue, type VersionLockRef, type VersionLockRefreshOptions, type VersionLockRefreshResult, type VersionLockSourceRef, type VersionLockStatus, type VersionLockUpdateOptions, type VersionSourceKind, type VersionedEdge, type VersionedNode, applyPreparedManagedHookBlocks, assemblePacket, auditPackets, auditVersionLock, bootstrapVersionLock, buildGraph, buildVersionIndex, collectChangedPaths, discoverAndAuditPackets, discoverTargets, doctorArtifactChain, formatContextMarkdown, getArtifactTypeMetadata, getTargetArtifactTypes, installManagedHookBlock, isPacketTargetType, isPacketTargetTypeDynamic, isTargetArtifactType, loadConfig, nextId, parseTargetSelector, parseTargetsFile, prepareManagedHookBlock, queryGraph, refreshVersionLock, renderDoctorMarkdown, renderMermaid, renderPacketMarkdown, renderPacketPrompt, renderTraceVersionMarkdown, renderVersionLockAuditMarkdown, renderVersionLockRefreshMarkdown, resolveArtifactContext, resolveArtifactGraphCli, resolveArtifactTypeName, resolveCliTarget, resolveGitHookPath, resolveMatrixEdges, scanArtifacts, traceVersion, updateVersionLock, validateExecutableTraceability, validateGraph, validatePacket, validatePacketMarkdown, validatePacketPrompt, validateScenarioPrdLinkIndex, validateScenarioPrdLinks, writeGraphCache };
952
+ export { ALWAYS_PRESENT_ITEMS as ALWAYS_PRESENT, type ArtifactChainDoctorReport, type ArtifactEdge, type ArtifactEdgeRule, type ArtifactExtraFieldSchema, type ArtifactGraph, type ArtifactGraphCliCandidate, type ArtifactGraphCliResolution, type ArtifactGraphCliSource, type ArtifactNode, type ArtifactSchema, type ArtifactTarget, type ArtifactTypeMetadata, type ArtifactTypeRole, type ArtifactTypeSchema, BASELINE_CONSTRAINTS, BASELINE_CONSTRAINTS_COUNT, BASELINE_ITEMS_COUNT, type BatchDefinition, type CollectChangedPathsOptions, type ContextItem, type ContextManifest, type ContextMode, type ContextOptions, type ContextTier, DEFAULT_MAX_CHARS, DEFAULT_SCHEMA, type DiscoverOptions, type Evidence, type EvidenceObject, type ExecutorType, type Finding, type FindingLocation, type FindingSeverity, type FindingStatus, type GitChangeMode, type GitChangeResult, type GitHookName, type HookInstallResult, type ImplementationBlueprintDraft, type ImplementationPacket, MIN_PROMPT_CHARS, type ManagedHookBlockOptions, type MissingDetail, type PacketAuditEntry, type PacketAuditSummary, type PacketCategory, type PacketItem, type PacketOmittedItem, type PacketOptions, type PacketPromptError, type PacketPromptOptions, type PacketTarget, type PacketTargetType, type PacketValidationIssue, type PacketValidationResult, type PreparedManagedHookBlock, type Producer, type PromptValidationIssue, type PromptValidationResult, type QueryOptions, type RepairData, type RepairValidation, type ResolveArtifactGraphCliOptions, type ReviewData, type ReviewDecision, type ReviewMetrics, type ReviewOrderStep, type ReviewResult, type ReviewStatus, type RiskChecklistItem, TARGET_ARTIFACT_TYPES, type TargetArtifactType, type TraceVersionResult, VALID_PACKET_TARGET_TYPES, VERSION_INDEX_SCHEMA_VERSION, VERSION_LOCK_PATH, VERSION_LOCK_SCHEMA_VERSION, type ValidationError, type ValidationIssue, type VersionEdgeKind, type VersionIndex, type VersionLockAuditResult, type VersionLockBootstrapOptions, type VersionLockEntry, type VersionLockFile, type VersionLockIssue, type VersionLockRef, type VersionLockRefreshOptions, type VersionLockRefreshResult, type VersionLockSourceRef, type VersionLockStatus, type VersionLockUpdateOptions, type VersionSourceKind, type VersionedEdge, type VersionedNode, applyPreparedManagedHookBlocks, assemblePacket, auditPackets, auditVersionLock, bootstrapVersionLock, buildGraph, buildVersionIndex, collectChangedPaths, discoverAndAuditPackets, discoverTargets, doctorArtifactChain, formatContextMarkdown, getArtifactTypeMetadata, getTargetArtifactTypes, installManagedHookBlock, isPacketTargetType, isPacketTargetTypeDynamic, isTargetArtifactType, loadConfig, nextId, parseTargetSelector, parseTargetsFile, prepareManagedHookBlock, queryGraph, refreshVersionLock, renderDoctorMarkdown, renderMermaid, renderPacketMarkdown, renderPacketPrompt, renderTraceVersionMarkdown, renderVersionLockAuditMarkdown, renderVersionLockRefreshMarkdown, resolveArtifactContext, resolveArtifactGraphCli, resolveArtifactTypeName, resolveCliTarget, resolveGitHookPath, resolveMatrixEdges, scanArtifacts, traceVersion, updateVersionLock, validateExecutableTraceability, validateGraph, validatePacket, validatePacketMarkdown, validatePacketPrompt, validateReviewResult, validateScenarioPrdLinkIndex, validateScenarioPrdLinks, writeGraphCache };
package/dist/index.js CHANGED
@@ -2578,6 +2578,252 @@ function findManagedRange(content, begin, end) {
2578
2578
  };
2579
2579
  }
2580
2580
 
2581
+ // src/review-result-validator.ts
2582
+ var VALID_STATUSES = /* @__PURE__ */ new Set([
2583
+ "SUCCEEDED",
2584
+ "FAILED",
2585
+ "BLOCKED",
2586
+ "NEEDS_INPUT",
2587
+ "SKIPPED"
2588
+ ]);
2589
+ var VALID_DECISIONS = /* @__PURE__ */ new Set([
2590
+ "PASS",
2591
+ "FAIL",
2592
+ "PASS_WITH_RESIDUAL_MINOR",
2593
+ "BLOCKED",
2594
+ "NEEDS_INPUT",
2595
+ "NOT_APPLICABLE"
2596
+ ]);
2597
+ var VALID_SEVERITIES = /* @__PURE__ */ new Set(["block", "warn", "info"]);
2598
+ var VALID_FINDING_STATUSES = /* @__PURE__ */ new Set(["open", "resolved", "accepted", "superseded"]);
2599
+ var VALID_EXECUTORS = /* @__PURE__ */ new Set(["script", "worker", "agent", "manual", "cli"]);
2600
+ function validateReviewResult(input) {
2601
+ const errors = [];
2602
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
2603
+ return [{ path: "$", message: "Root must be a non-null object" }];
2604
+ }
2605
+ const obj = input;
2606
+ if (obj.schema_version !== "1.0") {
2607
+ errors.push({ path: "$.schema_version", message: `Must be "1.0", got ${JSON.stringify(obj.schema_version)}` });
2608
+ }
2609
+ if (typeof obj.run_id !== "string" || obj.run_id.length === 0) {
2610
+ errors.push({ path: "$.run_id", message: "Must be a non-empty string" });
2611
+ }
2612
+ if (!VALID_STATUSES.has(String(obj.status))) {
2613
+ errors.push({ path: "$.status", message: `Must be one of ${[...VALID_STATUSES].join(", ")}, got ${JSON.stringify(obj.status)}` });
2614
+ }
2615
+ if (!VALID_DECISIONS.has(String(obj.decision))) {
2616
+ errors.push({ path: "$.decision", message: `Must be one of ${[...VALID_DECISIONS].join(", ")}, got ${JSON.stringify(obj.decision)}` });
2617
+ }
2618
+ if (typeof obj.summary !== "string") {
2619
+ errors.push({ path: "$.summary", message: "Must be a string" });
2620
+ }
2621
+ if (obj.stage_id !== void 0 && typeof obj.stage_id !== "string") {
2622
+ errors.push({ path: "$.stage_id", message: "Must be a string if present" });
2623
+ }
2624
+ if (obj.attempt !== void 0 && (!Number.isInteger(obj.attempt) || obj.attempt < 1)) {
2625
+ errors.push({ path: "$.attempt", message: "Must be a positive integer if present" });
2626
+ }
2627
+ if (obj.outputs !== void 0) {
2628
+ checkStringArray(obj.outputs, "$.outputs", errors);
2629
+ }
2630
+ if (obj.warnings !== void 0) {
2631
+ checkStringArray(obj.warnings, "$.warnings", errors);
2632
+ }
2633
+ checkOptionalNullableString(obj.blocking_reason, "$.blocking_reason", errors);
2634
+ checkOptionalNullableString(obj.degradation, "$.degradation", errors);
2635
+ if (obj.producer !== void 0) {
2636
+ if (!isPlainObject(obj.producer)) {
2637
+ errors.push({ path: "$.producer", message: "Must be an object" });
2638
+ } else {
2639
+ const p = obj.producer;
2640
+ if (typeof p.executor !== "string") {
2641
+ errors.push({ path: "$.producer.executor", message: "Must be a string" });
2642
+ } else if (!VALID_EXECUTORS.has(p.executor)) {
2643
+ errors.push({ path: "$.producer.executor", message: `Must be one of ${[...VALID_EXECUTORS].join(", ")}; got ${JSON.stringify(p.executor)}` });
2644
+ }
2645
+ if (typeof p.name !== "string") {
2646
+ errors.push({ path: "$.producer.name", message: "Must be a string" });
2647
+ }
2648
+ checkOptionalString(p.skill, "$.producer.skill", errors);
2649
+ }
2650
+ }
2651
+ if (obj.evidence !== void 0) {
2652
+ if (!Array.isArray(obj.evidence)) {
2653
+ errors.push({ path: "$.evidence", message: "Must be an array" });
2654
+ } else for (let i = 0; i < obj.evidence.length; i++) {
2655
+ const e = obj.evidence[i];
2656
+ if (typeof e === "string") continue;
2657
+ if (isPlainObject(e)) {
2658
+ const ev = e;
2659
+ if (typeof ev.type !== "string") {
2660
+ errors.push({ path: `$.evidence[${i}].type`, message: "Must be a string" });
2661
+ }
2662
+ if (typeof ev.path !== "string") {
2663
+ errors.push({ path: `$.evidence[${i}].path`, message: "Must be a string" });
2664
+ }
2665
+ for (const key of ["status", "decision", "summary", "command", "result"]) {
2666
+ checkOptionalString(ev[key], `$.evidence[${i}].${key}`, errors);
2667
+ }
2668
+ } else {
2669
+ errors.push({ path: `$.evidence[${i}]`, message: "Must be a string or object" });
2670
+ }
2671
+ }
2672
+ }
2673
+ if (obj.review !== void 0) {
2674
+ validateReviewData(obj.review, "$.review", errors);
2675
+ }
2676
+ if (obj.repair !== void 0) {
2677
+ if (!isPlainObject(obj.repair)) {
2678
+ errors.push({ path: "$.repair", message: "Must be an object" });
2679
+ } else {
2680
+ const r = obj.repair;
2681
+ checkOptionalString(r.source_review_run_id, "$.repair.source_review_run_id", errors);
2682
+ checkOptionalString(r.source_review_stage_id, "$.repair.source_review_stage_id", errors);
2683
+ if (r.findings_addressed !== void 0) {
2684
+ validateFindingArray(r.findings_addressed, "$.repair.findings_addressed", errors);
2685
+ }
2686
+ if (r.files_modified !== void 0) {
2687
+ checkStringArray(r.files_modified, "$.repair.files_modified", errors);
2688
+ }
2689
+ if (r.validation_after_repair !== void 0) {
2690
+ validateRepairValidation(r.validation_after_repair, "$.repair.validation_after_repair", errors);
2691
+ }
2692
+ }
2693
+ }
2694
+ return errors;
2695
+ }
2696
+ function checkStringArray(val, path, errors) {
2697
+ if (!Array.isArray(val)) {
2698
+ errors.push({ path, message: "Must be an array" });
2699
+ return;
2700
+ }
2701
+ for (let i = 0; i < val.length; i++) {
2702
+ if (typeof val[i] !== "string") {
2703
+ errors.push({ path: `${path}[${i}]`, message: "Must be a string" });
2704
+ }
2705
+ }
2706
+ }
2707
+ function isPlainObject(val) {
2708
+ return typeof val === "object" && val !== null && !Array.isArray(val);
2709
+ }
2710
+ function checkOptionalString(val, path, errors) {
2711
+ if (val !== void 0 && typeof val !== "string") {
2712
+ errors.push({ path, message: "Must be a string if present" });
2713
+ }
2714
+ }
2715
+ function checkOptionalNullableString(val, path, errors) {
2716
+ if (val !== void 0 && val !== null && typeof val !== "string") {
2717
+ errors.push({ path, message: "Must be a string or null if present" });
2718
+ }
2719
+ }
2720
+ function checkOptionalInteger(val, path, errors, minimum) {
2721
+ if (val === void 0) return;
2722
+ if (!Number.isInteger(val) || minimum !== void 0 && val < minimum) {
2723
+ errors.push({ path, message: minimum === void 0 ? "Must be an integer if present" : `Must be an integer >= ${minimum} if present` });
2724
+ }
2725
+ }
2726
+ function validateFinding(val, path, errors) {
2727
+ if (!isPlainObject(val)) {
2728
+ errors.push({ path, message: "Must be a non-null object" });
2729
+ return;
2730
+ }
2731
+ const f = val;
2732
+ if (typeof f.id !== "string" || f.id.length === 0) {
2733
+ errors.push({ path: `${path}.id`, message: "Must be a non-empty string" });
2734
+ }
2735
+ if (!VALID_SEVERITIES.has(String(f.severity))) {
2736
+ errors.push({ path: `${path}.severity`, message: `Must be one of block, warn, info; got ${JSON.stringify(f.severity)}` });
2737
+ }
2738
+ if (typeof f.message !== "string") {
2739
+ errors.push({ path: `${path}.message`, message: "Must be a string" });
2740
+ }
2741
+ if (f.status !== void 0 && !VALID_FINDING_STATUSES.has(String(f.status))) {
2742
+ errors.push({ path: `${path}.status`, message: `Must be one of ${[...VALID_FINDING_STATUSES].join(", ")}; got ${JSON.stringify(f.status)}` });
2743
+ }
2744
+ for (const key of ["category", "artifact_id", "evidence", "suggested_fix", "resolved_by"]) {
2745
+ checkOptionalString(f[key], `${path}.${key}`, errors);
2746
+ }
2747
+ if (f.location !== void 0) {
2748
+ if (!isPlainObject(f.location)) {
2749
+ errors.push({ path: `${path}.location`, message: "Must be an object if present" });
2750
+ } else {
2751
+ checkOptionalString(f.location.file, `${path}.location.file`, errors);
2752
+ checkOptionalInteger(f.location.line, `${path}.location.line`, errors);
2753
+ checkOptionalInteger(f.location.column, `${path}.location.column`, errors);
2754
+ }
2755
+ }
2756
+ }
2757
+ function validateFindingArray(val, path, errors) {
2758
+ if (!Array.isArray(val)) {
2759
+ errors.push({ path, message: "Must be an array" });
2760
+ return;
2761
+ }
2762
+ for (let i = 0; i < val.length; i++) validateFinding(val[i], `${path}[${i}]`, errors);
2763
+ }
2764
+ function validateReviewData(val, path, errors) {
2765
+ if (!isPlainObject(val)) {
2766
+ errors.push({ path, message: "Must be a non-null object" });
2767
+ return;
2768
+ }
2769
+ const r = val;
2770
+ if (r.source_files !== void 0) checkStringArray(r.source_files, `${path}.source_files`, errors);
2771
+ if (r.files !== void 0) checkStringArray(r.files, `${path}.files`, errors);
2772
+ if (r.findings !== void 0) validateFindingArray(r.findings, `${path}.findings`, errors);
2773
+ if (r.resolved_findings !== void 0) validateFindingArray(r.resolved_findings, `${path}.resolved_findings`, errors);
2774
+ if (r.batches !== void 0) validateBatches(r.batches, `${path}.batches`, errors);
2775
+ if (r.metrics !== void 0) validateMetrics(r.metrics, `${path}.metrics`, errors);
2776
+ if (r.repair_worker_needed !== void 0 && typeof r.repair_worker_needed !== "boolean") {
2777
+ errors.push({ path: `${path}.repair_worker_needed`, message: "Must be a boolean if present" });
2778
+ }
2779
+ }
2780
+ function validateBatches(val, path, errors) {
2781
+ if (!Array.isArray(val)) {
2782
+ errors.push({ path, message: "Must be an array" });
2783
+ return;
2784
+ }
2785
+ for (let i = 0; i < val.length; i++) {
2786
+ const itemPath = `${path}[${i}]`;
2787
+ const b = val[i];
2788
+ if (!isPlainObject(b)) {
2789
+ errors.push({ path: itemPath, message: "Must be an object" });
2790
+ continue;
2791
+ }
2792
+ if (typeof b.id !== "string") errors.push({ path: `${itemPath}.id`, message: "Must be a string" });
2793
+ checkStringArray(b.files, `${itemPath}.files`, errors);
2794
+ checkOptionalInteger(b.chars, `${itemPath}.chars`, errors);
2795
+ }
2796
+ }
2797
+ var METRIC_FIELDS = [
2798
+ "files_reviewed",
2799
+ "files_scanned",
2800
+ "findings_count",
2801
+ "deterministic_findings_count",
2802
+ "semantic_findings_count",
2803
+ "block_count",
2804
+ "warn_count",
2805
+ "info_count",
2806
+ "resolved_count",
2807
+ "batch_count",
2808
+ "scenario_count"
2809
+ ];
2810
+ function validateMetrics(val, path, errors) {
2811
+ if (!isPlainObject(val)) {
2812
+ errors.push({ path, message: "Must be an object" });
2813
+ return;
2814
+ }
2815
+ for (const key of METRIC_FIELDS) checkOptionalInteger(val[key], `${path}.${key}`, errors, 0);
2816
+ }
2817
+ function validateRepairValidation(val, path, errors) {
2818
+ if (!isPlainObject(val)) {
2819
+ errors.push({ path, message: "Must be an object" });
2820
+ return;
2821
+ }
2822
+ checkOptionalString(val.command, `${path}.command`, errors);
2823
+ checkOptionalInteger(val.exit_code, `${path}.exit_code`, errors);
2824
+ checkOptionalInteger(val.findings_remaining, `${path}.findings_remaining`, errors, 0);
2825
+ }
2826
+
2581
2827
  // src/index.ts
2582
2828
  var TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
2583
2829
  var NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
@@ -6023,6 +6269,7 @@ export {
6023
6269
  validatePacket,
6024
6270
  validatePacketMarkdown,
6025
6271
  validatePacketPrompt,
6272
+ validateReviewResult,
6026
6273
  validateScenarioPrdLinkIndex,
6027
6274
  validateScenarioPrdLinks,
6028
6275
  writeGraphCache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artifact-graph",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Git-native Markdown artifact graph scanner and validator",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -27,7 +27,8 @@
27
27
  "types": "./dist/index.d.cts",
28
28
  "default": "./dist/index.cjs"
29
29
  }
30
- }
30
+ },
31
+ "./schemas/review-result.schema.json": "./schemas/review-result.schema.json"
31
32
  },
32
33
  "engines": {
33
34
  "node": ">=22.0.0"
@@ -54,6 +55,7 @@
54
55
  "NOTICE",
55
56
  "INSTALL.md",
56
57
  "dist",
58
+ "schemas",
57
59
  "scripts",
58
60
  "templates"
59
61
  ],