@nebulacomponents/citable 1.7.0 → 1.8.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 (123) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +9 -3
  3. package/dist/universal/.agents/skills/citable/SKILL.md +9 -3
  4. package/dist/universal/.agents/skills/citable/VERSION +1 -1
  5. package/dist/universal/.agents/skills/citable/commands/README.md +1 -0
  6. package/dist/universal/.agents/skills/citable/commands/governance.md +17 -0
  7. package/dist/universal/.agents/skills/citable/manifest.json +11 -7
  8. package/dist/universal/.agents/skills/citable/references/capability-boundaries.md +5 -0
  9. package/dist/universal/.agents/skills/citable/schemas/exception.schema.json +70 -0
  10. package/dist/universal/.agents/skills/citable/schemas/review-policy.schema.json +35 -0
  11. package/dist/universal/.agents/skills/citable/schemas/reviewer.schema.json +32 -0
  12. package/dist/universal/.claude/skills/citable/SKILL.md +9 -3
  13. package/dist/universal/.claude/skills/citable/VERSION +1 -1
  14. package/dist/universal/.claude/skills/citable/commands/README.md +1 -0
  15. package/dist/universal/.claude/skills/citable/commands/governance.md +17 -0
  16. package/dist/universal/.claude/skills/citable/manifest.json +11 -7
  17. package/dist/universal/.claude/skills/citable/references/capability-boundaries.md +5 -0
  18. package/dist/universal/.claude/skills/citable/schemas/exception.schema.json +70 -0
  19. package/dist/universal/.claude/skills/citable/schemas/review-policy.schema.json +35 -0
  20. package/dist/universal/.claude/skills/citable/schemas/reviewer.schema.json +32 -0
  21. package/dist/universal/.cursor/skills/citable/SKILL.md +9 -3
  22. package/dist/universal/.cursor/skills/citable/VERSION +1 -1
  23. package/dist/universal/.cursor/skills/citable/commands/README.md +1 -0
  24. package/dist/universal/.cursor/skills/citable/commands/governance.md +17 -0
  25. package/dist/universal/.cursor/skills/citable/manifest.json +11 -7
  26. package/dist/universal/.cursor/skills/citable/references/capability-boundaries.md +5 -0
  27. package/dist/universal/.cursor/skills/citable/schemas/exception.schema.json +70 -0
  28. package/dist/universal/.cursor/skills/citable/schemas/review-policy.schema.json +35 -0
  29. package/dist/universal/.cursor/skills/citable/schemas/reviewer.schema.json +32 -0
  30. package/dist/universal/.gemini/skills/citable/SKILL.md +9 -3
  31. package/dist/universal/.gemini/skills/citable/VERSION +1 -1
  32. package/dist/universal/.gemini/skills/citable/commands/README.md +1 -0
  33. package/dist/universal/.gemini/skills/citable/commands/governance.md +17 -0
  34. package/dist/universal/.gemini/skills/citable/manifest.json +11 -7
  35. package/dist/universal/.gemini/skills/citable/references/capability-boundaries.md +5 -0
  36. package/dist/universal/.gemini/skills/citable/schemas/exception.schema.json +70 -0
  37. package/dist/universal/.gemini/skills/citable/schemas/review-policy.schema.json +35 -0
  38. package/dist/universal/.gemini/skills/citable/schemas/reviewer.schema.json +32 -0
  39. package/dist/universal/.github/skills/citable/SKILL.md +9 -3
  40. package/dist/universal/.github/skills/citable/VERSION +1 -1
  41. package/dist/universal/.github/skills/citable/commands/README.md +1 -0
  42. package/dist/universal/.github/skills/citable/commands/governance.md +17 -0
  43. package/dist/universal/.github/skills/citable/manifest.json +11 -7
  44. package/dist/universal/.github/skills/citable/references/capability-boundaries.md +5 -0
  45. package/dist/universal/.github/skills/citable/schemas/exception.schema.json +70 -0
  46. package/dist/universal/.github/skills/citable/schemas/review-policy.schema.json +35 -0
  47. package/dist/universal/.github/skills/citable/schemas/reviewer.schema.json +32 -0
  48. package/dist/universal/.kiro/skills/citable/SKILL.md +9 -3
  49. package/dist/universal/.kiro/skills/citable/VERSION +1 -1
  50. package/dist/universal/.kiro/skills/citable/commands/README.md +1 -0
  51. package/dist/universal/.kiro/skills/citable/commands/governance.md +17 -0
  52. package/dist/universal/.kiro/skills/citable/manifest.json +11 -7
  53. package/dist/universal/.kiro/skills/citable/references/capability-boundaries.md +5 -0
  54. package/dist/universal/.kiro/skills/citable/schemas/exception.schema.json +70 -0
  55. package/dist/universal/.kiro/skills/citable/schemas/review-policy.schema.json +35 -0
  56. package/dist/universal/.kiro/skills/citable/schemas/reviewer.schema.json +32 -0
  57. package/dist/universal/.opencode/skills/citable/SKILL.md +9 -3
  58. package/dist/universal/.opencode/skills/citable/VERSION +1 -1
  59. package/dist/universal/.opencode/skills/citable/commands/README.md +1 -0
  60. package/dist/universal/.opencode/skills/citable/commands/governance.md +17 -0
  61. package/dist/universal/.opencode/skills/citable/manifest.json +11 -7
  62. package/dist/universal/.opencode/skills/citable/references/capability-boundaries.md +5 -0
  63. package/dist/universal/.opencode/skills/citable/schemas/exception.schema.json +70 -0
  64. package/dist/universal/.opencode/skills/citable/schemas/review-policy.schema.json +35 -0
  65. package/dist/universal/.opencode/skills/citable/schemas/reviewer.schema.json +32 -0
  66. package/dist/universal/.pi/agent/skills/citable/SKILL.md +9 -3
  67. package/dist/universal/.pi/agent/skills/citable/VERSION +1 -1
  68. package/dist/universal/.pi/agent/skills/citable/commands/README.md +1 -0
  69. package/dist/universal/.pi/agent/skills/citable/commands/governance.md +17 -0
  70. package/dist/universal/.pi/agent/skills/citable/manifest.json +11 -7
  71. package/dist/universal/.pi/agent/skills/citable/references/capability-boundaries.md +5 -0
  72. package/dist/universal/.pi/agent/skills/citable/schemas/exception.schema.json +70 -0
  73. package/dist/universal/.pi/agent/skills/citable/schemas/review-policy.schema.json +35 -0
  74. package/dist/universal/.pi/agent/skills/citable/schemas/reviewer.schema.json +32 -0
  75. package/dist/universal/.qoder/skills/citable/SKILL.md +9 -3
  76. package/dist/universal/.qoder/skills/citable/VERSION +1 -1
  77. package/dist/universal/.qoder/skills/citable/commands/README.md +1 -0
  78. package/dist/universal/.qoder/skills/citable/commands/governance.md +17 -0
  79. package/dist/universal/.qoder/skills/citable/manifest.json +11 -7
  80. package/dist/universal/.qoder/skills/citable/references/capability-boundaries.md +5 -0
  81. package/dist/universal/.qoder/skills/citable/schemas/exception.schema.json +70 -0
  82. package/dist/universal/.qoder/skills/citable/schemas/review-policy.schema.json +35 -0
  83. package/dist/universal/.qoder/skills/citable/schemas/reviewer.schema.json +32 -0
  84. package/dist/universal/.rovodev/skills/citable/SKILL.md +9 -3
  85. package/dist/universal/.rovodev/skills/citable/VERSION +1 -1
  86. package/dist/universal/.rovodev/skills/citable/commands/README.md +1 -0
  87. package/dist/universal/.rovodev/skills/citable/commands/governance.md +17 -0
  88. package/dist/universal/.rovodev/skills/citable/manifest.json +11 -7
  89. package/dist/universal/.rovodev/skills/citable/references/capability-boundaries.md +5 -0
  90. package/dist/universal/.rovodev/skills/citable/schemas/exception.schema.json +70 -0
  91. package/dist/universal/.rovodev/skills/citable/schemas/review-policy.schema.json +35 -0
  92. package/dist/universal/.rovodev/skills/citable/schemas/reviewer.schema.json +32 -0
  93. package/dist/universal/.trae/skills/citable/SKILL.md +9 -3
  94. package/dist/universal/.trae/skills/citable/VERSION +1 -1
  95. package/dist/universal/.trae/skills/citable/commands/README.md +1 -0
  96. package/dist/universal/.trae/skills/citable/commands/governance.md +17 -0
  97. package/dist/universal/.trae/skills/citable/manifest.json +11 -7
  98. package/dist/universal/.trae/skills/citable/references/capability-boundaries.md +5 -0
  99. package/dist/universal/.trae/skills/citable/schemas/exception.schema.json +70 -0
  100. package/dist/universal/.trae/skills/citable/schemas/review-policy.schema.json +35 -0
  101. package/dist/universal/.trae/skills/citable/schemas/reviewer.schema.json +32 -0
  102. package/dist/universal/.trae-cn/skills/citable/SKILL.md +9 -3
  103. package/dist/universal/.trae-cn/skills/citable/VERSION +1 -1
  104. package/dist/universal/.trae-cn/skills/citable/commands/README.md +1 -0
  105. package/dist/universal/.trae-cn/skills/citable/commands/governance.md +17 -0
  106. package/dist/universal/.trae-cn/skills/citable/manifest.json +11 -7
  107. package/dist/universal/.trae-cn/skills/citable/references/capability-boundaries.md +5 -0
  108. package/dist/universal/.trae-cn/skills/citable/schemas/exception.schema.json +70 -0
  109. package/dist/universal/.trae-cn/skills/citable/schemas/review-policy.schema.json +35 -0
  110. package/dist/universal/.trae-cn/skills/citable/schemas/reviewer.schema.json +32 -0
  111. package/dist/universal/manifest.json +135 -87
  112. package/package.json +2 -2
  113. package/schemas/exception.schema.json +70 -0
  114. package/schemas/review-policy.schema.json +35 -0
  115. package/schemas/reviewer.schema.json +32 -0
  116. package/skill/SKILL.md +9 -3
  117. package/skill/commands/README.md +1 -0
  118. package/skill/commands/governance.md +17 -0
  119. package/skill/references/capability-boundaries.md +5 -0
  120. package/src/cli/index.js +17 -0
  121. package/src/commands/governance.js +144 -0
  122. package/src/commands/selfUpgrade.js +1 -1
  123. package/src/registries/index.js +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulacomponents/citable",
3
- "version": "1.7.0",
3
+ "version": "1.8.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,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
+ }
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.8.0
11
11
  ---
12
12
 
13
13
  # Citable — evidence and change control for search and AI citation readiness
@@ -108,6 +108,8 @@ 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]
111
113
  ```
112
114
 
113
115
  Audit scopes: `technical seo aeo geo architecture entity claims evidence schema
@@ -165,8 +167,9 @@ mandatory.
165
167
  ## Registries are the source of truth
166
168
 
167
169
  `.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
170
+ evidence, pages, crawlers, competitors, experiments, metrics, objectives,
171
+ interventions, optional connection state, reviewers, review policies, and
172
+ governed exceptions, all schema-validated
170
173
  (`schemas/*.schema.json`) with referential integrity checks. Rules:
171
174
 
172
175
  - Never overwrite registry content without history — use the loader/saver in
@@ -175,6 +178,9 @@ interventions, and optional connection state, all schema-validated
175
178
  competitors, pricing). Mark entities `incomplete` and list `required_input`.
176
179
  - Claim status transitions toward `verified` require existing verified evidence
177
180
  plus human semantic review; automation only downgrades (fail-closed).
181
+ - Never encode an accepted exception as a passed or resolved finding. Validate
182
+ reviewer authority and separation of duties, bind approval to exact source
183
+ finding/policy/evidence hashes, and report enforcement disposition separately.
178
184
 
179
185
  ## Fail-closed behaviour
180
186
 
@@ -27,6 +27,7 @@ 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 |
30
31
  | /citable ingest, map-site, map-queries, map-prompts, map-entities, map-evidence | specified (ingest.md) |
31
32
  | /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
33
  | /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.
@@ -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,7 @@ 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';
20
21
 
21
22
  const HELP = `citable — SEO / AEO / GEO audit, remediation, validation, and governance
22
23
 
@@ -53,6 +54,8 @@ Commands
53
54
  objectives init Validate/add one objective from --input (--write to save)
54
55
  objectives validate Validate objective contracts and metric references
55
56
  evaluate [objective-id] Compare objective baseline and evaluation windows
57
+ governance validate Validate reviewer, policy, and exception controls
58
+ governance evaluate [run] Produce immutable enforcement dispositions without changing findings
56
59
  self-upgrade Check for a newer version and upgrade the npx cache
57
60
 
58
61
  Options
@@ -238,6 +241,20 @@ export async function main(argv = process.argv.slice(2), options = {}) {
238
241
  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
242
  break;
240
243
  }
244
+ case 'governance': {
245
+ const mode = args._[0];
246
+ if (mode === 'validate') {
247
+ const r = validateGovernance(root, { refDate: args.refDate });
248
+ 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);
249
+ if (!r.ok) process.exitCode = 1;
250
+ } else if (mode === 'evaluate') {
251
+ const r = evaluateDispositions(root, { runId: args._[1], refDate: args.refDate });
252
+ const accepted = r.dispositions.filter((item) => item.enforcement_disposition === 'accepted_exception').length;
253
+ out(args, `governance evaluate ${r.source_run_id}: ${r.dispositions.length} failed finding(s), ${accepted} accepted exception(s)\nEvidence package: ${r.dir}`, r);
254
+ if (r.dispositions.some((item) => item.enforcement_disposition === 'blocked_ambiguous_exception')) process.exitCode = 1;
255
+ } else throw new Error('usage: citable governance <validate|evaluate [run-id]> [--ref-date YYYY-MM-DD]');
256
+ break;
257
+ }
241
258
  case 'self-upgrade': {
242
259
  const output = await selfUpgradeCommand(argv.slice(1));
243
260
  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 };
@@ -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
  */
@@ -17,6 +17,9 @@ export const REGISTRY_SPECS = [
17
17
  { file: 'objectives.yaml', kind: 'objectives', schema: 'objective.schema.json', idField: 'objective_id' },
18
18
  { file: 'interventions.yaml', kind: 'interventions', schema: 'intervention.schema.json', idField: 'intervention_id' },
19
19
  { file: 'connections.yaml', kind: 'connections', schema: 'connection.schema.json', idField: 'connection_id' },
20
+ { file: 'reviewers.yaml', kind: 'reviewers', schema: 'reviewer.schema.json', idField: 'reviewer_id' },
21
+ { file: 'review-policies.yaml', kind: 'review_policies', schema: 'review-policy.schema.json', idField: 'policy_id' },
22
+ { file: 'exceptions.yaml', kind: 'exceptions', schema: 'exception.schema.json', idField: 'exception_id' },
20
23
  ];
21
24
 
22
25
  export function contextDir(root) {
@@ -104,6 +107,20 @@ export function checkReferentialIntegrity(registries) {
104
107
  for (const intervention of registries.interventions?.entries || []) {
105
108
  for (const ref of intervention.objective_ids || []) if (!objectiveIds.has(ref)) problems.push(`interventions/${intervention.intervention_id}: references unknown objective id "${ref}"`);
106
109
  }
110
+ const reviewerIds = ids.reviewers || new Set();
111
+ const policyIds = ids.review_policies || new Set();
112
+ const evidenceIds = ids.evidence || new Set();
113
+ const interventionIds = ids.interventions || new Set();
114
+ const exceptionIds = ids.exceptions || new Set();
115
+ for (const exception of registries.exceptions?.entries || []) {
116
+ const prefix = `exceptions/${exception.exception_id}`;
117
+ if (!policyIds.has(exception.policy_id)) problems.push(`${prefix}: references unknown review policy id "${exception.policy_id}"`);
118
+ const reviewerRefs = [exception.owner_reviewer_id, ...(exception.reviewer_assignments || []).map((item) => item.reviewer_id), ...(exception.audit_history || []).map((item) => item.actor_reviewer_id)];
119
+ for (const ref of reviewerRefs) if (ref && !reviewerIds.has(ref)) problems.push(`${prefix}: references unknown reviewer id "${ref}"`);
120
+ for (const ref of exception.evidence_ids || []) if (!evidenceIds.has(ref)) problems.push(`${prefix}: references unknown evidence id "${ref}"`);
121
+ if (exception.related_intervention_id && !interventionIds.has(exception.related_intervention_id)) problems.push(`${prefix}: references unknown intervention id "${exception.related_intervention_id}"`);
122
+ for (const ref of [exception.supersedes_exception_id, exception.superseded_by_exception_id]) if (ref && !exceptionIds.has(ref)) problems.push(`${prefix}: references unknown exception id "${ref}"`);
123
+ }
107
124
  return problems;
108
125
  }
109
126