@ixo/domain.md 0.3.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 (70) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +6 -0
  3. package/README.md +30 -0
  4. package/assets/domain-md.schema.json +1103 -0
  5. package/assets/oracle-capsule-jcs-vectors.json +57 -0
  6. package/assets/oracle-capsule-manifest-contract.md +72 -0
  7. package/assets/oracle-capsule-source-lock.schema.json +45 -0
  8. package/assets/oracle-capsule.schema.json +265 -0
  9. package/assets/rules.json +275 -0
  10. package/assets/spec.md +1434 -0
  11. package/assets/template-manifest.schema.json +57 -0
  12. package/dist/capsule/index.d.ts +75 -0
  13. package/dist/capsule/index.js +20 -0
  14. package/dist/capsule/index.js.map +1 -0
  15. package/dist/chunk-BYBC2TSS.js +597 -0
  16. package/dist/chunk-BYBC2TSS.js.map +1 -0
  17. package/dist/chunk-G7PZJYAJ.js +31826 -0
  18. package/dist/chunk-G7PZJYAJ.js.map +1 -0
  19. package/dist/chunk-R6QZRNEX.js +164 -0
  20. package/dist/chunk-R6QZRNEX.js.map +1 -0
  21. package/dist/chunk-T3STBWXP.js +46 -0
  22. package/dist/chunk-T3STBWXP.js.map +1 -0
  23. package/dist/chunk-W7MRQP7I.js +862 -0
  24. package/dist/chunk-W7MRQP7I.js.map +1 -0
  25. package/dist/chunk-XDIWMZVF.js +1150 -0
  26. package/dist/chunk-XDIWMZVF.js.map +1 -0
  27. package/dist/cli-KcUIQEiE.d.ts +171 -0
  28. package/dist/cli.d.ts +2 -0
  29. package/dist/cli.js +400 -0
  30. package/dist/cli.js.map +1 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.js +83 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/resolver-B3mwnjJq.d.ts +96 -0
  35. package/dist/spec.d.ts +20 -0
  36. package/dist/spec.js +23 -0
  37. package/dist/spec.js.map +1 -0
  38. package/dist/templates/index.d.ts +7 -0
  39. package/dist/templates/index.js +24 -0
  40. package/dist/templates/index.js.map +1 -0
  41. package/dist/workers-Dr8B8a2O.d.ts +19 -0
  42. package/dist/workers.d.ts +3 -0
  43. package/dist/workers.js +31 -0
  44. package/dist/workers.js.map +1 -0
  45. package/package.json +97 -0
  46. package/src/capsule/canonical.ts +74 -0
  47. package/src/capsule/index.ts +10 -0
  48. package/src/capsule/json.ts +373 -0
  49. package/src/capsule/types.ts +63 -0
  50. package/src/capsule/validate.ts +551 -0
  51. package/src/cli.ts +405 -0
  52. package/src/compiled-validators.d.ts +7 -0
  53. package/src/compiled-validators.js +32512 -0
  54. package/src/constants.ts +250 -0
  55. package/src/diff.ts +111 -0
  56. package/src/export.ts +28 -0
  57. package/src/index.ts +36 -0
  58. package/src/lint.ts +42 -0
  59. package/src/parser.ts +174 -0
  60. package/src/sarif.ts +49 -0
  61. package/src/semantic.ts +1156 -0
  62. package/src/spec.ts +48 -0
  63. package/src/templates/errors.ts +3 -0
  64. package/src/templates/index.ts +11 -0
  65. package/src/templates/manifest.ts +94 -0
  66. package/src/templates/render.ts +435 -0
  67. package/src/templates/resolver.ts +200 -0
  68. package/src/templates/types.ts +98 -0
  69. package/src/types.ts +195 -0
  70. package/src/workers.ts +6 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/parser.ts","../src/semantic.ts","../src/lint.ts"],"sourcesContent":["import type { Heading, Root, YAML as MdastYaml } from 'mdast';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport remarkParse from 'remark-parse';\nimport { unified } from 'unified';\nimport { visit as visitTree } from 'unist-util-visit';\nimport { isAlias, parseDocument, visit as visitYaml } from 'yaml';\n\nimport {\n MAX_DOMAIN_BYTES,\n MAX_SCALAR_LENGTH,\n MAX_YAML_DEPTH,\n MAX_YAML_NODES,\n} from './constants.js';\nimport type { DomainRecord, DomainSection, Finding, ParseOptions, ParseResult } from './types.js';\n\nconst FRONTMATTER = /^---[ \\t]*\\r?\\n([\\s\\S]*?)\\r?\\n---[ \\t]*(?:\\r?\\n|$)/;\n\nfunction finding(code: string, message: string, path = '/'): Finding {\n return { severity: 'error', code, message, path, location: { line: 1, column: 1 } };\n}\n\nfunction isRecord(value: unknown): value is DomainRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction nodeText(value: unknown): string {\n if (!isRecord(value)) return '';\n if (typeof value.value === 'string') return value.value;\n return Array.isArray(value.children) ? value.children.map(nodeText).join('') : '';\n}\n\nfunction parseFrontmatter(source: string, findings: Finding[]): DomainRecord | undefined {\n const match = FRONTMATTER.exec(source);\n if (!match?.[1]) {\n findings.push(\n finding(\n 'missing-frontmatter',\n 'A domain.md must begin with YAML frontmatter.',\n '/frontmatter',\n ),\n );\n return undefined;\n }\n const yaml = parseDocument(match[1], { prettyErrors: true, uniqueKeys: true, version: '1.2' });\n if (yaml.errors.length > 0 || yaml.warnings.length > 0) {\n findings.push(\n finding(\n 'unsafe-yaml',\n [...yaml.errors, ...yaml.warnings].map((item) => item.message).join('; '),\n '/frontmatter',\n ),\n );\n return undefined;\n }\n const unsafe = new Set<string>();\n let nodes = 0;\n let depth = 0;\n let scalarTooLong = false;\n visitYaml(yaml, {\n Node(_key, node, path) {\n const candidate = node as { anchor?: string; tag?: string; value?: unknown };\n nodes += 1;\n depth = Math.max(depth, path.length + 1);\n if (typeof candidate.value === 'string' && candidate.value.length > MAX_SCALAR_LENGTH)\n scalarTooLong = true;\n if (isAlias(node)) unsafe.add('alias');\n if (candidate.anchor) unsafe.add('anchor');\n if (candidate.tag?.startsWith('!')) unsafe.add('custom-tag');\n },\n Pair(_key, pair) {\n const key = pair.key as { value?: unknown } | null;\n if (key?.value === '<<') unsafe.add('merge-key');\n },\n });\n if (nodes > MAX_YAML_NODES || depth > MAX_YAML_DEPTH || scalarTooLong) {\n findings.push(\n finding('unsafe-yaml', 'YAML exceeds the node, depth, or scalar limits.', '/frontmatter'),\n );\n return undefined;\n }\n if (unsafe.size > 0) {\n findings.push(\n finding(\n 'unsafe-yaml',\n `Forbidden YAML feature(s): ${[...unsafe].sort().join(', ')}.`,\n '/frontmatter',\n ),\n );\n return undefined;\n }\n let value: unknown;\n try {\n value = yaml.toJS({ maxAliasCount: 0 });\n } catch (error) {\n findings.push(\n finding(\n 'unsafe-yaml',\n error instanceof Error ? error.message : String(error),\n '/frontmatter',\n ),\n );\n return undefined;\n }\n if (!isRecord(value)) {\n findings.push(\n finding('frontmatter-shape', 'YAML frontmatter must be a mapping.', '/frontmatter'),\n );\n return undefined;\n }\n return value;\n}\n\nfunction extractSections(tree: Root, source: string): DomainSection[] {\n const headings: Heading[] = [];\n visitTree(tree, 'heading', (node: Heading) => {\n if (node.depth === 2) headings.push(node);\n });\n return headings.map((heading, index) => {\n const next = headings[index + 1];\n const start = heading.position?.start.offset ?? 0;\n const end = next?.position?.start.offset ?? source.length;\n const title = nodeText(heading);\n return {\n heading: title,\n content: source.slice(start, end).trimEnd(),\n location: {\n line: heading.position?.start.line ?? 1,\n column: heading.position?.start.column ?? 1,\n ...(heading.position?.end.line === undefined ? {} : { endLine: heading.position.end.line }),\n ...(heading.position?.end.column === undefined\n ? {}\n : { endColumn: heading.position.end.column }),\n },\n };\n });\n}\n\nexport function parseDomain(content: string, options: ParseOptions = {}): ParseResult {\n const sourceName = options.sourceName ?? '<memory>';\n const findings: Finding[] = [];\n const maxBytes = options.maxBytes ?? MAX_DOMAIN_BYTES;\n if (Buffer.byteLength(content, 'utf8') > maxBytes) {\n return { ok: false, findings: [finding('file-too-large', `Input exceeds ${maxBytes} bytes.`)] };\n }\n if (content.charCodeAt(0) === 0xfeff) {\n findings.push(finding('encoding', 'UTF-8 byte-order marks are forbidden.'));\n }\n const frontmatter = parseFrontmatter(content, findings);\n if (!frontmatter) return { ok: false, findings };\n\n const tree = unified().use(remarkParse).use(remarkFrontmatter, ['yaml']).parse(content);\n const yamlNodes: MdastYaml[] = [];\n visitTree(tree, 'yaml', (node: MdastYaml) => yamlNodes.push(node));\n const frontmatterLength = FRONTMATTER.exec(content)?.[0].length ?? 0;\n const additionalFence = /(?:^|\\r?\\n)---[ \\t]*\\r?\\n[\\s\\S]*?\\r?\\n---[ \\t]*(?:\\r?\\n|$)/.test(\n content.slice(frontmatterLength),\n );\n if (yamlNodes.length !== 1 || tree.children[0]?.type !== 'yaml' || additionalFence) {\n findings.push(\n finding(\n 'frontmatter-fence',\n 'Exactly one YAML frontmatter block must appear at the start.',\n '/frontmatter',\n ),\n );\n }\n const document = {\n frontmatter,\n sections: extractSections(tree, content),\n sourceName,\n raw: content,\n };\n return { ok: findings.every((item) => item.severity !== 'error'), document, findings };\n}\n","import { CANONICAL_SECTIONS, KNOWN_TOP_LEVEL_KEYS } from './constants.js';\nimport validators from './compiled-validators.js';\nimport type {\n ConformanceProfile,\n DomainDocument,\n DomainMode,\n DomainRecord,\n Finding,\n} from './types.js';\n\nconst AUTHOR_PLACEHOLDER = /\\{\\{[^{}\\n]+\\}\\}/;\nconst PUBLISH_PLACEHOLDER = /<<FILL_AT_PUBLISH:[A-Za-z0-9_.-]+>>/;\nconst validateSchema = validators.domain;\n\nfunction isRecord(value: unknown): value is DomainRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction records(value: unknown, key: string): DomainRecord[] {\n return isRecord(value) && Array.isArray(value[key]) ? value[key].filter(isRecord) : [];\n}\n\nfunction add(\n findings: Finding[],\n severity: Finding['severity'],\n code: string,\n message: string,\n path?: string,\n): void {\n findings.push({\n severity,\n code,\n message,\n path: path && path.length > 0 ? path : '/',\n location: { line: 1, column: 1 },\n });\n}\n\nfunction locate(document: DomainDocument, finding: Finding): Finding {\n const section = document.sections.find((candidate) => candidate.heading === finding.path);\n if (section) return { ...finding, location: section.location };\n const segment = finding.path.split('/').filter(Boolean).at(-1);\n if (!segment) return finding;\n const key = segment.replace(/~1/g, '/').replace(/~0/g, '~');\n const escaped = key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const lines = document.raw.split(/\\r?\\n/);\n const line = lines.findIndex((value) => new RegExp(`^\\\\s*(?:-\\\\s*)?${escaped}:`).test(value));\n if (line < 0) return finding;\n const column = (lines[line]?.search(/\\S/) ?? 0) + 1;\n return { ...finding, location: { line: line + 1, column } };\n}\n\nfunction uniqueIds(entries: DomainRecord[], label: string, findings: Finding[]): Set<string> {\n const result = new Set<string>();\n for (const entry of entries) {\n if (typeof entry.id !== 'string') continue;\n const id = entry.id.normalize('NFC');\n if (result.has(id))\n add(findings, 'error', 'duplicate-entry-id', `Duplicate ${label} id ${JSON.stringify(id)}.`);\n result.add(id);\n }\n return result;\n}\n\nfunction externalReference(value: string): boolean {\n return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value) || value.startsWith('baf');\n}\n\nfunction inspectSecrets(value: unknown, findings: Finding[], path = ''): void {\n if (Array.isArray(value)) {\n value.forEach((child, index) => inspectSecrets(child, findings, `${path}/${index}`));\n return;\n }\n if (!isRecord(value)) {\n if (\n typeof value === 'string' &&\n /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/.test(value)\n ) {\n add(findings, 'error', 'secret-in-index', 'Private key material is forbidden.', path);\n }\n if (\n typeof value === 'string' &&\n (/:\\/\\/[^\\s/@:]+:[^\\s/@]+@/.test(value) ||\n /[?&](?:access_token|api_key|bearer_token|secret|signature)=[^&#\\s]+/i.test(value))\n ) {\n add(\n findings,\n 'error',\n 'secret-in-index',\n 'Credential-bearing URI content is forbidden.',\n path,\n );\n }\n return;\n }\n for (const [key, child] of Object.entries(value)) {\n const childPath = `${path}/${key.replace(/~/g, '~0').replace(/\\//g, '~1')}`;\n if (\n /(^|_)(secret|private_key|seed_phrase|mnemonic|access_token|api_key|bearer_token)($|_)/i.test(\n key,\n )\n ) {\n add(\n findings,\n 'error',\n 'secret-in-index',\n `Secret-bearing key ${JSON.stringify(key)} is forbidden.`,\n childPath,\n );\n }\n inspectSecrets(child, findings, childPath);\n }\n}\n\nfunction validateSections(document: DomainDocument, findings: Finding[]): void {\n const seen = new Set<string>();\n let previous = -1;\n for (const section of document.sections) {\n if (seen.has(section.heading) && CANONICAL_SECTIONS.includes(section.heading as never)) {\n add(\n findings,\n 'error',\n 'duplicate-section',\n `Duplicate section ${JSON.stringify(section.heading)}.`,\n section.heading,\n );\n }\n seen.add(section.heading);\n const index = CANONICAL_SECTIONS.indexOf(section.heading as never);\n if (index < 0)\n add(\n findings,\n 'info',\n 'unknown-section',\n `Unknown section ${JSON.stringify(section.heading)} is preserved.`,\n section.heading,\n );\n else if (index < previous)\n add(\n findings,\n 'warning',\n 'section-order',\n `Section ${JSON.stringify(section.heading)} is out of canonical order.`,\n section.heading,\n );\n else previous = index;\n }\n const validation = document.frontmatter.validation;\n const required =\n isRecord(validation) && Array.isArray(validation.required_sections)\n ? validation.required_sections.filter((item): item is string => typeof item === 'string')\n : [];\n for (const section of required) {\n if (!seen.has(section))\n add(\n findings,\n 'error',\n 'missing-required-section',\n `Missing required section ${JSON.stringify(section)}.`,\n section,\n );\n }\n}\n\nfunction documentEntries(value: unknown): DomainRecord[] {\n if (Array.isArray(value)) return value.filter(isRecord);\n return records(value, 'entries');\n}\n\nfunction validateDocuments(frontmatter: DomainRecord, findings: Finding[]): Set<string> {\n const entries = documentEntries(frontmatter.documents);\n const ids = uniqueIds(entries, 'document', findings);\n const roles = entries\n .map((entry) => entry.role)\n .filter((role): role is string => typeof role === 'string');\n for (const required of ['description', 'changelog']) {\n if (!roles.includes(required))\n add(\n findings,\n 'error',\n 'document-contract',\n `Missing universal document role ${required}.`,\n '/documents/entries',\n );\n }\n const duplicates = roles.filter((role, index) => roles.indexOf(role) !== index);\n for (const role of new Set(duplicates))\n add(\n findings,\n 'error',\n 'document-contract',\n `Duplicate document role ${role}.`,\n '/documents/entries',\n );\n for (const entry of entries) {\n if (\n entry.role === 'manifest' &&\n (entry.category !== 'manifest' ||\n entry.authority !== 'defining' ||\n entry.disclosure_pass !== 3)\n ) {\n add(\n findings,\n 'error',\n 'document-contract',\n 'Manifest documents must be defining category manifest at disclosure pass 3.',\n '/documents/entries',\n );\n }\n if (entry.sensitivity !== 'public' && entry.access_policy === 'public') {\n add(\n findings,\n 'error',\n 'document-contract',\n `Sensitive document role ${String(entry.role)} cannot be public.`,\n '/documents/entries',\n );\n }\n }\n return ids;\n}\n\nfunction validateAuthority(\n frontmatter: DomainRecord,\n findings: Finding[],\n): {\n controllers: Set<string>;\n rights: Set<string>;\n resources: Set<string>;\n services: Set<string>;\n agents: Set<string>;\n agentControllers: Set<string>;\n linkedEntities: Set<string>;\n claims: Set<string>;\n wallets: Set<string>;\n} {\n const controllerEntries = records(frontmatter.controllers, 'entries');\n const controllerIds = uniqueIds(controllerEntries, 'controller', findings);\n const summary =\n isRecord(frontmatter.controllers) && isRecord(frontmatter.controllers.summary)\n ? frontmatter.controllers.summary\n : undefined;\n if (\n typeof summary?.primary_controller === 'string' &&\n !controllerIds.has(summary.primary_controller)\n ) {\n add(\n findings,\n 'error',\n 'broken-local-reference',\n 'Primary controller does not resolve.',\n '/controllers/summary/primary_controller',\n );\n }\n const rightEntries = records(frontmatter.rights, 'entries');\n const rights = uniqueIds(rightEntries, 'right', findings);\n const resources = uniqueIds(records(frontmatter.resources, 'entries'), 'resource', findings);\n const services = uniqueIds(records(frontmatter.services, 'entries'), 'service', findings);\n const linkedEntities = uniqueIds(\n records(frontmatter.linked_entities, 'entries'),\n 'linked entity',\n findings,\n );\n const claimCollections = records(frontmatter.claims, 'collections');\n const claims = new Set(\n [\n ...claimCollections,\n ...claimCollections.flatMap((collection) => records(collection, 'claim_types')),\n ...records(frontmatter.claims, 'linked_claims'),\n ]\n .map((entry) => entry.id)\n .filter((id): id is string => typeof id === 'string'),\n );\n const wallets = new Set(\n records(frontmatter.accounts, 'entries').flatMap((entry) =>\n [entry.name, entry.address].filter((value): value is string => typeof value === 'string'),\n ),\n );\n uniqueIds(records(frontmatter.pods, 'entries'), 'POD', findings);\n const agents = uniqueIds(records(frontmatter.agents, 'entries'), 'agent', findings);\n const agentControllers = new Set(\n controllerEntries\n .filter((entry) => entry.type === 'agent')\n .map((entry) => entry.id)\n .filter((id): id is string => typeof id === 'string'),\n );\n\n if (isRecord(frontmatter.source_of_truth)) {\n const order = new Set(\n Array.isArray(frontmatter.source_of_truth.conflict_resolution_order)\n ? frontmatter.source_of_truth.conflict_resolution_order.filter(\n (item): item is string => typeof item === 'string',\n )\n : [],\n );\n for (const scope of records(frontmatter.source_of_truth, 'authority_scopes')) {\n if (!Array.isArray(scope.sources)) continue;\n for (const source of scope.sources) {\n if (typeof source === 'string' && !order.has(source)) {\n add(\n findings,\n 'error',\n 'source-authority',\n `Authority source ${JSON.stringify(source)} is absent from conflict_resolution_order.`,\n '/source_of_truth/authority_scopes',\n );\n }\n }\n }\n }\n return {\n controllers: controllerIds,\n rights,\n resources,\n services,\n agents,\n agentControllers,\n linkedEntities,\n claims,\n wallets,\n };\n}\n\nfunction stringArray(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((item): item is string => typeof item === 'string')\n : [];\n}\n\nfunction resolvesReference(value: string, ...sets: Set<string>[]): boolean {\n return externalReference(value) || sets.some((set) => set.has(value));\n}\n\nfunction validateConstitution(\n frontmatter: DomainRecord,\n documents: Set<string>,\n controllers: Set<string>,\n rights: Set<string>,\n resources: Set<string>,\n services: Set<string>,\n agents: Set<string>,\n agentControllers: Set<string>,\n linkedEntities: Set<string>,\n claims: Set<string>,\n wallets: Set<string>,\n findings: Finding[],\n): void {\n const constitution = isRecord(frontmatter.constitution) ? frontmatter.constitution : undefined;\n if (!constitution) {\n add(\n findings,\n 'error',\n 'constitution-required',\n 'Every domain.md 1.0.0-rc.3 document must declare constitutional status.',\n '/constitution',\n );\n return;\n }\n\n const domain = isRecord(frontmatter.domain) ? frontmatter.domain : undefined;\n const subject = typeof domain?.id === 'string' ? domain.id : undefined;\n if (subject !== undefined && constitution.subject !== subject) {\n add(\n findings,\n 'error',\n 'constitution-required',\n 'constitution.subject must exactly equal domain.id.',\n '/constitution/subject',\n );\n }\n\n const subjectProfile = isRecord(constitution.subject_profile)\n ? constitution.subject_profile\n : undefined;\n const subjectTypes = stringArray(subjectProfile?.subject_types);\n const archetypes = stringArray(subjectProfile?.archetypes);\n const subjectIdentity = stringArray(subjectProfile?.identity);\n const agenticTwins = stringArray(subjectProfile?.agentic_twins);\n if (!subjectProfile || subjectTypes.length === 0 || subjectIdentity.length === 0) {\n add(\n findings,\n 'error',\n 'constitutional-subject-profile-unresolved',\n 'Every domain must classify its constitutional subject and identify its canonical identity through constitution.subject_profile.',\n '/constitution/subject_profile',\n );\n }\n if (subject !== undefined && !subjectIdentity.includes(subject)) {\n add(\n findings,\n 'error',\n 'constitutional-subject-profile-unresolved',\n 'constitution.subject_profile.identity must include constitution.subject.',\n '/constitution/subject_profile/identity',\n );\n }\n for (const reference of [...subjectTypes, ...archetypes]) {\n if (!externalReference(reference)) {\n add(\n findings,\n 'error',\n 'constitutional-subject-profile-unresolved',\n `Constitutional subject taxonomy reference ${reference} must be an IRI.`,\n '/constitution/subject_profile',\n );\n }\n }\n\n const profileReferenceSets: Array<[string, Set<string>[]]> = [\n ['identity', [controllers, linkedEntities, resources]],\n ['purposes', [documents, resources]],\n ['interests', [documents, resources]],\n ['values', [documents, resources]],\n ['rights', [rights]],\n ['obligations', [documents, resources, rights]],\n ['capabilities', [rights, resources, services]],\n ['claims', [claims, resources]],\n ['wallets', [wallets, resources]],\n ['authorities', [controllers, linkedEntities]],\n ['memory', [resources]],\n ['evidence_policies', [documents, resources]],\n ['evaluation_policies', [documents, resources]],\n ['decision_policies', [documents, resources]],\n ['settlement_policies', [documents, resources]],\n ['governance', [documents, resources]],\n ['custodians', [controllers, linkedEntities]],\n ['stewards', [controllers, linkedEntities]],\n ['owners', [controllers, linkedEntities]],\n ['beneficiaries', [controllers, linkedEntities]],\n ['oracles', [agents, services, linkedEntities]],\n ['agentic_twins', [agents, linkedEntities]],\n ];\n for (const [field, sets] of profileReferenceSets) {\n for (const reference of stringArray(subjectProfile?.[field])) {\n if (!resolvesReference(reference, ...sets)) {\n add(\n findings,\n 'error',\n 'constitutional-subject-profile-unresolved',\n `Constitutional subject ${field} reference ${reference} does not resolve.`,\n `/constitution/subject_profile/${field}`,\n );\n }\n }\n }\n\n const controllerSummary =\n isRecord(frontmatter.controllers) && isRecord(frontmatter.controllers.summary)\n ? frontmatter.controllers.summary\n : undefined;\n const agentMode =\n isRecord(frontmatter.agent_default_mode) &&\n typeof frontmatter.agent_default_mode.mode === 'string'\n ? frontmatter.agent_default_mode.mode\n : undefined;\n const governedTypes = new Set([\n 'dao',\n 'organisation',\n 'project',\n 'protocol',\n 'marketplace',\n 'pod',\n ]);\n const agentic =\n agents.size > 0 ||\n agentControllers.size > 0 ||\n agenticTwins.length > 0 ||\n controllerSummary?.agent_controllers_allowed === true ||\n agentMode === 'bounded_evaluate' ||\n agentMode === 'bounded_execute';\n const constitutionRequired =\n (typeof domain?.type === 'string' && governedTypes.has(domain.type)) || agentic;\n\n if (constitution.status === 'not_applicable') {\n const declaresConstitutionalPackage = [\n 'legal_effect',\n 'norms',\n 'instruments',\n 'governance',\n 'execution',\n 'constitutional_ai',\n ].some((field) => field in constitution);\n if (constitutionRequired || declaresConstitutionalPackage) {\n add(\n findings,\n 'error',\n 'constitution-not-applicable-invalid',\n 'Only passive domains without a constitutional package, agents, agent controllers, bounded agency, or executable governance may declare constitution.status as not_applicable.',\n '/constitution/status',\n );\n }\n return;\n }\n\n const legalEffect = isRecord(constitution.legal_effect) ? constitution.legal_effect : undefined;\n const governance = isRecord(constitution.governance) ? constitution.governance : undefined;\n const execution = isRecord(constitution.execution) ? constitution.execution : undefined;\n const constitutionalAI = isRecord(constitution.constitutional_ai)\n ? constitution.constitutional_ai\n : undefined;\n const instruments = Array.isArray(constitution.instruments)\n ? constitution.instruments.filter(isRecord)\n : [];\n if (\n !legalEffect ||\n !governance ||\n !execution ||\n !constitutionalAI ||\n instruments.length === 0 ||\n stringArray(constitution.norms).length === 0\n ) {\n add(\n findings,\n 'error',\n 'constitution-required',\n 'A constitutional package requires legal effect, norms, instruments, governance, execution, and constitutional-AI declarations.',\n '/constitution',\n );\n }\n for (const norm of stringArray(constitution.norms)) {\n if (!resolvesReference(norm, resources)) {\n add(\n findings,\n 'error',\n 'constitution-required',\n `Constitutional norm ${norm} does not resolve.`,\n '/constitution/norms',\n );\n }\n }\n\n const instrumentByDocument = new Map<string, DomainRecord>();\n for (const instrument of instruments) {\n if (typeof instrument.document_ref !== 'string' || !documents.has(instrument.document_ref)) {\n add(\n findings,\n 'error',\n 'constitutional-instrument-unresolved',\n `Constitutional instrument ${String(instrument.document_ref)} does not resolve to documents.entries[].id.`,\n '/constitution/instruments',\n );\n continue;\n }\n instrumentByDocument.set(instrument.document_ref, instrument);\n if (\n typeof instrument.effective_from === 'string' &&\n typeof instrument.effective_until === 'string' &&\n Date.parse(instrument.effective_from) > Date.parse(instrument.effective_until)\n ) {\n add(\n findings,\n 'error',\n 'constitution-conflicts-canonical',\n `Instrument ${instrument.document_ref} ends before it becomes effective.`,\n '/constitution/instruments',\n );\n }\n }\n\n if (\n constitution.status === 'superseded' &&\n instruments.some((instrument) => instrument.canonical === true)\n ) {\n add(\n findings,\n 'error',\n 'constitution-conflicts-canonical',\n 'A superseded constitution cannot retain a canonical instrument.',\n '/constitution/instruments',\n );\n }\n\n for (const entry of documentEntries(frontmatter.documents)) {\n if (typeof entry.id !== 'string' || typeof entry.supersedes !== 'string') continue;\n const current = instrumentByDocument.get(entry.id);\n const previous = instrumentByDocument.get(entry.supersedes);\n if (current?.canonical === true && previous?.canonical === true) {\n add(\n findings,\n 'error',\n 'constitution-conflicts-canonical',\n `Constitutional instruments ${entry.id} and ${entry.supersedes} cannot both be canonical when one supersedes the other.`,\n '/constitution/instruments',\n );\n }\n }\n\n if (\n legalEffect?.status === 'verified' &&\n (typeof legalEffect.jurisdiction !== 'string' ||\n stringArray(legalEffect.authority_evidence).length === 0)\n ) {\n add(\n findings,\n 'error',\n 'constitutional-authority-unverified',\n 'Verified legal effect requires a jurisdiction and at least one authority-evidence reference.',\n '/constitution/legal_effect',\n );\n }\n for (const reference of stringArray(legalEffect?.authority_evidence)) {\n if (!resolvesReference(reference, resources)) {\n add(\n findings,\n 'error',\n 'constitutional-authority-unverified',\n `Legal authority evidence ${reference} does not resolve.`,\n '/constitution/legal_effect/authority_evidence',\n );\n }\n }\n\n for (const reference of stringArray(governance?.authority_sources)) {\n if (!resolvesReference(reference, documents, resources)) {\n add(\n findings,\n 'error',\n 'constitutional-authority-unverified',\n `Constitutional authority source ${reference} does not resolve.`,\n '/constitution/governance/authority_sources',\n );\n }\n }\n for (const field of [\n 'decision_procedure',\n 'amendment_procedure',\n 'interpretation_procedure',\n 'dispute_resolution_procedure',\n 'suspension_procedure',\n 'dissolution_procedure',\n ]) {\n const reference = governance?.[field];\n if (typeof reference === 'string' && !resolvesReference(reference, documents, resources)) {\n add(\n findings,\n 'error',\n 'constitutional-authority-unverified',\n `Constitutional ${field} ${reference} does not resolve.`,\n `/constitution/governance/${field}`,\n );\n }\n }\n\n const amends = instruments.some((instrument) =>\n stringArray(instrument.functions).includes('amending'),\n );\n if (\n amends &&\n (typeof governance?.amendment_procedure !== 'string' ||\n stringArray(governance?.authority_sources).length === 0)\n ) {\n add(\n findings,\n 'error',\n 'constitutional-amendment-unapproved',\n 'An amending instrument requires an amendment procedure and at least one authority source.',\n '/constitution/governance/amendment_procedure',\n );\n }\n\n const executable =\n execution?.mode === 'machine_executable' ||\n execution?.mode === 'hybrid' ||\n instruments.some((instrument) => stringArray(instrument.functions).includes('executable'));\n const implementations = stringArray(execution?.implementations);\n const conformanceTests = stringArray(execution?.conformance_tests);\n const enforcementPoints = stringArray(execution?.enforcement_points);\n const humanReviewGates = stringArray(execution?.human_review_required_for);\n if (\n executable &&\n (implementations.length === 0 ||\n conformanceTests.length === 0 ||\n enforcementPoints.length === 0 ||\n humanReviewGates.length === 0 ||\n !['deny', 'pause_and_escalate'].includes(String(execution?.failure_policy)))\n ) {\n add(\n findings,\n 'error',\n 'constitutional-execution-incomplete',\n 'Executable constitutional governance requires implementations, conformance tests, enforcement points, human-review gates, and a fail-closed policy.',\n '/constitution/execution',\n );\n }\n for (const reference of [...implementations, ...conformanceTests]) {\n if (!resolvesReference(reference, resources)) {\n add(\n findings,\n 'error',\n 'constitutional-execution-incomplete',\n `Constitutional execution resource ${reference} does not resolve.`,\n '/constitution/execution',\n );\n }\n }\n for (const reference of enforcementPoints) {\n if (!resolvesReference(reference, services)) {\n add(\n findings,\n 'error',\n 'constitutional-execution-incomplete',\n `Constitutional enforcement point ${reference} does not resolve.`,\n '/constitution/execution/enforcement_points',\n );\n }\n }\n\n const aiMode = typeof constitutionalAI?.mode === 'string' ? constitutionalAI.mode : undefined;\n if (agentic && (!aiMode || aiMode === 'none')) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n 'Agentic domains require an active constitutional-AI mode.',\n '/constitution/constitutional_ai/mode',\n );\n }\n if (aiMode && aiMode !== 'none') {\n const principles = stringArray(constitutionalAI?.principles);\n const appliesToAgents = stringArray(constitutionalAI?.applies_to_agents);\n const constitutionalAgentIds = new Set([...agents, ...agentControllers, ...agenticTwins]);\n const auditRecord = constitutionalAI?.audit_record;\n const critiqueRequired = aiMode === 'critique_and_revise' || aiMode === 'hybrid';\n const decisionRequired = aiMode === 'policy_evaluate' || aiMode === 'hybrid';\n if (\n principles.length === 0 ||\n typeof auditRecord !== 'string' ||\n constitutionalAI?.conflict_policy !== 'canonical_authority_prevails' ||\n (critiqueRequired &&\n (typeof constitutionalAI.critique_procedure !== 'string' ||\n typeof constitutionalAI.revision_procedure !== 'string')) ||\n (decisionRequired && typeof constitutionalAI.decision_procedure !== 'string')\n ) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n 'Active constitutional AI requires principles, mode-specific procedures, canonical-authority conflict policy, and an audit-record definition.',\n '/constitution/constitutional_ai',\n );\n }\n if (constitutionalAgentIds.size > 0 && appliesToAgents.length === 0) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n 'Constitutional AI must identify the declared agents and agent controllers to which it applies.',\n '/constitution/constitutional_ai/applies_to_agents',\n );\n }\n for (const controller of agentControllers) {\n if (!appliesToAgents.includes(controller)) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n `Agent controller ${controller} must be bound to the constitutional-AI principles and procedures.`,\n '/constitution/constitutional_ai/applies_to_agents',\n );\n }\n }\n for (const twin of agenticTwins) {\n if (!appliesToAgents.includes(twin)) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n `Agentic twin ${twin} must be bound to the subject's constitutional-AI principles and procedures.`,\n '/constitution/constitutional_ai/applies_to_agents',\n );\n }\n }\n for (const agent of appliesToAgents) {\n if (!constitutionalAgentIds.has(agent)) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n `Constitutional-AI subject ${agent} is not declared as an agent or agent controller.`,\n '/constitution/constitutional_ai/applies_to_agents',\n );\n }\n }\n for (const reference of [\n ...principles,\n constitutionalAI?.critique_procedure,\n constitutionalAI?.revision_procedure,\n constitutionalAI?.decision_procedure,\n constitutionalAI?.model_profile,\n auditRecord,\n ]) {\n if (typeof reference === 'string' && !resolvesReference(reference, resources)) {\n add(\n findings,\n 'error',\n 'constitutional-ai-incomplete',\n `Constitutional-AI resource ${reference} does not resolve.`,\n '/constitution/constitutional_ai',\n );\n }\n }\n }\n}\n\ninterface FlowIndexEntry {\n transitions: Set<string>;\n}\n\nfunction validateFlows(\n frontmatter: DomainRecord,\n rights: Set<string>,\n findings: Finding[],\n): Map<string, FlowIndexEntry> {\n const index = new Map<string, FlowIndexEntry>();\n for (const pod of records(frontmatter.pods, 'entries')) {\n for (const role of records(pod, 'roles')) {\n if (!Array.isArray(role.rights)) continue;\n for (const right of role.rights) {\n if (typeof right === 'string' && !rights.has(right)) {\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `POD role ${String(role.id)} references missing right ${right}.`,\n '/pods/entries/roles',\n );\n }\n }\n }\n for (const flow of records(pod, 'flows')) {\n if (typeof flow.id !== 'string') continue;\n if (index.has(flow.id))\n add(\n findings,\n 'error',\n 'duplicate-entry-id',\n `Duplicate flow id ${flow.id}.`,\n '/pods/entries/flows',\n );\n const states = new Set(\n Array.isArray(flow.states)\n ? flow.states.filter((item): item is string => typeof item === 'string')\n : [],\n );\n const transitions = records(flow, 'transitions');\n const transitionIds = uniqueIds(transitions, `transition in ${flow.id}`, findings);\n index.set(flow.id, { transitions: transitionIds });\n const initial = typeof flow.initial_state === 'string' ? flow.initial_state : '';\n if (!states.has(initial))\n add(\n findings,\n 'error',\n 'invalid-flow',\n `Flow ${flow.id} initial state is not declared.`,\n '/pods/entries/flows',\n );\n const reachable = new Set(initial ? [initial] : []);\n let changed = true;\n while (changed) {\n changed = false;\n for (const transition of transitions) {\n if (\n typeof transition.from === 'string' &&\n typeof transition.to === 'string' &&\n reachable.has(transition.from) &&\n !reachable.has(transition.to)\n ) {\n reachable.add(transition.to);\n changed = true;\n }\n }\n }\n for (const transition of transitions) {\n if (\n (typeof transition.from === 'string' && !states.has(transition.from)) ||\n (typeof transition.to === 'string' && !states.has(transition.to))\n ) {\n add(\n findings,\n 'error',\n 'invalid-flow',\n `Flow ${flow.id} transition ${String(transition.id)} references an unknown state.`,\n '/pods/entries/flows',\n );\n }\n if (Array.isArray(transition.actor_rights)) {\n for (const right of transition.actor_rights) {\n if (typeof right === 'string' && !rights.has(right))\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Flow ${flow.id} references missing right ${right}.`,\n '/pods/entries/flows',\n );\n }\n }\n const effects = Array.isArray(transition.effects) ? transition.effects.map(String) : [];\n if (\n effects.some((effect) =>\n ['credential', 'payment', 'mint', 'burn', 'transfer'].includes(effect),\n ) &&\n transition.human_review !== true\n ) {\n add(\n findings,\n 'error',\n 'invalid-flow',\n `Consequential transition ${flow.id}/${String(transition.id)} requires human review.`,\n '/pods/entries/flows',\n );\n }\n }\n for (const state of states) {\n if (!reachable.has(state))\n add(\n findings,\n 'error',\n 'invalid-flow',\n `Flow ${flow.id} state ${state} is unreachable.`,\n '/pods/entries/flows',\n );\n }\n }\n }\n return index;\n}\n\nfunction validateClaims(\n frontmatter: DomainRecord,\n rights: Set<string>,\n resources: Set<string>,\n flows: Map<string, FlowIndexEntry>,\n findings: Finding[],\n): void {\n const collections = records(frontmatter.claims, 'collections');\n uniqueIds(collections, 'claim collection', findings);\n for (const collection of collections) {\n const claimTypes = records(collection, 'claim_types');\n uniqueIds(claimTypes, 'claim type', findings);\n for (const claim of claimTypes) {\n for (const field of ['evaluator_right', 'determiner_right']) {\n const right = claim[field];\n if (typeof right === 'string' && !rights.has(right))\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} references missing ${field} ${right}.`,\n '/claims/collections',\n );\n }\n const review = isRecord(claim.human_review_policy) ? claim.human_review_policy : undefined;\n if (typeof review?.reviewer_right === 'string' && !rights.has(review.reviewer_right)) {\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} reviewer right does not resolve.`,\n '/claims/collections',\n );\n }\n const rubric = isRecord(claim.rubric) ? claim.rubric : undefined;\n if (\n typeof rubric?.resource_id === 'string' &&\n !externalReference(rubric.resource_id) &&\n !resources.has(rubric.resource_id)\n ) {\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} rubric does not resolve.`,\n '/claims/collections',\n );\n }\n for (const requirement of records(claim, 'evidence_requirements')) {\n if (\n typeof requirement.resource_id === 'string' &&\n !externalReference(requirement.resource_id) &&\n !resources.has(requirement.resource_id)\n ) {\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} evidence resource does not resolve.`,\n '/claims/collections',\n );\n }\n }\n const outcomes = new Set(Array.isArray(claim.allowed_outcomes) ? claim.allowed_outcomes : []);\n for (const action of records(claim, 'next_actions')) {\n if (!outcomes.has(action.outcome))\n add(\n findings,\n 'error',\n 'incomplete-claim-contract',\n `Claim ${String(claim.id)} next action uses an undeclared outcome.`,\n '/claims/collections',\n );\n const flow = typeof action.flow_id === 'string' ? flows.get(action.flow_id) : undefined;\n if (!flow)\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} next-action flow does not resolve.`,\n '/claims/collections',\n );\n else if (typeof action.transition !== 'string' || !flow.transitions.has(action.transition))\n add(\n findings,\n 'error',\n 'broken-local-reference',\n `Claim ${String(claim.id)} next-action transition does not resolve.`,\n '/claims/collections',\n );\n }\n }\n }\n}\n\nfunction validatePrivacy(frontmatter: DomainRecord, findings: Finding[]): void {\n for (const entry of [\n ...records(frontmatter.documents, 'entries'),\n ...records(frontmatter.resources, 'entries'),\n ]) {\n if (entry.sensitivity !== 'public' && entry.access_policy === 'public') {\n const label =\n typeof entry.id === 'string'\n ? entry.id\n : typeof entry.role === 'string'\n ? entry.role\n : 'entry';\n add(\n findings,\n 'error',\n 'privacy-public-sensitive',\n `Sensitive ${label} cannot use public access.`,\n '/privacy',\n );\n }\n }\n for (const service of records(frontmatter.services, 'entries')) {\n const auth = isRecord(service.auth) ? service.auth : undefined;\n if (service.data_classification !== 'public' && auth?.method === 'none') {\n add(\n findings,\n 'error',\n 'privacy-public-sensitive',\n `Non-public service ${String(service.id)} requires an authentication boundary.`,\n '/services/entries',\n );\n }\n }\n}\n\nexport function inferMode(frontmatter: DomainRecord): DomainMode | null {\n if (!isRecord(frontmatter.domain)) return null;\n if (frontmatter.domain.type === 'protocol') return 'protocol';\n if (typeof frontmatter.domain.class === 'string') return 'derived';\n return 'standalone';\n}\n\nexport function getProfile(frontmatter: DomainRecord): ConformanceProfile | null {\n return isRecord(frontmatter.conformance) && typeof frontmatter.conformance.profile === 'string'\n ? (frontmatter.conformance.profile as ConformanceProfile)\n : null;\n}\n\nexport function validateSemantics(\n document: DomainDocument,\n expectedProfile?: ConformanceProfile,\n): Finding[] {\n const findings: Finding[] = [];\n if (!validateSchema(document.frontmatter)) {\n for (const error of validateSchema.errors ?? []) {\n add(\n findings,\n 'error',\n 'schema',\n `${error.instancePath || '$'} ${error.message ?? 'is invalid'}.`,\n error.instancePath || '/',\n );\n }\n }\n const profile = getProfile(document.frontmatter);\n if (expectedProfile !== undefined && profile !== expectedProfile) {\n add(\n findings,\n 'error',\n 'profile-mismatch',\n `Expected ${expectedProfile}, found ${String(profile)}.`,\n '/conformance/profile',\n );\n }\n if (AUTHOR_PLACEHOLDER.test(document.raw) || PUBLISH_PLACEHOLDER.test(document.raw)) {\n add(\n findings,\n 'error',\n 'template-placeholder',\n 'Conforming domain.md output contains an unresolved placeholder.',\n );\n }\n for (const key of Object.keys(document.frontmatter)) {\n if (!KNOWN_TOP_LEVEL_KEYS.has(key) && !key.startsWith('x-'))\n add(\n findings,\n 'warning',\n 'unknown-top-level-key',\n `Unknown top-level key ${JSON.stringify(key)}.`,\n `/${key}`,\n );\n }\n inspectSecrets(document.frontmatter, findings);\n validateSections(document, findings);\n const documents = validateDocuments(document.frontmatter, findings);\n const {\n controllers,\n rights,\n resources,\n services,\n agents,\n agentControllers,\n linkedEntities,\n claims,\n wallets,\n } = validateAuthority(document.frontmatter, findings);\n validateConstitution(\n document.frontmatter,\n documents,\n controllers,\n rights,\n resources,\n services,\n agents,\n agentControllers,\n linkedEntities,\n claims,\n wallets,\n findings,\n );\n const flows = validateFlows(document.frontmatter, rights, findings);\n validateClaims(document.frontmatter, rights, resources, flows, findings);\n validatePrivacy(document.frontmatter, findings);\n if (profile === 'anchored' || profile === 'runtime') {\n add(\n findings,\n 'info',\n 'runtime-external-checks-required',\n 'Static validation cannot prove all anchored or runtime checks.',\n );\n }\n return findings.map((finding) => locate(document, finding));\n}\n","import { EXTERNAL_CHECKS, PACKAGE_VERSION, SPEC_VERSION } from './constants.js';\nimport { parseDomain } from './parser.js';\nimport { getProfile, inferMode, validateSemantics } from './semantic.js';\nimport type { Finding, FindingSummary, LintOptions, LintReport } from './types.js';\n\nfunction summarize(findings: Finding[]): FindingSummary {\n return {\n errors: findings.filter((item) => item.severity === 'error').length,\n warnings: findings.filter((item) => item.severity === 'warning').length,\n infos: findings.filter((item) => item.severity === 'info').length,\n };\n}\n\nexport function lint(content: string, options: LintOptions = {}): LintReport {\n const parsed = parseDomain(content, options);\n const findings = [...parsed.findings];\n if (parsed.document)\n findings.push(...validateSemantics(parsed.document, options.expectedProfile));\n const summary = summarize(findings);\n const profile = parsed.document ? getProfile(parsed.document.frontmatter) : null;\n const externalChecksRequired =\n profile === 'persisted_draft'\n ? EXTERNAL_CHECKS.filter((check) => check.code === 'cid-verification')\n : profile === 'anchored' || profile === 'runtime'\n ? [...EXTERNAL_CHECKS]\n : [];\n const result: LintReport = {\n tool: '@ixo/domain.md',\n toolVersion: PACKAGE_VERSION,\n specVersion: SPEC_VERSION,\n sourceName: options.sourceName ?? '<memory>',\n mode: parsed.document ? inferMode(parsed.document.frontmatter) : null,\n profile,\n status: summary.errors === 0 ? 'static-pass' : 'fail',\n ok: summary.errors === 0,\n summary,\n findings,\n externalChecksRequired,\n };\n if (parsed.document) result.document = parsed.document;\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,eAAe;AACxB,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,eAAe,SAAS,iBAAiB;AAU3D,IAAM,cAAc;AAEpB,SAAS,QAAQ,MAAc,SAAiB,OAAO,KAAc;AACnE,SAAO,EAAE,UAAU,SAAS,MAAM,SAAS,MAAM,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE;AACpF;AAEA,SAAS,SAAS,OAAuC;AACvD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,SAAS,OAAwB;AACxC,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,MAAI,OAAO,MAAM,UAAU,SAAU,QAAO,MAAM;AAClD,SAAO,MAAM,QAAQ,MAAM,QAAQ,IAAI,MAAM,SAAS,IAAI,QAAQ,EA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ord","finding"]}
@@ -0,0 +1,171 @@
1
+ type Severity = 'error' | 'warning' | 'info';
2
+ type ConformanceProfile = 'authoring_draft' | 'persisted_draft' | 'anchored' | 'runtime';
3
+ type DomainMode = 'derived' | 'protocol' | 'standalone';
4
+ type DomainRecord = Record<string, unknown>;
5
+ interface SourceLocation {
6
+ line: number;
7
+ column: number;
8
+ endLine?: number;
9
+ endColumn?: number;
10
+ }
11
+ interface Finding {
12
+ severity: Severity;
13
+ code: string;
14
+ message: string;
15
+ path: string;
16
+ location: SourceLocation;
17
+ remediation?: string;
18
+ }
19
+ interface DomainSection {
20
+ heading: string;
21
+ content: string;
22
+ location: SourceLocation;
23
+ }
24
+ interface DomainDocument {
25
+ frontmatter: DomainRecord;
26
+ sections: DomainSection[];
27
+ sourceName: string;
28
+ raw: string;
29
+ }
30
+ interface ParseOptions {
31
+ sourceName?: string;
32
+ maxBytes?: number;
33
+ }
34
+ interface ParseResult {
35
+ ok: boolean;
36
+ document?: DomainDocument;
37
+ findings: Finding[];
38
+ }
39
+ interface LintOptions extends ParseOptions {
40
+ expectedProfile?: ConformanceProfile;
41
+ }
42
+ interface FindingSummary {
43
+ errors: number;
44
+ warnings: number;
45
+ infos: number;
46
+ }
47
+ interface ExternalCheck {
48
+ code: string;
49
+ category: 'integrity' | 'identity' | 'authorization' | 'time' | 'chain';
50
+ reason: string;
51
+ }
52
+ type ConstitutionStatus = 'not_applicable' | 'draft' | 'adopted' | 'in_force' | 'suspended' | 'superseded';
53
+ type ConstitutionalInstrumentFunction = 'constitutive' | 'governing' | 'amending' | 'interpretive' | 'executable';
54
+ interface LegalEffect {
55
+ status: 'none' | 'claimed' | 'verified' | 'unknown';
56
+ jurisdiction: string | null;
57
+ authority_evidence: string[];
58
+ }
59
+ interface ConstitutionalInstrument {
60
+ document_ref: string;
61
+ type: string;
62
+ functions: ConstitutionalInstrumentFunction[];
63
+ canonical: boolean;
64
+ effective_from: string | null;
65
+ effective_until: string | null;
66
+ }
67
+ interface ConstitutionalGovernance {
68
+ authority_sources: string[];
69
+ decision_procedure: string | null;
70
+ amendment_procedure: string | null;
71
+ interpretation_procedure: string | null;
72
+ dispute_resolution_procedure: string | null;
73
+ suspension_procedure: string | null;
74
+ dissolution_procedure: string | null;
75
+ }
76
+ interface ConstitutionalExecution {
77
+ mode: 'human_interpreted' | 'machine_assisted' | 'machine_executable' | 'hybrid';
78
+ implementations: string[];
79
+ conformance_tests: string[];
80
+ enforcement_points: string[];
81
+ failure_policy: 'deny' | 'pause_and_escalate';
82
+ human_review_required_for: string[];
83
+ }
84
+ interface ConstitutionalAI {
85
+ mode: 'none' | 'context_only' | 'critique_and_revise' | 'policy_evaluate' | 'hybrid';
86
+ applies_to_agents: string[];
87
+ principles: string[];
88
+ critique_procedure: string | null;
89
+ revision_procedure: string | null;
90
+ decision_procedure: string | null;
91
+ model_profile: string | null;
92
+ conflict_policy: 'canonical_authority_prevails';
93
+ audit_record: string | null;
94
+ }
95
+ interface ConstitutionalSubjectProfile {
96
+ subject_types: string[];
97
+ archetypes: string[];
98
+ identity: string[];
99
+ purposes: string[];
100
+ interests: string[];
101
+ values: string[];
102
+ rights: string[];
103
+ obligations: string[];
104
+ capabilities: string[];
105
+ claims: string[];
106
+ wallets: string[];
107
+ authorities: string[];
108
+ memory: string[];
109
+ evidence_policies: string[];
110
+ evaluation_policies: string[];
111
+ decision_policies: string[];
112
+ settlement_policies: string[];
113
+ governance: string[];
114
+ custodians: string[];
115
+ stewards: string[];
116
+ owners: string[];
117
+ beneficiaries: string[];
118
+ oracles: string[];
119
+ agentic_twins: string[];
120
+ }
121
+ interface ConstitutionDeclaration {
122
+ status: ConstitutionStatus;
123
+ reason: string | null;
124
+ subject: string;
125
+ type: string;
126
+ subject_profile: ConstitutionalSubjectProfile;
127
+ legal_effect?: LegalEffect;
128
+ norms?: string[];
129
+ instruments?: ConstitutionalInstrument[];
130
+ governance?: ConstitutionalGovernance;
131
+ execution?: ConstitutionalExecution;
132
+ constitutional_ai?: ConstitutionalAI;
133
+ }
134
+ interface LintReport {
135
+ tool: '@ixo/domain.md';
136
+ toolVersion: string;
137
+ specVersion: string;
138
+ sourceName: string;
139
+ mode: DomainMode | null;
140
+ profile: ConformanceProfile | null;
141
+ status: 'static-pass' | 'fail';
142
+ ok: boolean;
143
+ summary: FindingSummary;
144
+ findings: Finding[];
145
+ externalChecksRequired: ExternalCheck[];
146
+ document?: DomainDocument;
147
+ }
148
+ type ChangeClassification = 'security-sensitive' | 'operational' | 'narrative';
149
+ interface DomainChange {
150
+ path: string;
151
+ classification: ChangeClassification;
152
+ before?: unknown;
153
+ after?: unknown;
154
+ }
155
+ interface DiffOptions {
156
+ failOn?: 'regression' | 'review';
157
+ }
158
+ interface DiffReport {
159
+ before: FindingSummary;
160
+ after: FindingSummary;
161
+ changes: DomainChange[];
162
+ conformanceRegression: boolean;
163
+ requiresReview: boolean;
164
+ regression: boolean;
165
+ }
166
+ interface ExportOptions {
167
+ format: 'json' | 'sarif';
168
+ sourceName?: string;
169
+ }
170
+
171
+ export type { ChangeClassification as C, DomainRecord as D, ExportOptions as E, Finding as F, LegalEffect as L, ParseOptions as P, Severity as S, DiffOptions as a, DiffReport as b, ConformanceProfile as c, ConstitutionDeclaration as d, ConstitutionStatus as e, ConstitutionalAI as f, ConstitutionalExecution as g, ConstitutionalGovernance as h, ConstitutionalInstrument as i, ConstitutionalInstrumentFunction as j, ConstitutionalSubjectProfile as k, DomainChange as l, DomainDocument as m, DomainMode as n, DomainSection as o, ExternalCheck as p, FindingSummary as q, LintOptions as r, LintReport as s, ParseResult as t, SourceLocation as u };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { F as Finding } from './cli-KcUIQEiE.js';