// ============================================================================ // mainframe doctor - registry conformance for the interface, agent, loadout // and device registries. // // Every query returns ZERO rows on a conformant platform. A row is a finding. // Run: cypher-shell -f doctor-registries.cypher // // Hand-written Cypher, no generator. This deliberately replaces the // generator-emitted checks for the new registries so that no Python tool sits // in the conformance path (laws.md law 4). // ============================================================================ // 1. A service in the service registry that belongs to no loadout. Composition // is how a fleet stays uniform, so an unloaded service is unmanaged. MATCH (s:Entry:Service) WHERE NOT (:Entry:Loadout)-[:CONTAINS]->(s) RETURN 'service_without_loadout' AS check, s.registry AS registry, s.key AS key, s.name AS name; // 1b. A host-derived fact with no snapshot lineage. Evidence over assertion: // an observed fact must cite the observation snapshot it was read from. MATCH (e:Entry) WHERE e.source = 'host-index' AND (e.observedFrom IS NULL OR e.observedFrom = '') RETURN 'missing_snapshot_lineage' AS check, e.registry AS registry, e.key AS key, e.name AS name; // 2. A loadout that does not, directly or transitively, require core. Core // carries identity, secrets and the agent runtime; a node without it is not // part of the mainframe. MATCH (l:Entry:Loadout) WHERE l.mandatory = false AND NOT (l)-[:REQUIRES*1..4]->(:Entry:Loadout {key: 'core'}) RETURN 'loadout_without_core' AS check, l.key AS key, l.name AS name; // 3. No mandatory loadout declared. The model assumes exactly one. MATCH (l:Entry:Loadout) WHERE l.mandatory = true WITH count(l) AS mandatoryCount WHERE mandatoryCount <> 1 RETURN 'mandatory_loadout_count' AS check, mandatoryCount AS count; // 4. An agent with no interface. An agent nothing can reach cannot be // governed, alerted on, or held to account. MATCH (a:Entry:Agent) WHERE NOT (a)-[:EXPOSED_VIA]->(:Entry:Interface) RETURN 'agent_without_interface' AS check, a.key AS key, a.name AS name, a.runtime AS runtime; // 5. An agent declaring skills that do not exist as references, so its // capability set is asserted rather than evidenced. // Two syntax faults fixed 2026-10-06: a bare WHERE cannot follow UNWIND (WHERE // is a sub-clause of MATCH/WITH, so the UNWIND must be closed with WITH), and // the inner MATCH must bind a variable rather than matching an anonymous node. // cypher-shell aborts the whole file at the first error, so this silently // skipped checks 6 to 12. MATCH (a:Entry:Agent) WHERE a.skills IS NOT NULL AND size(a.skills) > 0 UNWIND a.skills AS skill WITH a, skill WHERE NOT EXISTS { MATCH (e:Entry) WHERE e.key = skill } RETURN 'agent_skill_unregistered' AS check, a.key AS agent, skill AS skill; // 6. An interface pointing at a host with no matching service in the service // registry. Best-effort: matched on the first hostname label. MATCH (i:Entry:Interface) WHERE i.url CONTAINS '://' WITH i, split(split(i.url, '://')[1], '/')[0] AS host WITH i, split(host, '.')[0] AS label WHERE NOT EXISTS { MATCH (s:Entry:Service) WHERE s.key = label } RETURN 'interface_without_backing_service' AS check, i.key AS interface, label AS expectedService; // 7. A device declaring no capabilities. A device-as-API with no capability // scope is an unscoped endpoint. MATCH (d:Entry:Device) WHERE d.capabilities IS NULL OR size(d.capabilities) = 0 RETURN 'device_without_capabilities' AS check, d.key AS key, d.name AS name; // 8. An agent in the agent registry with no declared runtime, so provenance of // its execution surface is unknown. MATCH (a:Entry:Agent) WHERE a.runtime IS NULL RETURN 'agent_without_runtime' AS check, a.key AS key, a.name AS name; // 9. CLOSED WORLD for playbooks. A step naming a verb that is not in the // primitive registry is an invented procedure. This is the check that makes // "the playbook is data" a claim rather than a hope. MATCH (p:Entry:Playbook)-[u:USES]->(v) WHERE NOT (v)-[:IN_REGISTRY]->(:Registry {key: 'primitive'}) RETURN 'playbook_step_unknown_primitive' AS check, p.key AS playbook, u.phase AS phase, v.key AS primitive; // 10. An incident-class playbook with no approval-gated step. Every incident // response must pass through at least one human decision. MATCH (p:Entry:Playbook {class: 'incident'}) WHERE NOT EXISTS { MATCH (p)-[:USES]->(v:Entry:Primitive) WHERE v.approval <> 'none' } RETURN 'playbook_without_approval_gate' AS check, p.key AS playbook, p.name AS name; // 11. An incident-class playbook that produces no verification or evidence // step, so it cannot be shown to have worked. MATCH (p:Entry:Playbook {class: 'incident'}) WHERE NOT EXISTS { MATCH (p)-[:USES]->(v:Entry:Primitive) WHERE v.intent IN ['verify', 'record'] } RETURN 'playbook_without_evidence' AS check, p.key AS playbook, p.name AS name; // 12. A declared primitive no playbook uses. Informational: either the // vocabulary is ahead of the scenarios, or a scenario should use it. MATCH (v:Entry:Primitive) WHERE NOT ()-[:USES]->(v) RETURN 'primitive_unused' AS check, v.key AS primitive, v.intent AS intent; // 13. A rewrite-track entry with no spec to reimplement from. The spec is the // deliverable of the study half; without it the rewrite is a port and a port // inherits the upstream licence, so this is a legal finding. MATCH (a:Entry:Adoption {track: 'study_and_rewrite'}) WHERE a.specToMine IS NULL OR a.specToMine = '' RETURN 'rewrite_target_without_spec' AS check, a.key AS key, a.name AS name; // 14. A rewrite-track entry that does not state its clean-room boundary. The // boundary is what makes licence provenance-only, so an unstated boundary is // an unsafe rewrite. MATCH (a:Entry:Adoption {track: 'study_and_rewrite'}) WHERE a.cleanRoom IS NULL OR a.cleanRoom = '' RETURN 'rewrite_target_without_clean_room' AS check, a.key AS key, a.name AS name; // 15. An interface with no track. Every interface is on one of the two tracks. MATCH (i:Entry:Interface) WHERE i.track IS NULL OR i.track = '' RETURN 'interface_without_track' AS check, i.key AS interface, i.category AS category; // 16. An interface on the rewrite track with no spec to reimplement from. MATCH (i:Entry:Interface {track: 'study_and_rewrite'}) WHERE i.specToMine IS NULL OR i.specToMine = '' RETURN 'rewrite_interface_without_spec' AS check, i.key AS interface;