@nebulacomponents/citable 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +14 -3
  3. package/dist/universal/.agents/skills/citable/SKILL.md +14 -3
  4. package/dist/universal/.agents/skills/citable/VERSION +1 -1
  5. package/dist/universal/.agents/skills/citable/commands/README.md +2 -0
  6. package/dist/universal/.agents/skills/citable/commands/governance.md +17 -0
  7. package/dist/universal/.agents/skills/citable/commands/reviews.md +18 -0
  8. package/dist/universal/.agents/skills/citable/manifest.json +14 -7
  9. package/dist/universal/.agents/skills/citable/references/capability-boundaries.md +5 -0
  10. package/dist/universal/.agents/skills/citable/schemas/exception.schema.json +70 -0
  11. package/dist/universal/.agents/skills/citable/schemas/review-item.schema.json +12 -0
  12. package/dist/universal/.agents/skills/citable/schemas/review-policy.schema.json +35 -0
  13. package/dist/universal/.agents/skills/citable/schemas/reviewer.schema.json +32 -0
  14. package/dist/universal/.agents/skills/citable/schemas/sampling-plan.schema.json +4 -0
  15. package/dist/universal/.claude/skills/citable/SKILL.md +14 -3
  16. package/dist/universal/.claude/skills/citable/VERSION +1 -1
  17. package/dist/universal/.claude/skills/citable/commands/README.md +2 -0
  18. package/dist/universal/.claude/skills/citable/commands/governance.md +17 -0
  19. package/dist/universal/.claude/skills/citable/commands/reviews.md +18 -0
  20. package/dist/universal/.claude/skills/citable/manifest.json +14 -7
  21. package/dist/universal/.claude/skills/citable/references/capability-boundaries.md +5 -0
  22. package/dist/universal/.claude/skills/citable/schemas/exception.schema.json +70 -0
  23. package/dist/universal/.claude/skills/citable/schemas/review-item.schema.json +12 -0
  24. package/dist/universal/.claude/skills/citable/schemas/review-policy.schema.json +35 -0
  25. package/dist/universal/.claude/skills/citable/schemas/reviewer.schema.json +32 -0
  26. package/dist/universal/.claude/skills/citable/schemas/sampling-plan.schema.json +4 -0
  27. package/dist/universal/.cursor/skills/citable/SKILL.md +14 -3
  28. package/dist/universal/.cursor/skills/citable/VERSION +1 -1
  29. package/dist/universal/.cursor/skills/citable/commands/README.md +2 -0
  30. package/dist/universal/.cursor/skills/citable/commands/governance.md +17 -0
  31. package/dist/universal/.cursor/skills/citable/commands/reviews.md +18 -0
  32. package/dist/universal/.cursor/skills/citable/manifest.json +14 -7
  33. package/dist/universal/.cursor/skills/citable/references/capability-boundaries.md +5 -0
  34. package/dist/universal/.cursor/skills/citable/schemas/exception.schema.json +70 -0
  35. package/dist/universal/.cursor/skills/citable/schemas/review-item.schema.json +12 -0
  36. package/dist/universal/.cursor/skills/citable/schemas/review-policy.schema.json +35 -0
  37. package/dist/universal/.cursor/skills/citable/schemas/reviewer.schema.json +32 -0
  38. package/dist/universal/.cursor/skills/citable/schemas/sampling-plan.schema.json +4 -0
  39. package/dist/universal/.gemini/skills/citable/SKILL.md +14 -3
  40. package/dist/universal/.gemini/skills/citable/VERSION +1 -1
  41. package/dist/universal/.gemini/skills/citable/commands/README.md +2 -0
  42. package/dist/universal/.gemini/skills/citable/commands/governance.md +17 -0
  43. package/dist/universal/.gemini/skills/citable/commands/reviews.md +18 -0
  44. package/dist/universal/.gemini/skills/citable/manifest.json +14 -7
  45. package/dist/universal/.gemini/skills/citable/references/capability-boundaries.md +5 -0
  46. package/dist/universal/.gemini/skills/citable/schemas/exception.schema.json +70 -0
  47. package/dist/universal/.gemini/skills/citable/schemas/review-item.schema.json +12 -0
  48. package/dist/universal/.gemini/skills/citable/schemas/review-policy.schema.json +35 -0
  49. package/dist/universal/.gemini/skills/citable/schemas/reviewer.schema.json +32 -0
  50. package/dist/universal/.gemini/skills/citable/schemas/sampling-plan.schema.json +4 -0
  51. package/dist/universal/.github/skills/citable/SKILL.md +14 -3
  52. package/dist/universal/.github/skills/citable/VERSION +1 -1
  53. package/dist/universal/.github/skills/citable/commands/README.md +2 -0
  54. package/dist/universal/.github/skills/citable/commands/governance.md +17 -0
  55. package/dist/universal/.github/skills/citable/commands/reviews.md +18 -0
  56. package/dist/universal/.github/skills/citable/manifest.json +14 -7
  57. package/dist/universal/.github/skills/citable/references/capability-boundaries.md +5 -0
  58. package/dist/universal/.github/skills/citable/schemas/exception.schema.json +70 -0
  59. package/dist/universal/.github/skills/citable/schemas/review-item.schema.json +12 -0
  60. package/dist/universal/.github/skills/citable/schemas/review-policy.schema.json +35 -0
  61. package/dist/universal/.github/skills/citable/schemas/reviewer.schema.json +32 -0
  62. package/dist/universal/.github/skills/citable/schemas/sampling-plan.schema.json +4 -0
  63. package/dist/universal/.kiro/skills/citable/SKILL.md +14 -3
  64. package/dist/universal/.kiro/skills/citable/VERSION +1 -1
  65. package/dist/universal/.kiro/skills/citable/commands/README.md +2 -0
  66. package/dist/universal/.kiro/skills/citable/commands/governance.md +17 -0
  67. package/dist/universal/.kiro/skills/citable/commands/reviews.md +18 -0
  68. package/dist/universal/.kiro/skills/citable/manifest.json +14 -7
  69. package/dist/universal/.kiro/skills/citable/references/capability-boundaries.md +5 -0
  70. package/dist/universal/.kiro/skills/citable/schemas/exception.schema.json +70 -0
  71. package/dist/universal/.kiro/skills/citable/schemas/review-item.schema.json +12 -0
  72. package/dist/universal/.kiro/skills/citable/schemas/review-policy.schema.json +35 -0
  73. package/dist/universal/.kiro/skills/citable/schemas/reviewer.schema.json +32 -0
  74. package/dist/universal/.kiro/skills/citable/schemas/sampling-plan.schema.json +4 -0
  75. package/dist/universal/.opencode/skills/citable/SKILL.md +14 -3
  76. package/dist/universal/.opencode/skills/citable/VERSION +1 -1
  77. package/dist/universal/.opencode/skills/citable/commands/README.md +2 -0
  78. package/dist/universal/.opencode/skills/citable/commands/governance.md +17 -0
  79. package/dist/universal/.opencode/skills/citable/commands/reviews.md +18 -0
  80. package/dist/universal/.opencode/skills/citable/manifest.json +14 -7
  81. package/dist/universal/.opencode/skills/citable/references/capability-boundaries.md +5 -0
  82. package/dist/universal/.opencode/skills/citable/schemas/exception.schema.json +70 -0
  83. package/dist/universal/.opencode/skills/citable/schemas/review-item.schema.json +12 -0
  84. package/dist/universal/.opencode/skills/citable/schemas/review-policy.schema.json +35 -0
  85. package/dist/universal/.opencode/skills/citable/schemas/reviewer.schema.json +32 -0
  86. package/dist/universal/.opencode/skills/citable/schemas/sampling-plan.schema.json +4 -0
  87. package/dist/universal/.pi/agent/skills/citable/SKILL.md +14 -3
  88. package/dist/universal/.pi/agent/skills/citable/VERSION +1 -1
  89. package/dist/universal/.pi/agent/skills/citable/commands/README.md +2 -0
  90. package/dist/universal/.pi/agent/skills/citable/commands/governance.md +17 -0
  91. package/dist/universal/.pi/agent/skills/citable/commands/reviews.md +18 -0
  92. package/dist/universal/.pi/agent/skills/citable/manifest.json +14 -7
  93. package/dist/universal/.pi/agent/skills/citable/references/capability-boundaries.md +5 -0
  94. package/dist/universal/.pi/agent/skills/citable/schemas/exception.schema.json +70 -0
  95. package/dist/universal/.pi/agent/skills/citable/schemas/review-item.schema.json +12 -0
  96. package/dist/universal/.pi/agent/skills/citable/schemas/review-policy.schema.json +35 -0
  97. package/dist/universal/.pi/agent/skills/citable/schemas/reviewer.schema.json +32 -0
  98. package/dist/universal/.pi/agent/skills/citable/schemas/sampling-plan.schema.json +4 -0
  99. package/dist/universal/.qoder/skills/citable/SKILL.md +14 -3
  100. package/dist/universal/.qoder/skills/citable/VERSION +1 -1
  101. package/dist/universal/.qoder/skills/citable/commands/README.md +2 -0
  102. package/dist/universal/.qoder/skills/citable/commands/governance.md +17 -0
  103. package/dist/universal/.qoder/skills/citable/commands/reviews.md +18 -0
  104. package/dist/universal/.qoder/skills/citable/manifest.json +14 -7
  105. package/dist/universal/.qoder/skills/citable/references/capability-boundaries.md +5 -0
  106. package/dist/universal/.qoder/skills/citable/schemas/exception.schema.json +70 -0
  107. package/dist/universal/.qoder/skills/citable/schemas/review-item.schema.json +12 -0
  108. package/dist/universal/.qoder/skills/citable/schemas/review-policy.schema.json +35 -0
  109. package/dist/universal/.qoder/skills/citable/schemas/reviewer.schema.json +32 -0
  110. package/dist/universal/.qoder/skills/citable/schemas/sampling-plan.schema.json +4 -0
  111. package/dist/universal/.rovodev/skills/citable/SKILL.md +14 -3
  112. package/dist/universal/.rovodev/skills/citable/VERSION +1 -1
  113. package/dist/universal/.rovodev/skills/citable/commands/README.md +2 -0
  114. package/dist/universal/.rovodev/skills/citable/commands/governance.md +17 -0
  115. package/dist/universal/.rovodev/skills/citable/commands/reviews.md +18 -0
  116. package/dist/universal/.rovodev/skills/citable/manifest.json +14 -7
  117. package/dist/universal/.rovodev/skills/citable/references/capability-boundaries.md +5 -0
  118. package/dist/universal/.rovodev/skills/citable/schemas/exception.schema.json +70 -0
  119. package/dist/universal/.rovodev/skills/citable/schemas/review-item.schema.json +12 -0
  120. package/dist/universal/.rovodev/skills/citable/schemas/review-policy.schema.json +35 -0
  121. package/dist/universal/.rovodev/skills/citable/schemas/reviewer.schema.json +32 -0
  122. package/dist/universal/.rovodev/skills/citable/schemas/sampling-plan.schema.json +4 -0
  123. package/dist/universal/.trae/skills/citable/SKILL.md +14 -3
  124. package/dist/universal/.trae/skills/citable/VERSION +1 -1
  125. package/dist/universal/.trae/skills/citable/commands/README.md +2 -0
  126. package/dist/universal/.trae/skills/citable/commands/governance.md +17 -0
  127. package/dist/universal/.trae/skills/citable/commands/reviews.md +18 -0
  128. package/dist/universal/.trae/skills/citable/manifest.json +14 -7
  129. package/dist/universal/.trae/skills/citable/references/capability-boundaries.md +5 -0
  130. package/dist/universal/.trae/skills/citable/schemas/exception.schema.json +70 -0
  131. package/dist/universal/.trae/skills/citable/schemas/review-item.schema.json +12 -0
  132. package/dist/universal/.trae/skills/citable/schemas/review-policy.schema.json +35 -0
  133. package/dist/universal/.trae/skills/citable/schemas/reviewer.schema.json +32 -0
  134. package/dist/universal/.trae/skills/citable/schemas/sampling-plan.schema.json +4 -0
  135. package/dist/universal/.trae-cn/skills/citable/SKILL.md +14 -3
  136. package/dist/universal/.trae-cn/skills/citable/VERSION +1 -1
  137. package/dist/universal/.trae-cn/skills/citable/commands/README.md +2 -0
  138. package/dist/universal/.trae-cn/skills/citable/commands/governance.md +17 -0
  139. package/dist/universal/.trae-cn/skills/citable/commands/reviews.md +18 -0
  140. package/dist/universal/.trae-cn/skills/citable/manifest.json +14 -7
  141. package/dist/universal/.trae-cn/skills/citable/references/capability-boundaries.md +5 -0
  142. package/dist/universal/.trae-cn/skills/citable/schemas/exception.schema.json +70 -0
  143. package/dist/universal/.trae-cn/skills/citable/schemas/review-item.schema.json +12 -0
  144. package/dist/universal/.trae-cn/skills/citable/schemas/review-policy.schema.json +35 -0
  145. package/dist/universal/.trae-cn/skills/citable/schemas/reviewer.schema.json +32 -0
  146. package/dist/universal/.trae-cn/skills/citable/schemas/sampling-plan.schema.json +4 -0
  147. package/dist/universal/manifest.json +171 -87
  148. package/package.json +2 -2
  149. package/schemas/exception.schema.json +70 -0
  150. package/schemas/review-item.schema.json +12 -0
  151. package/schemas/review-policy.schema.json +35 -0
  152. package/schemas/reviewer.schema.json +32 -0
  153. package/schemas/sampling-plan.schema.json +4 -0
  154. package/skill/SKILL.md +14 -3
  155. package/skill/commands/README.md +2 -0
  156. package/skill/commands/governance.md +17 -0
  157. package/skill/commands/reviews.md +18 -0
  158. package/skill/references/capability-boundaries.md +5 -0
  159. package/src/cli/index.js +34 -0
  160. package/src/commands/governance.js +144 -0
  161. package/src/commands/reviews.js +73 -0
  162. package/src/commands/selfUpgrade.js +1 -1
  163. package/src/registries/index.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulacomponents/citable",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Production-grade SEO, AEO, and GEO agent skill with auditable detection, claim governance, evidence validation, and multi-agent installation.",
5
5
  "keywords": [
6
6
  "seo",
@@ -71,7 +71,7 @@
71
71
  "LICENSE"
72
72
  ],
73
73
  "engines": {
74
- "node": ">=22.22.2"
74
+ "node": ">=24.0.0"
75
75
  },
76
76
  "license": "Apache-2.0",
77
77
  "repository": {
@@ -0,0 +1,70 @@
1
+ {
2
+ "$id": "citable://schemas/exception.schema.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Governed exception registry",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["version", "kind", "updated", "entries"],
8
+ "properties": {
9
+ "version": { "const": 1 },
10
+ "kind": { "const": "exceptions" },
11
+ "updated": { "type": "string", "format": "date-time" },
12
+ "entries": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object", "additionalProperties": false,
16
+ "required": ["exception_id", "policy_id", "policy_hash", "status", "source_run_id", "finding_ids", "finding_hashes", "reason", "risk_statement", "residual_risk", "compensating_controls", "evidence_ids", "evidence_hashes", "owner_reviewer_id", "reviewer_assignments", "reviewer_independence", "created_at", "expires_at", "renewal_count", "renewal_limit", "invalidation_conditions", "audit_history"],
17
+ "properties": {
18
+ "exception_id": { "type": "string", "pattern": "^EXCEPTION-[A-Z0-9][A-Z0-9_-]*$" },
19
+ "policy_id": { "type": "string", "pattern": "^POLICY-" },
20
+ "policy_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
21
+ "status": { "type": "string", "enum": ["proposed", "approved", "revoked", "superseded"] },
22
+ "source_run_id": { "type": "string", "minLength": 1 },
23
+ "finding_ids": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
24
+ "finding_hashes": { "type": "object", "minProperties": 1, "additionalProperties": { "type": "string", "pattern": "^[a-f0-9]{64}$" } },
25
+ "reason": { "type": "string", "minLength": 1 },
26
+ "risk_statement": { "type": "string", "minLength": 1 },
27
+ "residual_risk": { "type": "string", "enum": ["documented", "not_documented"] },
28
+ "compensating_controls": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
29
+ "evidence_ids": { "type": "array", "items": { "type": "string" } },
30
+ "evidence_hashes": { "type": "object", "additionalProperties": { "type": "string", "pattern": "^[a-f0-9]{64}$" } },
31
+ "owner_reviewer_id": { "type": "string", "pattern": "^REVIEWER-" },
32
+ "reviewer_assignments": {
33
+ "type": "array", "minItems": 1,
34
+ "items": {
35
+ "type": "object", "additionalProperties": false, "required": ["reviewer_id", "role"],
36
+ "properties": {
37
+ "reviewer_id": { "type": "string", "pattern": "^REVIEWER-" },
38
+ "role": { "type": "string", "enum": ["technical_reviewer", "subject_matter_reviewer", "independent_reviewer", "approver", "risk_acceptor", "remediation_implementer", "content_author"] }
39
+ }
40
+ }
41
+ },
42
+ "reviewer_independence": { "type": "string", "enum": ["established", "not_established", "conflicted"] },
43
+ "created_at": { "type": "string", "format": "date-time" },
44
+ "expires_at": { "type": "string", "format": "date-time" },
45
+ "renewal_count": { "type": "integer", "minimum": 0 },
46
+ "renewal_limit": { "type": "integer", "minimum": 0 },
47
+ "invalidation_conditions": {
48
+ "type": "array", "minItems": 1, "uniqueItems": true,
49
+ "items": { "type": "string", "enum": ["finding_changed", "evidence_changed", "policy_changed", "resource_changed", "intervention_changed"] }
50
+ },
51
+ "related_intervention_id": { "type": ["string", "null"] },
52
+ "supersedes_exception_id": { "type": ["string", "null"] },
53
+ "superseded_by_exception_id": { "type": ["string", "null"] },
54
+ "audit_history": {
55
+ "type": "array", "minItems": 1,
56
+ "items": {
57
+ "type": "object", "additionalProperties": false, "required": ["timestamp", "actor_reviewer_id", "action", "note"],
58
+ "properties": {
59
+ "timestamp": { "type": "string", "format": "date-time" },
60
+ "actor_reviewer_id": { "type": "string", "pattern": "^REVIEWER-" },
61
+ "action": { "type": "string", "enum": ["proposed", "approved", "renewed", "revoked", "superseded"] },
62
+ "note": { "type": "string", "minLength": 1 }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$id":"citable://schemas/review-item.schema.json","$schema":"http://json-schema.org/draft-07/schema#","title":"Semantic review item registry","type":"object","additionalProperties":false,"required":["version","kind","updated","entries"],
3
+ "properties":{"version":{"const":1},"kind":{"const":"review_items"},"updated":{"type":"string","format":"date-time"},"entries":{"type":"array","items":{"type":"object","additionalProperties":false,
4
+ "required":["review_item_id","source_run_id","finding_id","finding_hash","review_type","status","priority_inputs","priority_score","priority_tier","missing_inputs","policy_id","assigned_reviewer_ids","decisions","created_at"],
5
+ "properties":{"review_item_id":{"type":"string","pattern":"^REVIEW-[A-Z0-9][A-Z0-9_-]*$"},"source_run_id":{"type":"string"},"finding_id":{"type":"string"},"finding_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"},
6
+ "review_type":{"type":"string","enum":["claim_support","citation_correctness","passage_integrity","narrative_accuracy","recommendation_eligibility","comparison_fairness","intent_alignment","evidence_strength","general_semantic_review"]},
7
+ "status":{"type":"string","enum":["queued","assigned","in_review","adjudication_required","completed","withdrawn"]},
8
+ "priority_inputs":{"type":"object","additionalProperties":false,"required":["business_importance","citation_frequency","evidence_age_days","source_authority","regulatory_exposure","intervention_impact","change_magnitude","disagreement_history"],"properties":{"business_importance":{"type":["integer","null"],"minimum":0,"maximum":5},"citation_frequency":{"type":["integer","null"],"minimum":0},"evidence_age_days":{"type":["integer","null"],"minimum":0},"source_authority":{"type":["integer","null"],"minimum":0,"maximum":5},"regulatory_exposure":{"type":["integer","null"],"minimum":0,"maximum":5},"intervention_impact":{"type":["integer","null"],"minimum":0,"maximum":5},"change_magnitude":{"type":["integer","null"],"minimum":0,"maximum":5},"disagreement_history":{"type":["integer","null"],"minimum":0}}},
9
+ "priority_score":{"type":"number","minimum":0},"priority_tier":{"type":"string","enum":["urgent","high","normal","insufficient_inputs"]},"missing_inputs":{"type":"array","items":{"type":"string"}},"policy_id":{"type":"string","pattern":"^POLICY-"},"assigned_reviewer_ids":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^REVIEWER-"}},
10
+ "decisions":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["reviewer_id","verdict","rubric","evidence_refs","rationale","decided_at","review_item_hash"],"properties":{"reviewer_id":{"type":"string","pattern":"^REVIEWER-"},"verdict":{"type":"string","enum":["supported","partially_supported","unsupported","inconclusive","not_applicable"]},"rubric":{"type":"string"},"evidence_refs":{"type":"array","minItems":1,"items":{"type":"string"}},"rationale":{"type":"string","minLength":1},"decided_at":{"type":"string","format":"date-time"},"review_item_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"}}}},"adjudication":{"type":["object","null"],"additionalProperties":false,"required":["reviewer_id","verdict","evidence_refs","rationale","decided_at","review_item_hash"],"properties":{"reviewer_id":{"type":"string","pattern":"^REVIEWER-"},"verdict":{"type":"string","enum":["supported","partially_supported","unsupported","inconclusive","not_applicable"]},"evidence_refs":{"type":"array","minItems":1,"items":{"type":"string"}},"rationale":{"type":"string","minLength":1},"decided_at":{"type":"string","format":"date-time"},"review_item_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"}}},"created_at":{"type":"string","format":"date-time"}
11
+ }}}}
12
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "$id": "citable://schemas/review-policy.schema.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Review policy registry",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["version", "kind", "updated", "entries"],
8
+ "properties": {
9
+ "version": { "const": 1 },
10
+ "kind": { "const": "review_policies" },
11
+ "updated": { "type": "string", "format": "date-time" },
12
+ "entries": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object", "additionalProperties": false,
16
+ "required": ["policy_id", "name", "status", "required_roles", "separation_rules", "max_exception_days", "max_renewals"],
17
+ "properties": {
18
+ "policy_id": { "type": "string", "pattern": "^POLICY-[A-Z0-9][A-Z0-9_-]*$" },
19
+ "name": { "type": "string", "minLength": 1 },
20
+ "status": { "type": "string", "enum": ["active", "deprecated"] },
21
+ "required_roles": {
22
+ "type": "array", "minItems": 1, "uniqueItems": true,
23
+ "items": { "type": "string", "enum": ["technical_reviewer", "subject_matter_reviewer", "independent_reviewer", "approver", "risk_acceptor"] }
24
+ },
25
+ "separation_rules": {
26
+ "type": "array", "uniqueItems": true,
27
+ "items": { "type": "string", "enum": ["author_cannot_verify_own_claim", "implementer_cannot_solely_verify", "commercial_owner_requires_independent_benefit_review", "risk_acceptor_must_be_authorized"] }
28
+ },
29
+ "max_exception_days": { "type": "integer", "minimum": 1, "maximum": 366 },
30
+ "max_renewals": { "type": "integer", "minimum": 0, "maximum": 20 }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$id": "citable://schemas/reviewer.schema.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Reviewer registry",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["version", "kind", "updated", "entries"],
8
+ "properties": {
9
+ "version": { "const": 1 },
10
+ "kind": { "const": "reviewers" },
11
+ "updated": { "type": "string", "format": "date-time" },
12
+ "entries": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "required": ["reviewer_id", "name", "status", "roles", "authorized_scopes", "conflicts"],
18
+ "properties": {
19
+ "reviewer_id": { "type": "string", "pattern": "^REVIEWER-[A-Z0-9][A-Z0-9_-]*$" },
20
+ "name": { "type": "string", "minLength": 1 },
21
+ "status": { "type": "string", "enum": ["active", "inactive"] },
22
+ "roles": {
23
+ "type": "array", "minItems": 1, "uniqueItems": true,
24
+ "items": { "type": "string", "enum": ["content_author", "evidence_owner", "technical_reviewer", "subject_matter_reviewer", "independent_reviewer", "approver", "risk_acceptor", "remediation_implementer"] }
25
+ },
26
+ "authorized_scopes": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
27
+ "conflicts": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$id":"citable://schemas/sampling-plan.schema.json","$schema":"http://json-schema.org/draft-07/schema#","title":"Semantic review sampling plan registry","type":"object","additionalProperties":false,"required":["version","kind","updated","entries"],
3
+ "properties":{"version":{"const":1},"kind":{"const":"sampling_plans"},"updated":{"type":"string","format":"date-time"},"entries":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["sampling_plan_id","status","method","population_statuses","review_types","sample_size","seed","inclusion_criteria","exclusion_criteria","reviewer_assignment_method","extrapolation_limits","population_hash","selected_item_ids","created_at"],"properties":{"sampling_plan_id":{"type":"string","pattern":"^SAMPLE-[A-Z0-9][A-Z0-9_-]*$"},"status":{"type":"string","enum":["draft","selected","completed"]},"method":{"type":"string","enum":["census","simple_random"]},"population_statuses":{"type":"array","minItems":1,"items":{"type":"string","enum":["queued","assigned","in_review","adjudication_required","completed"]}},"review_types":{"type":"array","items":{"type":"string"}},"sample_size":{"type":"integer","minimum":1},"seed":{"type":"string","minLength":1},"inclusion_criteria":{"type":"array","items":{"type":"string"}},"exclusion_criteria":{"type":"array","items":{"type":"string"}},"reviewer_assignment_method":{"type":"string","minLength":1},"extrapolation_limits":{"type":"array","minItems":1,"items":{"type":"string"}},"population_hash":{"type":["string","null"],"pattern":"^[a-f0-9]{64}$"},"selected_item_ids":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^REVIEW-"}},"created_at":{"type":"string","format":"date-time"}}}}}
4
+ }
package/skill/SKILL.md CHANGED
@@ -7,7 +7,7 @@ description: >
7
7
  generative engine optimization, structured data governance, claim substantiation,
8
8
  crawler policy, entity consistency, content discoverability, or wants a site audited
9
9
  for how search and AI systems will retrieve, understand, cite, or recommend it.
10
- version: 1.7.0
10
+ version: 1.9.0
11
11
  ---
12
12
 
13
13
  # Citable — evidence and change control for search and AI citation readiness
@@ -108,6 +108,13 @@ citable connect disconnect --connection-id <id> [--write]
108
108
  citable objectives init --input <json|yaml> [--write]
109
109
  citable objectives validate
110
110
  citable evaluate [objective-id] [--ref-date YYYY-MM-DD]
111
+ citable governance validate [--ref-date YYYY-MM-DD]
112
+ citable governance evaluate <run-id> [--ref-date YYYY-MM-DD]
113
+ citable reviews queue <run-id> <policy-id> [--write]
114
+ citable reviews prioritize [--write]
115
+ citable reviews plan --input <json|yaml> [--write]
116
+ citable reviews sample <sampling-plan-id> [--write]
117
+ citable reviews evaluate
111
118
  ```
112
119
 
113
120
  Audit scopes: `technical seo aeo geo architecture entity claims evidence schema
@@ -165,8 +172,9 @@ mandatory.
165
172
  ## Registries are the source of truth
166
173
 
167
174
  `.citable/` holds YAML registries for queries, prompts, entities, claims,
168
- evidence, pages, crawlers, competitors, experiments, metrics, objectives,
169
- interventions, and optional connection state, all schema-validated
175
+ evidence, pages, crawlers, competitors, experiments, metrics, objectives,
176
+ interventions, optional connection state, reviewers, review policies, and
177
+ governed exceptions, semantic review items, and sampling plans, all schema-validated
170
178
  (`schemas/*.schema.json`) with referential integrity checks. Rules:
171
179
 
172
180
  - Never overwrite registry content without history — use the loader/saver in
@@ -175,6 +183,9 @@ interventions, and optional connection state, all schema-validated
175
183
  competitors, pricing). Mark entities `incomplete` and list `required_input`.
176
184
  - Claim status transitions toward `verified` require existing verified evidence
177
185
  plus human semantic review; automation only downgrades (fail-closed).
186
+ - Never encode an accepted exception as a passed or resolved finding. Validate
187
+ reviewer authority and separation of duties, bind approval to exact source
188
+ finding/policy/evidence hashes, and report enforcement disposition separately.
178
189
 
179
190
  ## Fail-closed behaviour
180
191
 
@@ -27,6 +27,8 @@ intent, not executability, so statuses are strict:
27
27
  | /citable metrics import | implemented — validates declared CSV/JSON metrics and writes immutable observations |
28
28
  | /citable objectives init / validate | implemented — user-owned metric selection, cohorts, windows, and guardrails |
29
29
  | /citable evaluate | implemented — independent baseline/evaluation comparisons with inconclusive handling |
30
+ | /citable governance validate / evaluate | implemented — validates reviewer and exception authority and emits immutable dispositions without changing failed findings |
31
+ | /citable reviews queue / prioritize / plan / sample / evaluate | implemented — materiality queues, reproducible sampling, stale-decision checks, and independent disagreement adjudication |
30
32
  | /citable ingest, map-site, map-queries, map-prompts, map-entities, map-evidence | specified (ingest.md) |
31
33
  | /citable optimize-page | specified (optimize-page.md) — requires source-to-render mapping, claim-preserving rewrites, build execution, rollback; none of that is proven yet |
32
34
  | /citable create-page, answer-block, architect, interlink, consolidate, metadata | specified (page-work.md) |
@@ -0,0 +1,17 @@
1
+ # Governance validation and exception evaluation
2
+
3
+ Use `citable governance validate` before relying on any accepted exception. It
4
+ validates reviewer roles and scopes, conflicts, policy requirements, separation
5
+ of duties, source bindings, expiry, renewal, and referential integrity.
6
+
7
+ Use `citable governance evaluate <run-id>` to create a new immutable evidence
8
+ package. The command never edits the source run. Every source finding retains
9
+ `technical_state: failed`; a valid exception is represented only as
10
+ `enforcement_disposition: accepted_exception` with active validity and
11
+ documented residual risk.
12
+
13
+ Refuse authorization when policy, finding, or evidence hashes have changed;
14
+ the exception is expired, revoked, superseded, conflicted, unauthorized, or
15
+ over-renewed; required roles are absent; or more than one active exception
16
+ matches a finding. Reviewer records are declarations and do not independently
17
+ prove real-world identity, competence, independence, or legal authority.
@@ -0,0 +1,18 @@
1
+ # Semantic review queues and sampling
2
+
3
+ Use `reviews queue` to create hash-bound review work from heuristic or
4
+ review-required findings. Newly queued items expose all missing materiality
5
+ inputs and remain `insufficient_inputs`; model confidence alone never controls
6
+ priority. After authorized operators supply business importance, citation
7
+ frequency, evidence age and authority, regulatory exposure, intervention
8
+ impact, change magnitude, and disagreement history, use `reviews prioritize`.
9
+
10
+ Sampling plans support only `census` and reproducible `simple_random` methods.
11
+ Every selection records its seed, population hash, inclusion/exclusion criteria,
12
+ assignment method, and extrapolation limits. Do not present sampled review as
13
+ complete validation or generalize beyond the recorded population.
14
+
15
+ `reviews evaluate` rejects stale or unauthorized decisions. Distinct verdicts
16
+ produce `adjudication_required`; vote counting never establishes semantic truth.
17
+ Completion requires an evidence-linked, hash-bound decision from an active
18
+ independent reviewer.
@@ -13,12 +13,17 @@ Use the narrowest supported state. Never promote evidence across rows.
13
13
  | Cited | Import or disclosed adapter | Complete `observe citations` answer with citation URL and product/adapter mode |
14
14
  | Materially supports answer | Human review required | `citation_review` maps answer claim to source passage and names the reviewer |
15
15
  | Recommended | Operator supplied + review | Explicit recommendation, constraints, provider/mode/locale/time |
16
+ | Accepted exception | Governed owner record | Active policy, authorized reviewers, separation-of-duty checks, exact finding/policy/evidence hashes, expiry, controls, and documented residual risk |
16
17
 
17
18
  URL audit mode alone does not prove crawler identity, WAF allowlisting,
18
19
  production-log access, index presence, selected canonical, rendered DOM parity,
19
20
  or provider citation behavior. Observation collectors can supply narrower
20
21
  evidence for these states; unavailable inputs remain `not_evidenced`.
21
22
 
23
+ An accepted exception changes enforcement disposition only. It does not change
24
+ the source finding, prove remediation, or establish that reviewer identity,
25
+ competence, independence, or legal authority was externally authenticated.
26
+
22
27
  Primary-source lineage for these boundaries:
23
28
 
24
29
  - Perplexity documents separate `PerplexityBot` and `Perplexity-User` purposes,
package/src/cli/index.js CHANGED
@@ -17,6 +17,8 @@ import { applyRemediation } from '../commands/applyRemediation.js';
17
17
  import { monitor } from '../commands/monitor.js';
18
18
  import { evaluateObjective, importMetrics, initializeObjective, validateObjectives } from '../commands/measurement.js';
19
19
  import { configureConnection, connectionStatus, discoverConnections, disconnectConnection, syncConnection, validateConnection } from '../commands/connect.js';
20
+ import { evaluateDispositions, validateGovernance } from '../commands/governance.js';
21
+ import { evaluateReviews, initializeSamplingPlan, prioritizeReviews, queueReviews, selectSample } from '../commands/reviews.js';
20
22
 
21
23
  const HELP = `citable — SEO / AEO / GEO audit, remediation, validation, and governance
22
24
 
@@ -53,6 +55,13 @@ Commands
53
55
  objectives init Validate/add one objective from --input (--write to save)
54
56
  objectives validate Validate objective contracts and metric references
55
57
  evaluate [objective-id] Compare objective baseline and evaluation windows
58
+ governance validate Validate reviewer, policy, and exception controls
59
+ governance evaluate [run] Produce immutable enforcement dispositions without changing findings
60
+ reviews queue [run policy] Create semantic review work from heuristic findings
61
+ reviews prioritize Rank review work from explicit materiality inputs
62
+ reviews plan Validate/add a sampling plan from --input
63
+ reviews sample [plan] Select a reproducible census or seeded random sample
64
+ reviews evaluate Detect stale decisions and require disagreement adjudication
56
65
  self-upgrade Check for a newer version and upgrade the npx cache
57
66
 
58
67
  Options
@@ -238,6 +247,31 @@ export async function main(argv = process.argv.slice(2), options = {}) {
238
247
  out(args, `evaluate ${r.objective_id}: ${r.status}\n` + r.metrics.map((metric) => ` ${metric.metric_id}: ${metric.state}${metric.state === 'observed' ? ` (${metric.baseline} → ${metric.evaluation})` : ''}`).join('\n') + `\n${r.interpretation}`, r);
239
248
  break;
240
249
  }
250
+ case 'governance': {
251
+ const mode = args._[0];
252
+ if (mode === 'validate') {
253
+ const r = validateGovernance(root, { refDate: args.refDate });
254
+ out(args, `governance validate: ${r.ok ? 'OK' : 'PROBLEMS'} (${r.counts.reviewers} reviewer(s), ${r.counts.policies} policy/policies, ${r.counts.exceptions} exception(s))${r.problems.length ? `\n${r.problems.map((problem) => ` - ${problem}`).join('\n')}` : ''}`, r);
255
+ if (!r.ok) process.exitCode = 1;
256
+ } else if (mode === 'evaluate') {
257
+ const r = evaluateDispositions(root, { runId: args._[1], refDate: args.refDate });
258
+ const accepted = r.dispositions.filter((item) => item.enforcement_disposition === 'accepted_exception').length;
259
+ out(args, `governance evaluate ${r.source_run_id}: ${r.dispositions.length} failed finding(s), ${accepted} accepted exception(s)\nEvidence package: ${r.dir}`, r);
260
+ if (r.dispositions.some((item) => item.enforcement_disposition === 'blocked_ambiguous_exception')) process.exitCode = 1;
261
+ } else throw new Error('usage: citable governance <validate|evaluate [run-id]> [--ref-date YYYY-MM-DD]');
262
+ break;
263
+ }
264
+ case 'reviews': {
265
+ const mode=args._[0]; let r;
266
+ if(mode==='queue') r=queueReviews(root,{runId:args._[1],policyId:args._[2],write:args.write});
267
+ else if(mode==='prioritize') r=prioritizeReviews(root,{write:args.write});
268
+ else if(mode==='plan') r=initializeSamplingPlan(root,{input:args.input,write:args.write});
269
+ else if(mode==='sample') r=selectSample(root,{planId:args._[1],write:args.write});
270
+ else if(mode==='evaluate') { r=evaluateReviews(root); if(!r.ok) process.exitCode=1; }
271
+ else throw new Error('usage: citable reviews <queue|prioritize|plan|sample|evaluate> [options]');
272
+ out(args,`reviews ${mode}: ${r.created?.length ?? r.items?.length ?? r.selected_item_ids?.length ?? r.results?.length ?? 1} item(s)${args.write?' written':' (dry run)'}`,r);
273
+ break;
274
+ }
241
275
  case 'self-upgrade': {
242
276
  const output = await selfUpgradeCommand(argv.slice(1));
243
277
  console.log(output);
@@ -0,0 +1,144 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createRun } from '../evidence/run.js';
4
+ import { loadRegistries, checkReferentialIntegrity } from '../registries/index.js';
5
+ import { readJson, sha256, parseRefDate } from '../shared/io.js';
6
+
7
+ function recordHash(value) {
8
+ return sha256(JSON.stringify(value));
9
+ }
10
+
11
+ function assigned(exception, role) {
12
+ return exception.reviewer_assignments.filter((item) => item.role === role).map((item) => item.reviewer_id);
13
+ }
14
+
15
+ function reviewerCanAct(reviewer, role, finding) {
16
+ if (!reviewer || reviewer.status !== 'active' || !reviewer.roles.includes(role)) return false;
17
+ const scopes = reviewer.authorized_scopes || [];
18
+ return scopes.includes('*') || scopes.includes(finding.detector_id) || scopes.includes(finding.subject.identifier);
19
+ }
20
+
21
+ function exceptionProblems(exception, policy, reviewers, findings, evidence, refDate) {
22
+ const problems = [];
23
+ if (!policy || policy.status !== 'active') problems.push('review policy is missing or inactive');
24
+ if (exception.status !== 'approved') problems.push(`exception status is ${exception.status}`);
25
+ if (exception.residual_risk !== 'documented') problems.push('residual risk is not documented');
26
+ if (new Date(exception.expires_at) < refDate) problems.push('exception is expired');
27
+ if (exception.renewal_count > exception.renewal_limit) problems.push('exception renewal limit exceeded');
28
+ if (policy && exception.renewal_limit > policy.max_renewals) problems.push('exception renewal limit exceeds policy');
29
+ if (policy && new Date(exception.expires_at) - new Date(exception.created_at) > policy.max_exception_days * 86400000) problems.push('exception duration exceeds policy');
30
+ if (policy && recordHash(policy) !== exception.policy_hash) problems.push('policy changed since approval');
31
+ if (exception.superseded_by_exception_id) problems.push('exception is superseded');
32
+ const owner = reviewers.get(exception.owner_reviewer_id);
33
+ if (!owner || owner.status !== 'active') problems.push('exception owner is missing or inactive');
34
+
35
+ for (const findingId of exception.finding_ids) {
36
+ const finding = findings.get(findingId);
37
+ if (!finding) problems.push(`source finding ${findingId} is unavailable`);
38
+ else if (recordHash(finding) !== exception.finding_hashes[findingId]) problems.push(`source finding ${findingId} changed since approval`);
39
+ }
40
+ for (const evidenceId of exception.evidence_ids) {
41
+ const item = evidence.get(evidenceId);
42
+ if (!item) problems.push(`evidence ${evidenceId} is unavailable`);
43
+ else if (recordHash(item) !== exception.evidence_hashes[evidenceId]) problems.push(`evidence ${evidenceId} changed since approval`);
44
+ }
45
+
46
+ if (policy) {
47
+ for (const role of policy.required_roles) {
48
+ const actors = assigned(exception, role);
49
+ if (actors.length === 0) problems.push(`required role ${role} is unassigned`);
50
+ for (const actor of actors) {
51
+ const reviewer = reviewers.get(actor);
52
+ const scoped = exception.finding_ids.every((id) => findings.has(id) && reviewerCanAct(reviewer, role, findings.get(id)));
53
+ if (!scoped) problems.push(`${actor} is not active and authorized for role ${role} across the exception scope`);
54
+ }
55
+ }
56
+ const authors = new Set(assigned(exception, 'content_author'));
57
+ const implementers = new Set(assigned(exception, 'remediation_implementer'));
58
+ const verifiers = new Set([...assigned(exception, 'technical_reviewer'), ...assigned(exception, 'subject_matter_reviewer'), ...assigned(exception, 'independent_reviewer')]);
59
+ if (policy.separation_rules.includes('author_cannot_verify_own_claim') && [...authors].some((id) => verifiers.has(id))) problems.push('content author also verifies the scoped finding');
60
+ if (policy.separation_rules.includes('implementer_cannot_solely_verify') && verifiers.size === 1 && [...implementers].some((id) => verifiers.has(id))) problems.push('remediation implementer is the sole verifier');
61
+ if (policy.separation_rules.includes('commercial_owner_requires_independent_benefit_review') && exception.reviewer_independence !== 'established') problems.push('independent review is not established');
62
+ if (policy.separation_rules.includes('risk_acceptor_must_be_authorized') && assigned(exception, 'risk_acceptor').length === 0) problems.push('authorized risk acceptor is missing');
63
+ }
64
+ for (const assignment of exception.reviewer_assignments) {
65
+ const reviewer = reviewers.get(assignment.reviewer_id);
66
+ if (!reviewer) continue;
67
+ if (reviewer.status !== 'active' || !reviewer.roles.includes(assignment.role)) problems.push(`${reviewer.reviewer_id} is not active in assigned role ${assignment.role}`);
68
+ if ((reviewer.conflicts || []).some((scope) => exception.finding_ids.some((id) => findings.get(id)?.subject.identifier === scope))) problems.push(`${reviewer.reviewer_id} has a declared conflict with the exception scope`);
69
+ }
70
+ return [...new Set(problems)];
71
+ }
72
+
73
+ export function validateGovernance(root, { refDate } = {}) {
74
+ const { registries, problems: schemaProblems } = loadRegistries(root);
75
+ const problems = [...schemaProblems, ...checkReferentialIntegrity(registries)];
76
+ const reference = parseRefDate(refDate);
77
+ const reviewers = new Map(registries.reviewers.entries.map((item) => [item.reviewer_id, item]));
78
+ const policies = new Map(registries.review_policies.entries.map((item) => [item.policy_id, item]));
79
+ const evidence = new Map(registries.evidence.entries.map((item) => [item.evidence_id, item]));
80
+ const activeByFinding = new Map();
81
+ for (const exception of registries.exceptions.entries) {
82
+ const file = path.join(root, '.citable', 'runs', exception.source_run_id, 'findings.json');
83
+ const findings = new Map(fs.existsSync(file) ? readJson(file).map((item) => [item.finding_id, item]) : []);
84
+ const exceptionIssues = exceptionProblems(exception, policies.get(exception.policy_id), reviewers, findings, evidence, reference);
85
+ problems.push(...exceptionIssues.map((problem) => `exceptions/${exception.exception_id}: ${problem}`));
86
+ if (exceptionIssues.length === 0) {
87
+ for (const findingId of exception.finding_ids) {
88
+ const key = `${exception.source_run_id}:${findingId}`;
89
+ activeByFinding.set(key, [...(activeByFinding.get(key) || []), exception.exception_id]);
90
+ }
91
+ }
92
+ }
93
+ for (const [scope, exceptionIds] of activeByFinding) {
94
+ if (exceptionIds.length > 1) problems.push(`ambiguous active exceptions for ${scope}: ${exceptionIds.join(', ')}`);
95
+ }
96
+ return { ok: problems.length === 0, problems, counts: { reviewers: reviewers.size, policies: policies.size, exceptions: registries.exceptions.entries.length } };
97
+ }
98
+
99
+ export function evaluateDispositions(root, { runId, refDate } = {}) {
100
+ if (!runId) throw new Error('source run id is required');
101
+ const findingsFile = path.join(root, '.citable', 'runs', runId, 'findings.json');
102
+ if (!fs.existsSync(findingsFile)) throw new Error(`source findings not found for run ${runId}`);
103
+ const sourceBytes = fs.readFileSync(findingsFile);
104
+ const sourceFindings = JSON.parse(sourceBytes);
105
+ const findings = new Map(sourceFindings.map((item) => [item.finding_id, item]));
106
+ const { registries, problems } = loadRegistries(root);
107
+ const integrity = checkReferentialIntegrity(registries);
108
+ if (problems.length || integrity.length) throw new Error(`registry validation failed: ${[...problems, ...integrity].join('; ')}`);
109
+ const reviewers = new Map(registries.reviewers.entries.map((item) => [item.reviewer_id, item]));
110
+ const policies = new Map(registries.review_policies.entries.map((item) => [item.policy_id, item]));
111
+ const evidence = new Map(registries.evidence.entries.map((item) => [item.evidence_id, item]));
112
+ const reference = parseRefDate(refDate);
113
+ const applicable = registries.exceptions.entries.filter((item) => item.source_run_id === runId);
114
+ const evaluations = applicable.map((exception) => {
115
+ const exceptionProblemsList = exceptionProblems(exception, policies.get(exception.policy_id), reviewers, findings, evidence, reference);
116
+ return { exception, validity: exceptionProblemsList.length ? 'invalid' : 'active', problems: exceptionProblemsList };
117
+ });
118
+ const dispositions = sourceFindings.map((finding) => {
119
+ const matches = evaluations.filter((item) => item.exception.finding_ids.includes(finding.finding_id));
120
+ const active = matches.filter((item) => item.validity === 'active');
121
+ return {
122
+ finding_id: finding.finding_id,
123
+ detector_id: finding.detector_id,
124
+ subject: finding.subject,
125
+ technical_state: 'failed',
126
+ enforcement_disposition: active.length === 1 ? 'accepted_exception' : active.length > 1 ? 'blocked_ambiguous_exception' : 'enforce',
127
+ exception_validity: active.length === 1 ? 'active' : matches.length ? (active.length > 1 ? 'ambiguous' : 'invalid') : 'not_applicable',
128
+ exception_id: active.length === 1 ? active[0].exception.exception_id : null,
129
+ residual_risk: active.length === 1 ? active[0].exception.residual_risk : 'not_documented',
130
+ problems: matches.flatMap((item) => item.problems),
131
+ };
132
+ });
133
+ const run = createRun(root, { command: 'governance evaluate', argv: [runId], target: { kind: 'registries', location: findingsFile } });
134
+ run.addInput('source-findings', sourceBytes);
135
+ run.addInput('exceptions', registries.exceptions);
136
+ run.addInput('review-policies', registries.review_policies);
137
+ run.writeArtifact('dispositions.json', dispositions);
138
+ run.writeArtifact('exception-evaluations.json', evaluations.map(({ exception, ...evaluation }) => ({ exception_id: exception.exception_id, ...evaluation })));
139
+ run.manifest.warnings.push('Accepted exceptions alter enforcement disposition only; source findings remain failed and immutable.');
140
+ run.finalize(dispositions.some((item) => item.enforcement_disposition === 'blocked_ambiguous_exception') ? 'incomplete' : 'completed_with_warnings');
141
+ return { runId: run.runId, dir: run.dir, source_run_id: runId, dispositions, exception_evaluations: evaluations.length };
142
+ }
143
+
144
+ export { recordHash };
@@ -0,0 +1,73 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { loadRegistries, saveRegistry } from '../registries/index.js';
4
+ import { readJson, readYaml, sha256, nowIso } from '../shared/io.js';
5
+ import { validateAgainst } from '../shared/schemaValidator.js';
6
+
7
+ const INPUTS = ['business_importance','citation_frequency','evidence_age_days','source_authority','regulatory_exposure','intervention_impact','change_magnitude','disagreement_history'];
8
+ const SEVERITY = { critical: 25, high: 20, medium: 12, low: 6, informational: 2, experimental: 1 };
9
+
10
+ export function reviewBindingHash(item) {
11
+ const { decisions, status, adjudication, ...bound } = item;
12
+ return sha256(JSON.stringify(bound));
13
+ }
14
+
15
+ function priority(item, finding) {
16
+ const missing = INPUTS.filter((key) => item.priority_inputs[key] == null);
17
+ const p = item.priority_inputs;
18
+ const score = (SEVERITY[finding?.classification?.severity] || 0) + (p.business_importance || 0) * 4 + Math.min(p.citation_frequency || 0, 10) + Math.min((p.evidence_age_days || 0) / 30, 10) + (5 - (p.source_authority ?? 5)) * 2 + (p.regulatory_exposure || 0) * 5 + (p.intervention_impact || 0) * 3 + (p.change_magnitude || 0) * 2 + Math.min((p.disagreement_history || 0) * 3, 12);
19
+ return { score, tier: missing.length ? 'insufficient_inputs' : score >= 60 ? 'urgent' : score >= 35 ? 'high' : 'normal', missing };
20
+ }
21
+
22
+ export function queueReviews(root, { runId, policyId, write = false }) {
23
+ if (!runId || !policyId) throw new Error('reviews queue requires <run-id> <policy-id>');
24
+ const file = path.join(root,'.citable','runs',runId,'findings.json');
25
+ if (!fs.existsSync(file)) throw new Error(`source findings not found for run ${runId}`);
26
+ const findings = readJson(file);
27
+ const { registries, problems } = loadRegistries(root);
28
+ if (problems.length) throw new Error(`registry validation failed: ${problems.join('; ')}`);
29
+ if (!registries.review_policies.entries.some((p) => p.policy_id === policyId && p.status === 'active')) throw new Error(`active review policy not found: ${policyId}`);
30
+ const existing = new Set(registries.review_items.entries.map((i) => `${i.source_run_id}:${i.finding_id}`));
31
+ const candidates = findings.filter((f) => !f.classification.deterministic || f.remediation.review_required).filter((f) => !existing.has(`${runId}:${f.finding_id}`));
32
+ const created = candidates.map((finding) => {
33
+ const item = { review_item_id:`REVIEW-${sha256(`${runId}:${finding.finding_id}`).slice(0,12).toUpperCase()}`,source_run_id:runId,finding_id:finding.finding_id,finding_hash:sha256(JSON.stringify(finding)),review_type:'general_semantic_review',status:'queued',priority_inputs:Object.fromEntries(INPUTS.map((k)=>[k,null])),priority_score:0,priority_tier:'insufficient_inputs',missing_inputs:[...INPUTS],policy_id:policyId,assigned_reviewer_ids:[],decisions:[],adjudication:null,created_at:nowIso() };
34
+ const ranked = priority(item,finding); item.priority_score=ranked.score; item.priority_tier=ranked.tier; item.missing_inputs=ranked.missing; return item;
35
+ });
36
+ if (write && created.length) saveRegistry(root,'review_items',{...registries.review_items,entries:[...registries.review_items.entries,...created]});
37
+ return { source_run_id:runId, created, written:write };
38
+ }
39
+
40
+ export function prioritizeReviews(root, { write = false } = {}) {
41
+ const { registries, problems } = loadRegistries(root); if (problems.length) throw new Error(`registry validation failed: ${problems.join('; ')}`);
42
+ const cache = new Map();
43
+ const entries = registries.review_items.entries.map((item) => { const file=path.join(root,'.citable','runs',item.source_run_id,'findings.json'); if(!cache.has(file)) cache.set(file,fs.existsSync(file)?new Map(readJson(file).map(f=>[f.finding_id,f])):new Map()); const ranked=priority(item,cache.get(file).get(item.finding_id)); return {...item,priority_score:ranked.score,priority_tier:ranked.tier,missing_inputs:ranked.missing}; });
44
+ if(write) saveRegistry(root,'review_items',{...registries.review_items,entries});
45
+ return { items:entries.sort((a,b)=>b.priority_score-a.priority_score), written:write };
46
+ }
47
+
48
+ export function initializeSamplingPlan(root,{input,write=false}) {
49
+ if(!input || !fs.existsSync(input)) throw new Error('reviews plan requires --input <json|yaml>');
50
+ const plan=path.extname(input).match(/ya?ml/i)?readYaml(input):readJson(input); const {registries}=loadRegistries(root);
51
+ const candidate={...registries.sampling_plans,entries:[...registries.sampling_plans.entries,plan]};
52
+ const check=validateAgainst('sampling-plan.schema.json',candidate); if(!check.valid) throw new Error(`sampling plan violates contract: ${check.errors.join('; ')}`);
53
+ if(write) saveRegistry(root,'sampling_plans',candidate);
54
+ return { plan, written:write };
55
+ }
56
+
57
+ export function selectSample(root,{planId,write=false}) {
58
+ const {registries,problems}=loadRegistries(root); if(problems.length) throw new Error(`registry validation failed: ${problems.join('; ')}`);
59
+ const plan=registries.sampling_plans.entries.find(p=>p.sampling_plan_id===planId); if(!plan) throw new Error(`sampling plan not found: ${planId}`);
60
+ const population=registries.review_items.entries.filter(i=>plan.population_statuses.includes(i.status) && (!plan.review_types.length||plan.review_types.includes(i.review_type))).sort((a,b)=>a.review_item_id.localeCompare(b.review_item_id));
61
+ if(!population.length) throw new Error('sampling population is empty');
62
+ if(plan.method==='simple_random' && plan.sample_size>population.length) throw new Error('sample_size exceeds population');
63
+ const selected=plan.method==='census'?population:[...population].sort((a,b)=>sha256(`${plan.seed}:${a.review_item_id}`).localeCompare(sha256(`${plan.seed}:${b.review_item_id}`))).slice(0,plan.sample_size);
64
+ const updated={...plan,status:'selected',population_hash:sha256(JSON.stringify(population.map(i=>[i.review_item_id,reviewBindingHash(i)]))),selected_item_ids:selected.map(i=>i.review_item_id)};
65
+ if(write) saveRegistry(root,'sampling_plans',{...registries.sampling_plans,entries:registries.sampling_plans.entries.map(p=>p.sampling_plan_id===planId?updated:p)});
66
+ return { plan:updated,population_size:population.length,selected_item_ids:updated.selected_item_ids,written:write };
67
+ }
68
+
69
+ export function evaluateReviews(root) {
70
+ const {registries,problems}=loadRegistries(root); const reviewers=new Map(registries.reviewers.entries.map(r=>[r.reviewer_id,r])); const results=[];
71
+ for(const item of registries.review_items.entries){const issues=[];const binding=reviewBindingHash(item);const source=path.join(root,'.citable','runs',item.source_run_id,'findings.json');const finding=fs.existsSync(source)?readJson(source).find(f=>f.finding_id===item.finding_id):null;if(!finding||sha256(JSON.stringify(finding))!==item.finding_hash)issues.push('source finding is unavailable or changed');for(const d of item.decisions){const r=reviewers.get(d.reviewer_id);const reviewRole=r?.roles.some(role=>['technical_reviewer','subject_matter_reviewer','independent_reviewer'].includes(role));if(!r||r.status!=='active'||!reviewRole||!item.assigned_reviewer_ids.includes(d.reviewer_id))issues.push(`${d.reviewer_id} is not an active assigned semantic reviewer`);if(d.review_item_hash!==binding)issues.push(`${d.reviewer_id} decision is stale`);}const verdicts=[...new Set(item.decisions.map(d=>d.verdict))];let state=item.decisions.length?'completed':'review_required';if(verdicts.length>1){state='adjudication_required';const a=reviewers.get(item.adjudication?.reviewer_id);if(item.adjudication&&a?.status==='active'&&a.roles.includes('independent_reviewer')&&item.adjudication.review_item_hash===binding)state='completed';else issues.push('reviewer disagreement requires a current decision from an active independent adjudicator');}results.push({review_item_id:item.review_item_id,state,verdict:state==='completed'&&!issues.length?(item.adjudication?.verdict||verdicts[0]):null,issues});}
72
+ return {ok:problems.length===0&&results.every(r=>!r.issues.length),problems,results};
73
+ }
@@ -21,7 +21,7 @@ const FETCH_TIMEOUT_MS = 10_000;
21
21
 
22
22
  /**
23
23
  * Fetch the latest published version from the npm registry.
24
- * Uses Node's built-in fetch (Node 22+); no extra dependencies.
24
+ * Uses Node's built-in fetch (Node 24+); no extra dependencies.
25
25
  *
26
26
  * @returns {Promise<string>} latest semver string
27
27
  */