Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/mantis-assistant-a2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Mantis Assistant A2

on:
push:
paths:
- "projects/biomemetics/labs/mantis/assistant/hierarchy/**"
- ".github/workflows/mantis-assistant-a2.yml"
pull_request:
paths:
- "projects/biomemetics/labs/mantis/assistant/hierarchy/**"
- ".github/workflows/mantis-assistant-a2.yml"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
agent-tree-limits:
name: agent-tree-limits
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: projects/biomemetics/labs/mantis/assistant/hierarchy
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: projects/biomemetics/labs/mantis/assistant/hierarchy/package-lock.json

- name: Install dependencies
run: npm ci

- name: Typecheck
run: npm run typecheck

- name: Test
run: npm test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
51 changes: 51 additions & 0 deletions projects/biomemetics/labs/mantis/assistant/hierarchy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Constrained specialist hierarchy

Package `@tmnl/mantis-assistant-hierarchy` is the A2 inspectable registry, delegation policy, and thread-scoped assistant-memory ledger. It sits behind `MantisController`. This package does not edit the A0 harness.

A later controller imports `openHierarchy` and calls `delegate` / `remember`. This PR does not patch that controller.

## Use

```ts
import { openHierarchy, interpretationYield } from '@tmnl/mantis-assistant-hierarchy';

const hierarchy = openHierarchy({
clock: { now: () => '2026-08-21T00:00:00.000Z' },
});

const attempt = hierarchy.delegate({
specialist: 'care-source',
mode: 'care',
threadId: 'care:fixture-cup-01:conversation-01',
careSubjectId: 'care.fixture-cup-01',
goal: 'source feeding advice',
transcriptExcerpt: 'small mantis in a cup',
});
```

`openHierarchy` fails closed if a specialist is missing, if `forked` is not `false`, if a tool list contains `device-command`, or if observational-memory policy enables resource-scoped OM.

Default `delegate` is a policy dry-run. It does not call a model. It does not bind CopilotKit. A missing `runtimeUrl` is not a gate.

## Registry

Nine specialists, one JSON manifest each under `manifests/`:

`care-source`, `observation-extractor`, `taxon-hypothesis`, `supply-transit`, `terrarium-diagnostician`, `evidence-curator`, `workflow-composer`, `tool-assessor`, `adversarial-reviewer`.

Loaded rows have `forked: false` as a literal. Taxon output is `interpretationYield`, which forces `confirmed: false`. Care subjects are not minted here.

## Memory

`remember` stamps `recordClass: assistant-memory`, redacts address/tokens, and appends. A canonical correction marks older rows `superseded` and leaves their text in place. `forget` exports a tombstone without text. Observer/reflector live cycles stay `QUARANTINED_UPSTREAM`.

## Check

```text
cd projects/biomemetics/labs/mantis/assistant/hierarchy
npm ci
npm run typecheck
npm test
```

`.github/workflows/mantis-assistant-a2.yml` runs those same commands.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"schemaVersion": "1.0.0",
"kind": "DelegationRejectDataset",
"cases": [
{
"id": "forked-true",
"input": {
"specialist": "care-source",
"mode": "care",
"threadId": "care:fixture-cup-01:conversation-01",
"careSubjectId": "care.fixture-cup-01",
"goal": "advice",
"transcriptExcerpt": "cup",
"forked": true
},
"reason": "forked-prohibited"
},
{
"id": "mode-elevation",
"input": {
"specialist": "care-source",
"mode": "care",
"threadId": "care:fixture-cup-01:conversation-01",
"careSubjectId": "care.fixture-cup-01",
"goal": "advice",
"transcriptExcerpt": "cup",
"targetMode": "review"
},
"reason": "privilege-escalation"
},
{
"id": "self-admit-assessor",
"input": {
"specialist": "tool-assessor",
"mode": "review",
"threadId": "care:fixture-cup-01:conversation-01",
"careSubjectId": "care.fixture-cup-01",
"goal": "assay",
"transcriptExcerpt": "candidate tool",
"admit": true
},
"reason": "self-review"
},
{
"id": "taxon-confirmed",
"input": {
"specialist": "taxon-hypothesis",
"mode": "research",
"threadId": "care:fixture-cup-01:conversation-01",
"careSubjectId": "care.fixture-cup-01",
"goal": "identify",
"transcriptExcerpt": "photo notes",
"confirmed": true
},
"reason": "confirmed-taxon"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"schemaVersion": "1.0.0",
"kind": "OmSupersessionDataset",
"threadId": "care:fixture-cup-01:conversation-01",
"first": {
"kind": "conversation-observation",
"text": "Feeding was logged."
},
"correction": {
"kind": "canonical-correction",
"text": "Feeding was not logged.",
"canonicalRef": { "kind": "CareEvent", "id": "event.fixture-offer-01" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"schemaVersion": "1.0.0",
"kind": "YieldSeparationDataset",
"taxon": {
"kind": "interpretation",
"recordClass": "interpretation",
"confirmed": false
},
"assessor": { "kind": "assay-report", "admitted": false },
"curator": { "kind": "evidence-draft", "accepted": false },
"reviewer": { "kind": "attack-report", "edits": false }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"schemaVersion": "1.0.0",
"kind": "SpecialistManifest",
"id": "care-source",
"purpose": "forked true must fail parse",
"sourceClass": "reviewed-source",
"modes": ["care"],
"tools": ["care-source-read"],
"budget": { "maxSteps": 4, "timeoutMs": 30000, "maxTokens": 4000 },
"contextFilter": {
"stripExactLocation": true,
"stripSecrets": true,
"stripUnrelatedMedia": true,
"stripRawToolDumps": true,
"preserveSourceStatus": true,
"preserveCorrelationIds": true,
"includeFullTranscript": false
},
"forbiddenActions": ["diagnose", "publish", "actuate"],
"yieldKind": "care-advice-draft",
"forked": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recordClass": "observed",
"threadId": "care:fixture-cup-01:conversation-01",
"kind": "conversation-observation",
"text": "this must not become care truth"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"specialist": "care-source",
"mode": "care",
"threadId": "care:fixture-cup-01:conversation-01",
"careSubjectId": "care.fixture-cup-01",
"goal": "advice",
"transcriptExcerpt": "cup",
"sourceStatus": "reviewed-source"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Read-only copies of A0 files from PR 100, branch cursor/mantis-assistant-a0-9bdb, a02d73e8f340b672a3ca057945cdbea01f90cac5.

This directory is not schema authority once assistant/contracts and assistant/policies exist on the same checkout. Prefer those live paths at runtime. Fall back here so this slice verifies without merging A0.

Do not rewrite A0 files. Do not treat this copy as a pin change.

Mastra core recorded from A0 src/pins.ts: 1.61.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:specimendb:biomemetics:mantis:assistant:contracts:assistant-run:v1",
"title": "Mantis assistant run receipt",
"description": "Pinned package, model, config, tool, memory, and workflow versions for one assistant run. Observational memory on this receipt is assistant-memory, never observation or evidence.",
"type": "object",
"additionalProperties": false,
"required": [
"schemaVersion",
"kind",
"runId",
"startedAt",
"mode",
"resourceId",
"threadId",
"versions",
"memoryRecordClass"
],
"properties": {
"$schema": { "type": "string" },
"schemaVersion": { "const": "1.0.0" },
"kind": { "const": "AssistantRun" },
"runId": {
"type": "string",
"pattern": "^run\\.[a-z][a-z0-9.-]*$"
},
"traceId": { "type": "string", "minLength": 1 },
"startedAt": { "type": "string", "format": "date-time" },
"endedAt": { "type": "string", "format": "date-time" },
"mode": {
"enum": [
"care",
"observe",
"research",
"terrarium-read",
"review",
"service-sim"
]
},
"resourceId": { "type": "string", "minLength": 1 },
"threadId": {
"type": "string",
"pattern": "^care:[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$"
},
"careSubjectId": {
"type": "string",
"pattern": "^care\\.[a-z][a-z0-9.-]*$"
},
"agentId": { "type": "string", "minLength": 1 },
"workflowId": { "type": "string", "minLength": 1 },
"memoryRecordClass": { "const": "assistant-memory" },
"versions": {
"type": "object",
"additionalProperties": false,
"required": [
"mastraCore",
"copilotkitRuntime",
"aguiMastra",
"effect",
"typescript",
"model",
"controllerConfig",
"tools",
"memory",
"workflow"
],
"properties": {
"mastraCore": { "type": "string", "minLength": 1 },
"copilotkitRuntime": { "type": "string", "minLength": 1 },
"aguiMastra": { "type": "string", "minLength": 1 },
"effect": { "type": "string", "minLength": 1 },
"typescript": { "type": "string", "minLength": 1 },
"model": { "type": "string", "minLength": 1 },
"controllerConfig": { "type": "string", "minLength": 1 },
"tools": { "type": "string", "minLength": 1 },
"memory": { "type": "string", "minLength": 1 },
"workflow": { "type": "string", "minLength": 1 }
}
},
"cost": {
"type": "object",
"additionalProperties": false,
"properties": {
"inputTokens": { "type": "integer", "minimum": 0 },
"outputTokens": { "type": "integer", "minimum": 0 }
}
}
},
"unevaluatedProperties": false
}
Loading
Loading