{
  "format": "memorix-metadata/1",
  "agentId": "ops",
  "version": "0.2.0-static-memorix",
  "agents": [
    {
      "id": "ops",
      "name": "Operations (generic parent)",
      "description": "Complete generic parent agent for ordinary operational work. Permanent Memorix acceptance pack.",
      "parentId": null
    },
    {
      "id": "project-ops",
      "name": "Project Operations (child of ops)",
      "description": "Inheritance smoke agent. Extends ops without replacing core definitions.",
      "parentId": "ops"
    }
  ],
  "objectTypes": [
    {
      "id": "employees",
      "name": "Employees",
      "dataCategory": "entity",
      "abstractTypes": [
        "People",
        "KnowXEntity"
      ],
      "contentTypes": [
        {
          "id": "raw",
          "required": true
        },
        {
          "id": "snapshots",
          "required": true
        },
        {
          "id": "discovery",
          "discriminator": {
            "path": "data.discoveryType",
            "required": false,
            "defaultValue": "default"
          }
        },
        {
          "id": "analysis",
          "discriminator": {
            "path": "data.analysisType",
            "required": false,
            "defaultValue": "default"
          }
        },
        {
          "id": "relationships",
          "notes": "Candidate store shape until Gate G4"
        },
        {
          "id": "knowx",
          "notes": "KnowX NODE facet on same recordId"
        }
      ],
      "fields": [
        {
          "path": "data.displayName",
          "valueType": "string",
          "contentType": "snapshots"
        },
        {
          "path": "data.role",
          "valueType": "string",
          "contentType": "snapshots"
        }
      ]
    },
    {
      "id": "contractors",
      "name": "Contractors",
      "dataCategory": "entity",
      "abstractTypes": [
        "People",
        "KnowXEntity"
      ],
      "contentTypes": [
        {
          "id": "raw"
        },
        {
          "id": "snapshots"
        },
        {
          "id": "discovery",
          "discriminator": {
            "path": "data.discoveryType",
            "required": false
          }
        },
        {
          "id": "analysis",
          "discriminator": {
            "path": "data.analysisType",
            "required": false
          }
        },
        {
          "id": "relationships"
        },
        {
          "id": "knowx",
          "notes": "KnowX NODE facet on same recordId"
        }
      ],
      "fields": [
        {
          "path": "data.displayName",
          "valueType": "string",
          "contentType": "snapshots"
        },
        {
          "path": "data.role",
          "valueType": "string",
          "contentType": "snapshots"
        }
      ]
    },
    {
      "id": "work-items",
      "name": "Work Items",
      "dataCategory": "entity",
      "abstractTypes": [
        "WorkItems",
        "KnowXEntity"
      ],
      "contentTypes": [
        {
          "id": "raw"
        },
        {
          "id": "snapshots"
        },
        {
          "id": "discovery",
          "discriminator": {
            "path": "data.discoveryType",
            "required": false
          }
        },
        {
          "id": "analysis",
          "discriminator": {
            "path": "data.analysisType",
            "required": false,
            "defaultValue": "delivery-risk"
          }
        },
        {
          "id": "decisions",
          "discriminator": {
            "path": "data.decisionType",
            "required": false,
            "defaultValue": "priority"
          }
        },
        {
          "id": "workflow"
        },
        {
          "id": "context",
          "retention": "work-scoped-ttl"
        },
        {
          "id": "relationships"
        },
        {
          "id": "knowx",
          "notes": "KnowX NODE facet on same recordId"
        }
      ],
      "snapshotBuckets": {
        "analytics": "optional",
        "enrichment": "optional",
        "insights": "optional"
      }
    },
    {
      "id": "procedures",
      "name": "Procedures",
      "dataCategory": "knowledge",
      "abstractTypes": [
        "Procedures"
      ],
      "contentTypes": [
        {
          "id": "raw"
        },
        {
          "id": "snapshots",
          "notes": "Persistent knowledge content"
        },
        {
          "id": "relationships"
        }
      ],
      "retention": "persistent-knowledge"
    },
    {
      "id": "activity-events",
      "name": "Activity Events",
      "dataCategory": "event",
      "abstractTypes": [
        "ActivityEvents"
      ],
      "contentTypes": [
        {
          "id": "raw"
        },
        {
          "id": "snapshots",
          "notes": "Normalized event content"
        },
        {
          "id": "relationships"
        }
      ]
    },
    {
      "id": "assertions",
      "name": "Assertions",
      "dataCategory": "knowledge",
      "abstractTypes": [
        "KnowXEntity"
      ],
      "contentTypes": [
        {
          "id": "knowx",
          "required": true
        },
        {
          "id": "workflow"
        },
        {
          "id": "confirmations",
          "discriminator": {
            "path": "data.confirmationType",
            "required": false
          }
        }
      ]
    }
  ],
  "abstractTypes": [
    {
      "id": "People",
      "name": "People",
      "meaning": "Employees and contractors who perform operational work",
      "category": "entity",
      "properties": [
        {
          "id": "title",
          "valueType": "string",
          "required": true
        },
        {
          "id": "role",
          "valueType": "string",
          "required": true
        },
        {
          "id": "lens",
          "valueType": "string",
          "required": false
        }
      ]
    },
    {
      "id": "WorkItems",
      "name": "Work Items",
      "meaning": "Units of operational work",
      "category": "entity"
    },
    {
      "id": "Procedures",
      "name": "Procedures",
      "meaning": "Reusable operational knowledge / playbooks",
      "category": "knowledge"
    },
    {
      "id": "ActivityEvents",
      "name": "Activity Events",
      "meaning": "Progress and activity reports about work items",
      "category": "event"
    },
    {
      "id": "KnowXEntity",
      "name": "KnowX Entity",
      "meaning": "Virtual union of concrete subjects that may carry contentType knowx (NODE or EDGE). No KnowXNode/KnowXEdge types.",
      "category": "knowledge",
      "properties": [
        {
          "id": "kind",
          "valueType": "string",
          "required": false
        },
        {
          "id": "label",
          "valueType": "string",
          "required": false
        }
      ]
    }
  ],
  "abstractBindings": [
    {
      "id": "people-employees-contractors",
      "abstractType": "People",
      "concreteObjectTypes": [
        "employees",
        "contractors"
      ],
      "union": true,
      "notes": "People = Employees ∪ Contractors. No abstract records exist.",
      "members": [
        {
          "objectType": "employees",
          "contentType": "snapshots",
          "properties": [
            {
              "abstractProperty": "title",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-employees"
            },
            {
              "abstractProperty": "role",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-employees"
            },
            {
              "abstractProperty": "lens",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-employees"
            }
          ]
        },
        {
          "objectType": "contractors",
          "contentType": "snapshots",
          "properties": [
            {
              "abstractProperty": "title",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-contractors"
            },
            {
              "abstractProperty": "role",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-contractors"
            },
            {
              "abstractProperty": "lens",
              "contentType": "snapshots",
              "mappingId": "ops-people-abstract-contractors"
            }
          ]
        }
      ]
    },
    {
      "id": "work-items-concrete",
      "abstractType": "WorkItems",
      "concreteObjectTypes": [
        "work-items"
      ],
      "union": false
    },
    {
      "id": "procedures-concrete",
      "abstractType": "Procedures",
      "concreteObjectTypes": [
        "procedures"
      ],
      "union": false
    },
    {
      "id": "activity-events-concrete",
      "abstractType": "ActivityEvents",
      "concreteObjectTypes": [
        "activity-events"
      ],
      "union": false
    },
    {
      "id": "knowx-entity-union",
      "abstractType": "KnowXEntity",
      "concreteObjectTypes": [
        "employees",
        "contractors",
        "work-items",
        "assertions"
      ],
      "notes": "KnowXEntity = subjects that may carry knowx. No abstract records."
    }
  ],
  "relationshipDefinitions": [
    {
      "id": "people-assigned-to-work-items",
      "name": "People assigned to work items",
      "meaning": "A person (employee or contractor) is assigned to perform a work item",
      "directionality": "directed",
      "from": {
        "abstractType": "People",
        "path": "assignedWorkItems"
      },
      "to": {
        "abstractType": "WorkItems",
        "path": "assignedPeople"
      },
      "discoveryRules": [
        {
          "id": "from-source-assignee",
          "kind": "source-field",
          "sourcePath": "assigneeId",
          "notes": "ops-source work-items.assigneeId resolves across employees and contractors"
        }
      ]
    },
    {
      "id": "work-items-use-procedures",
      "name": "Work items use procedures",
      "meaning": "A work item follows one or more reusable procedures",
      "directionality": "directed",
      "from": {
        "abstractType": "WorkItems",
        "path": "usedProcedures"
      },
      "to": {
        "abstractType": "Procedures",
        "path": "usedByWorkItems"
      },
      "discoveryRules": [
        {
          "id": "from-source-procedure-ids",
          "kind": "source-field",
          "sourcePath": "procedureIds"
        }
      ]
    },
    {
      "id": "activity-events-about-work-items",
      "name": "Activity events about work items",
      "meaning": "An activity event reports progress on a work item",
      "directionality": "directed",
      "from": {
        "abstractType": "ActivityEvents",
        "path": "aboutWorkItems"
      },
      "to": {
        "abstractType": "WorkItems",
        "path": "activityEvents"
      },
      "discoveryRules": [
        {
          "id": "from-source-work-item-id",
          "kind": "source-field",
          "sourcePath": "workItemId"
        }
      ]
    },
    {
      "id": "work-items-depend-on-work-items",
      "name": "Work items depend on work items",
      "meaning": "A work item cannot complete until another work item completes",
      "directionality": "directed",
      "from": {
        "abstractType": "WorkItems",
        "path": "dependsOn"
      },
      "to": {
        "abstractType": "WorkItems",
        "path": "dependedOnBy"
      },
      "discoveryRules": [
        {
          "id": "from-source-depends-on",
          "kind": "source-field",
          "sourcePath": "dependsOnIds"
        }
      ]
    },
    {
      "id": "people-collaborate-with-people",
      "name": "People collaborate with people",
      "meaning": "Two people collaborate on operational work",
      "directionality": "undirected",
      "from": {
        "abstractType": "People",
        "path": "collaborators"
      },
      "to": {
        "abstractType": "People",
        "path": "collaborators"
      },
      "discoveryRules": [
        {
          "id": "from-source-collaborator-ids",
          "kind": "source-field",
          "sourcePath": "collaboratorIds"
        }
      ]
    },
    {
      "id": "assigned-to",
      "name": "Assigned to",
      "meaning": "Person or subject assigned to a work item",
      "directionality": "directed",
      "from": {
        "abstractType": "People",
        "path": "assignedWorkItems"
      },
      "to": {
        "abstractType": "WorkItems",
        "path": "assignedPeople"
      },
      "discoveryRules": [
        {
          "id": "from-knowx-refs",
          "kind": "source-field",
          "sourcePath": "refs"
        }
      ]
    },
    {
      "id": "blocked-by",
      "name": "Blocked by",
      "meaning": "Work item blocked by another work item",
      "directionality": "directed",
      "from": {
        "abstractType": "WorkItems",
        "path": "blockedBy"
      },
      "to": {
        "abstractType": "WorkItems",
        "path": "blocks"
      },
      "discoveryRules": [
        {
          "id": "from-knowx-refs",
          "kind": "source-field",
          "sourcePath": "refs"
        }
      ]
    }
  ],
  "mappings": [
    {
      "id": "ops-source-employees-to-raw",
      "sourceId": "ops-source",
      "endpoint": "/employees",
      "objectType": "employees",
      "contentType": "raw",
      "mode": "knowledge",
      "purpose": "source",
      "map": {
        "recordId": {
          "op": "path",
          "path": "id",
          "required": true
        },
        "objectType": {
          "op": "constant",
          "value": "employees"
        },
        "data.displayName": {
          "op": "path",
          "path": "name",
          "required": true
        },
        "data.role": {
          "op": "path",
          "path": "role",
          "required": true
        },
        "data.email": {
          "op": "path",
          "path": "email"
        },
        "data.sourceId": {
          "op": "path",
          "path": "id"
        }
      }
    },
    {
      "id": "ops-source-contractors-to-raw",
      "sourceId": "ops-source",
      "endpoint": "/contractors",
      "objectType": "contractors",
      "contentType": "raw",
      "mode": "knowledge",
      "purpose": "source",
      "map": {
        "recordId": {
          "op": "path",
          "path": "id",
          "required": true
        },
        "objectType": {
          "op": "constant",
          "value": "contractors"
        },
        "data.displayName": {
          "op": "path",
          "path": "name",
          "required": true
        },
        "data.role": {
          "op": "path",
          "path": "role",
          "required": true
        },
        "data.vendor": {
          "op": "path",
          "path": "vendor"
        },
        "data.sourceId": {
          "op": "path",
          "path": "id"
        }
      }
    },
    {
      "id": "ops-source-work-items-to-raw",
      "sourceId": "ops-source",
      "endpoint": "/work-items",
      "objectType": "work-items",
      "contentType": "raw",
      "mode": "knowledge",
      "purpose": "source",
      "map": {
        "data": {
          "op": "path",
          "path": "$"
        }
      }
    },
    {
      "id": "ops-source-procedures-to-raw",
      "sourceId": "ops-source",
      "endpoint": "/procedures",
      "objectType": "procedures",
      "contentType": "raw",
      "mode": "knowledge",
      "purpose": "source",
      "map": {
        "data": {
          "op": "path",
          "path": "$"
        }
      }
    },
    {
      "id": "ops-source-work-item-context",
      "sourceId": "ops-source",
      "endpoint": "/work-items/:id/context",
      "objectType": "work-items",
      "contentType": "raw",
      "mode": "context",
      "trigger": "on-demand",
      "purpose": "source",
      "map": {
        "data": {
          "op": "path",
          "path": "$"
        }
      }
    },
    {
      "id": "ops-people-abstract-employees",
      "purpose": "abstract",
      "abstractType": "People",
      "objectType": "employees",
      "contentType": "snapshots",
      "map": {
        "title": {
          "expr": {
            "op": "path",
            "path": "data.displayName"
          },
          "required": true
        },
        "role": {
          "expr": {
            "op": "path",
            "path": "data.role"
          },
          "required": true
        },
        "lens": {
          "op": "constant",
          "value": "people"
        }
      },
      "reverse": {
        "title": {
          "expr": {
            "op": "path",
            "path": "title"
          },
          "targetPath": "data.displayName"
        }
      }
    },
    {
      "id": "ops-people-abstract-contractors",
      "purpose": "abstract",
      "abstractType": "People",
      "objectType": "contractors",
      "contentType": "snapshots",
      "map": {
        "title": {
          "expr": {
            "op": "path",
            "path": "data.displayName"
          },
          "required": true
        },
        "role": {
          "expr": {
            "op": "path",
            "path": "data.role"
          },
          "required": true
        },
        "lens": {
          "op": "constant",
          "value": "people"
        }
      },
      "reverse": {
        "title": {
          "expr": {
            "op": "path",
            "path": "title"
          },
          "targetPath": "data.displayName"
        }
      }
    },
    {
      "id": "ops-work-items-completion-priority",
      "purpose": "completion",
      "objectType": "work-items",
      "contentType": "snapshots",
      "map": {
        "data.priority": {
          "op": "coalesce",
          "exprs": [
            {
              "op": "path",
              "path": "priority"
            },
            {
              "op": "constant",
              "value": "normal"
            }
          ]
        },
        "data.title": {
          "op": "path",
          "path": "title"
        }
      }
    }
  ],
  "views": [
    {
      "id": "ops-work-items-list",
      "kind": "list",
      "objectType": "work-items",
      "title": "Work items",
      "columns": [
        "concept.title",
        "data.status",
        "data.priority"
      ]
    },
    {
      "id": "ops-work-items-item",
      "kind": "item",
      "objectType": "work-items",
      "title": "Work item",
      "sections": [
        "concept",
        "data",
        "workflow",
        "analysis",
        "decisions"
      ]
    },
    {
      "id": "ops-people-list",
      "kind": "list",
      "abstractType": "People",
      "title": "People",
      "columns": [
        "concept.title",
        "objectType",
        "data.role"
      ]
    },
    {
      "id": "ops-work-item-expand-people",
      "kind": "relationship-expansion",
      "objectType": "work-items",
      "relationshipDefinitionId": "people-assigned-to-work-items",
      "direction": "to-from"
    }
  ],
  "writes": [
    {
      "id": "ops-employees-snapshots",
      "objectType": "employees",
      "contentType": "snapshots",
      "identity": {
        "primaryKind": "employeeId",
        "issuer": "ops-source"
      }
    },
    {
      "id": "ops-contractors-snapshots",
      "objectType": "contractors",
      "contentType": "snapshots",
      "identity": {
        "primaryKind": "contractorId",
        "issuer": "ops-source"
      }
    },
    {
      "id": "ops-work-items-snapshots",
      "objectType": "work-items",
      "contentType": "snapshots",
      "identity": {
        "primaryKind": "workItemId",
        "issuer": "ops-source"
      }
    },
    {
      "id": "ops-procedures-snapshots",
      "objectType": "procedures",
      "contentType": "snapshots",
      "identity": {
        "primaryKind": "procedureId",
        "issuer": "ops-source"
      }
    },
    {
      "id": "ops-activity-events-snapshots",
      "objectType": "activity-events",
      "contentType": "snapshots",
      "identity": {
        "primaryKind": "activityEventId",
        "issuer": "ops-source"
      }
    }
  ],
  "sources": [
    {
      "id": "ops-source",
      "name": "Fieldstone ops fixture source",
      "kind": "rest-fixture",
      "baseUrlEnv": "OPS_SOURCE_URL",
      "defaultBaseUrl": "http://127.0.0.1:7099",
      "credentialRef": "ops-source-local",
      "connectorRef": "ops-fixture",
      "endpoints": [
        "/employees",
        "/contractors",
        "/work-items",
        "/activity-events",
        "/procedures",
        "/work-items/:id/context"
      ],
      "pagination": {
        "style": "cursor",
        "defaultPageSize": 50
      },
      "retention": {
        "context": {
          "ttlSeconds": 3600,
          "discardOnWorkCompletion": true
        }
      },
      "routes": [
        {
          "endpoint": "/procedures",
          "objectType": "procedures",
          "dataCategory": "knowledge",
          "identityPath": "id",
          "primaryKind": "procedureId",
          "modes": [
            "knowledge"
          ],
          "pageSize": 2
        },
        {
          "endpoint": "/work-items/:id/context",
          "objectType": "work-items",
          "dataCategory": "entity",
          "identityPath": "workItemId",
          "primaryKind": "workItemId",
          "modes": [
            "context"
          ]
        },
        {
          "endpoint": "/work-items",
          "objectType": "work-items",
          "dataCategory": "entity",
          "identityPath": "id",
          "primaryKind": "workItemId",
          "modes": [
            "knowledge"
          ]
        },
        {
          "endpoint": "/employees",
          "objectType": "employees",
          "dataCategory": "entity",
          "identityPath": "id",
          "primaryKind": "employeeId",
          "modes": [
            "knowledge"
          ]
        },
        {
          "endpoint": "/contractors",
          "objectType": "contractors",
          "dataCategory": "entity",
          "identityPath": "id",
          "primaryKind": "contractorId",
          "modes": [
            "knowledge"
          ]
        },
        {
          "endpoint": "/activity-events",
          "objectType": "activity-events",
          "dataCategory": "event",
          "identityPath": "id",
          "primaryKind": "activityEventId",
          "modes": [
            "knowledge"
          ]
        }
      ]
    }
  ],
  "services": [
    {
      "id": "ops-normalize",
      "name": "Normalize records",
      "description": "Logical normalize capability for ops knowledge pull",
      "capabilities": [
        "normalize"
      ],
      "inputs": [
        {
          "id": "raw-records",
          "schemaRef": "memorix-record/raw"
        }
      ],
      "outputs": [
        {
          "id": "normalized-records",
          "schemaRef": "memorix-record/snapshots"
        }
      ],
      "invocation": {
        "kind": "worker",
        "operation": "normalize"
      }
    },
    {
      "id": "ops-completion",
      "name": "Field completion",
      "capabilities": [
        "completion"
      ],
      "inputs": [
        {
          "id": "snapshot",
          "schemaRef": "memorix-record/snapshots"
        }
      ],
      "outputs": [
        {
          "id": "completed",
          "schemaRef": "memorix-record/snapshots"
        }
      ],
      "invocation": {
        "kind": "worker",
        "operation": "complete"
      }
    }
  ],
  "pipelines": [
    {
      "id": "ops-knowledge-pull",
      "name": "Scheduled knowledge pull from ops-source",
      "trigger": "scheduled",
      "mode": "knowledge",
      "steps": [
        {
          "id": "pull",
          "kind": "memory-pull",
          "sourceId": "ops-source"
        },
        {
          "id": "land-raw",
          "kind": "write-raw"
        },
        {
          "id": "normalize",
          "kind": "normalize"
        },
        {
          "id": "promote",
          "kind": "promote-snapshots"
        },
        {
          "id": "normalize-svc",
          "kind": "invoke-service",
          "serviceId": "ops-normalize"
        },
        {
          "id": "complete",
          "kind": "completion",
          "serviceId": "ops-completion",
          "mappingId": "ops-work-items-completion-priority",
          "completionPolicy": {
            "mode": "fill-missing",
            "maxFields": 20
          }
        }
      ]
    },
    {
      "id": "ops-context-pull",
      "name": "On-demand work-item context pull",
      "trigger": "on-demand",
      "mode": "context",
      "steps": [
        {
          "id": "pull",
          "kind": "memory-pull",
          "sourceId": "ops-source"
        },
        {
          "id": "land-raw",
          "kind": "write-raw"
        },
        {
          "id": "normalize-context",
          "kind": "normalize-context"
        },
        {
          "id": "ttl",
          "kind": "apply-ttl"
        }
      ]
    },
    {
      "id": "ops-relationship-build",
      "name": "Discover and write lightweight relationships",
      "trigger": "explicit",
      "steps": [
        {
          "id": "discover",
          "kind": "relationship-discover"
        },
        {
          "id": "write",
          "kind": "relationship-write"
        },
        {
          "id": "verify",
          "kind": "relationship-verify"
        }
      ]
    },
    {
      "id": "ops-analysis",
      "name": "Work-item analysis sibling",
      "trigger": "explicit",
      "steps": [
        {
          "id": "analyze",
          "kind": "analysis"
        },
        {
          "id": "write-sibling",
          "kind": "write-content",
          "contentType": "analysis"
        }
      ]
    },
    {
      "id": "ops-workflow",
      "name": "Work-item workflow sibling",
      "trigger": "explicit",
      "steps": [
        {
          "id": "sync-workflow",
          "kind": "workflow-sync"
        },
        {
          "id": "write-sibling",
          "kind": "write-content",
          "contentType": "workflow"
        }
      ]
    }
  ],
  "schedules": [
    {
      "id": "ops-knowledge-hourly",
      "pipelineId": "ops-knowledge-pull",
      "cron": "0 * * * *",
      "timezone": "UTC",
      "enabled": true
    }
  ],
  "kindDeclarations": [
    {
      "id": "acme.ui-tabs",
      "name": "UI Tabs",
      "description": "Client-owned tab layouts for object detail screens (store/resolve only).",
      "schemaVersion": "acme.uiTabs.v1",
      "itemSchema": {
        "type": "object",
        "required": [
          "id",
          "title",
          "objectType"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "objectType": {
            "type": "string"
          },
          "tabs": {
            "type": "array"
          }
        }
      }
    }
  ],
  "extensions": {
    "acme.ui-tabs": [
      {
        "id": "employee-detail",
        "title": "Employee detail",
        "objectType": "employees",
        "schemaVersion": "acme.uiTabs.v1",
        "tabs": [
          {
            "id": "overview",
            "label": "Overview"
          },
          {
            "id": "history",
            "label": "History"
          }
        ]
      }
    ]
  }
}
