Files
boshu2__agentops/schemas/session-bootstrap.v1.schema.json
T
Bo 853d781e66 feat(memory): inject canon memory during session bootstrap (#740)
## Summary

Implements ag-11bi W2.3 canon-gated T2 bootstrap memory for `ao session
bootstrap`.

- Selects only canon-promoted established learnings plus high/critical
severity canon anti-patterns from `.agents/canon/learnings`.
- Ranks by `utility * confidence * freshness`, caps selection at 1200
estimated tokens, and warns on stderr when eligible canon memory exceeds
the cap.
- Computes reach through the existing search reach helper, so
established canon memory surfaces as `reach=always` without author-set
reach.
- Emits the memory payload in JSON/robot output and prints selected
memory in the default human bootstrap output.
- Extends `schemas/session-bootstrap.v1.schema.json` and tests the
filter, budget, warning, and human-output paths.

## Validation

Focused checks:

- `go test ./cmd/ao -run 'TestSessionBootstrap'`
- `go test ./internal/search ./internal/types`
- `git diff --check`
- `python3 -m json.tool schemas/session-bootstrap.v1.schema.json`

Required regen:

- `bash scripts/regen-all.sh` regenerated artifacts but exited on the
known CMDAO `wiki query` parity red.

Required pre-push after rebase:

- `PRE_PUSH_FAIL_FAST=false bash scripts/pre-push-gate.sh` completed
with 4 known non-diff failures:
  - test-fixture parity: `scripts/gc-stale-worktrees.sh`
  - worktree disposition: canonical root dirty/untracked operator state
  - corpus freshness: newest local snapshot older than threshold
- contract canaries: known `agentops-core.pre-push-gate-governance` Bats
failure

Diff-relevant gates passed in the pre-push run, including changed-scope
Go race tests, command/test pairing, goals validate, registry drift, CLI
docs parity, command-surface matrix canary, schema checks, CI policy
parity, and shellcheck.

## Review Ask

Requesting cross-model ACK/AMEND/BLOCK before merge. Primary attacks to
run:

- Does any non-canon or candidate/provisional learning enter bootstrap
memory?
- Can the 1200-token cap be bypassed or hidden from callers?
- Does the default human path actually expose the selected memory, not
just JSON?
- Is the generated CLI-surface drift acceptable as regen output on this
branch?

No self-grade for merge.
2026-06-04 23:31:05 -04:00

124 lines
4.7 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/boshu2/agentops/schemas/session-bootstrap.v1.schema.json",
"title": "Session Bootstrap Status v1",
"description": "Canonical machine-readable status report emitted by `ao session bootstrap` (soc-vuu6.25). Every agent spawned into an AgentOps repo runs `ao session bootstrap` first; this schema guarantees the report shape is identical across runtimes so swarm coordination layers can compare starting frames.",
"type": "object",
"required": [
"agents_md_read",
"agents_siblings_read",
"onboard_phase",
"ready_beads_count",
"mail_unread_count",
"runtime",
"started_at",
"bootstrap_version",
"bootstrap_memory",
"bootstrap_memory_budget_tokens",
"bootstrap_memory_used_tokens",
"bootstrap_memory_omitted_count",
"bootstrap_memory_over_budget"
],
"properties": {
"agents_md_read": {
"type": "boolean",
"description": "True when AGENTS.md is present and readable at the repo root."
},
"agents_siblings_read": {
"type": "array",
"description": "Post-soc-vuu6.3 tiered-split siblings that were detected at the repo root. Empty when no siblings exist (pre-split repo or non-AgentOps project).",
"items": {
"type": "string",
"enum": [
"AGENTS-WORKFLOW.md",
"AGENTS-CI.md",
"AGENTS-CODEX.md",
"AGENTS-RUNTIME.md"
]
}
},
"onboard_phase": {
"type": "string",
"description": "Result of the `ao onboard --auto` substep. `skipped:not-implemented` until soc-vuu6.9 lands; `skipped:error` if the subprocess fails; a free-form phase string when onboard runs.",
"examples": [
"skipped:not-implemented",
"skipped:error",
"ran:no-phase",
"fresh",
"task-routed"
]
},
"ready_beads_count": {
"type": ["integer", "null"],
"minimum": 0,
"description": "Number of items returned by `bd ready --json`. Null when bd is missing or the command errors (fail-open contract — bootstrap does not abort)."
},
"mail_unread_count": {
"type": ["integer", "null"],
"minimum": 0,
"description": "Number of unread messages from mcp-agent-mail. Null when the MCP server is absent, the probe is skipped (--no-mail), or the integration is not yet wired."
},
"runtime": {
"type": "string",
"description": "Detected agent runtime. Reads AGENTOPS_RPI_RUNTIME first, then CLAUDECODE / CODEX_CLI, then falls back to GOOS.",
"examples": ["claude-code", "codex", "linux", "darwin"]
},
"started_at": {
"type": "string",
"format": "date-time",
"description": "UTC RFC3339 timestamp captured at the start of the bootstrap run."
},
"bootstrap_version": {
"type": "string",
"const": "v1",
"description": "Schema version. Increment in a new schema file when fields change shape."
},
"bootstrap_memory": {
"type": "array",
"description": "Canon-gated T2 memory injected at bootstrap: canon-promoted established learnings plus high-severity canon anti-patterns, ranked and capped below the normal ao inject budget.",
"items": {
"type": "object",
"required": ["id", "title", "content", "source", "maturity", "reach", "score", "tokens"],
"properties": {
"id": { "type": "string" },
"title": { "type": "string" },
"content": { "type": "string" },
"source": { "type": "string" },
"maturity": { "type": "string" },
"reach": {
"type": "string",
"enum": ["bead", "pull", "always"]
},
"score": { "type": "number" },
"tokens": {
"type": "integer",
"minimum": 1
}
},
"additionalProperties": false
}
},
"bootstrap_memory_budget_tokens": {
"type": "integer",
"const": 1200,
"description": "Hard token budget for bootstrap_memory; intentionally below DefaultInjectMaxTokens (1500)."
},
"bootstrap_memory_used_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 1200,
"description": "Approximate tokens used by selected bootstrap_memory items."
},
"bootstrap_memory_omitted_count": {
"type": "integer",
"minimum": 0,
"description": "Number of eligible canon memory items omitted because the 1200-token bootstrap budget was full."
},
"bootstrap_memory_over_budget": {
"type": "boolean",
"description": "True when eligible canon memory exceeded the hard budget and lower-ranked items were omitted with a stderr warning."
}
},
"additionalProperties": false
}