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
44 changes: 27 additions & 17 deletions .agents/skills/retrospective/SKILL.md

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions .agents/skills/retrospective/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,29 @@ Workstation-local, cross-project, confidence-scored, decaying.

`project` is a **known-inconsistent field** — the documentation and the live data have disagreed.
Call `memory_sessions()` first and reuse whatever identifier the current session was actually
registered under; if none exists, **omit it** rather than invent one. Detail: Brain `02a16f`.
registered under; if none exists, **omit it** rather than invent one. Detail, on a PP Brain home: item `02a16f`.

## PP Brain
## Org knowledge store

Company-wide, cross-repo, cross-machine, human-readable — the only layer a colleague can read.
Which store that is comes from `bin/fm-knowledge-store.sh read` (`SKILL.md`, "Resolve the org store first"); use only the section below that matches its `backend`.
Search before writing in every backend: the convention is to link, not fork.

- Search before writing. The convention is to link, not fork.
### `backend=rag` — the RAG (`rag_qdrant_server`)

- Recall: `query_rag_hybrid(query_text, user_roles)`, falling back to `query_rag` with the same arguments.
Pass `user_roles` even when empty.
- Write: `ingest_document(chunk_text, metadata_json, user_roles)`.
`metadata_json` is a JSON string and must carry `document_type`, one of `guida` | `policy` | `info` | `ticket`; any other value is rejected.
A retrospective learning is normally `info`, and a stable convention a colleague must follow is `guida`.
Also set `file_path` (a stable logical path such as `retrospective/<repo>/<slug>`), a `slug`, `tags`, and `document_date` (today), so the item is findable and linkable later.
`user_roles` sets who can read it; keep it internal (for example `admin,dev`), never public.
- The identifier to record in the report is the `slug` the call accepted, or whatever id it returned; no id back means the write is not claimed.
- Keep `chunk_text` focused with the key information first, and point at the canonical file rather than embedding it wholesale.

### `backend=pp-brain` — PP Brain

- Recall: `search_knowledge(query, prompt)`, with **both** fields populated.
- `add_knowledge(title, summary, body, tags, links)` — title >= 5 chars, summary >= 20 (aim ~500,
key information **first**, because it is sentence-truncated server-side), body >= 50. Tags are
namespaced: `type:pattern`, `domain:payment`. Default `sync: true` returns
Expand All @@ -85,3 +101,8 @@ Company-wide, cross-repo, cross-machine, human-readable — the only layer a col
- Very large payloads have failed JSON validation. Keep the body focused and point at the canonical
file rather than embedding it wholesale.
- A 422 is the sensitivity gate. What it refuses is in `SKILL.md`.

### `backend=other`

Recall through the `search=` instructions the command printed.
No write contract is known here, so every org-store write stays pending in the report, naming the store.
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ config/calm Pi Calm presentation preference; LOCAL, gitignored, and not inhe
config/startup-memory-budget primary-authoritative per-home startup-memory budget; LOCAL, gitignored, materialized as 7,500 estimated tokens by locked primary bootstrap and inherited into secondmate homes; see docs/configuration.md "Startup memory budget"
config/herdr-presentation-spaces optional "off" opt-out from, or "on" opt-in to, Herdr's default-on disposable single-task visual projection, which is unconfigured-default-on only at or above a Herdr version floor; LOCAL, gitignored; inherited by secondmate homes; see docs/herdr-backend.md "Presentation spaces"
config/trace-context optional presence flag enabling default-off native W3C trace-context propagation to spawned agents; LOCAL, gitignored; inherited by secondmate homes; see docs/configuration.md "Trace context propagation" and docs/trace-context.md
config/knowledge-store optional two-line knowledge-store name (line 1) and search-instructions clause (line 2) for generated crewmate briefs; LOCAL, gitignored; absent keeps bin/fm-brief.sh's historical upstream RAG wording; inherited by secondmate homes; see docs/configuration.md "Knowledge store naming (config/knowledge-store)"
config/knowledge-store optional knowledge-store name (line 1), search-instructions clause (line 2), and optional backend key (line 3) for generated crewmate briefs and /retrospective; LOCAL, gitignored; absent keeps bin/fm-brief.sh's historical upstream RAG wording; inherited by secondmate homes; see docs/configuration.md "Knowledge store naming (config/knowledge-store)"
config/cmux-socket-password optional cmux control-socket password; LOCAL, gitignored; read fresh on every cmux CLI call and passed through without ever overriding an operator's own ambient CMUX_SOCKET_PASSWORD when absent (docs/cmux-backend.md "Setup")
config/wedge-alarm optional away-mode wedge-alarm active-alert directives; LOCAL, gitignored; absent means auto (macOS Notification Center when available); see docs/wedge-alarm.md
config/skill-sync-exclude optional rsync --exclude patterns for the remote secondmate skill sync, one per non-empty, non-comment line; LOCAL, gitignored; absent uses the built-in default set; a remote-launch-only best-effort step outside the FM_INHERITABLE_CONFIG allowlist, NOT inherited by secondmate homes; see docs/configuration.md "Remote secondmate skill sync (config/skill-sync-exclude)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Claude and grok use the slash form shown here; codex uses the same names with `$
| `/bearings` | Generate a concise four-section chat digest from bounded local fleet and registered-secondmate state; use `/bearings file` to also replace today's dated report in `data/`, and add `include PRs` when live PR enrichment is wanted |
| `/updatefirstmate` | Self-update the running firstmate and its secondmates to the latest from origin with fast-forward-only pulls, then re-read instructions and nudge secondmates |
| `/stow` | Sweep the session for uncaptured durable knowledge, persist the open work records this session knows are unfiled or now wrong, curate tiered startup memory with decay and cold archival, enforce each home's budget or surface the required decision, cascade to registered second mates, and report what is safe to reset |
| `/retrospective` | Analyze the active session, route durable learnings to CLAUDE.md/AGENTS.md, agentmemory, and PP Brain by blast radius, and write a dated report; see [`.agents/skills/retrospective/SKILL.md`](.agents/skills/retrospective/SKILL.md) |
| `/retrospective` | Analyze the active session, route durable learnings to CLAUDE.md/AGENTS.md, agentmemory, and the org-wide knowledge store this home is configured with (the RAG or PP Brain) by blast radius, and write a dated report; see [`.agents/skills/retrospective/SKILL.md`](.agents/skills/retrospective/SKILL.md) |

Bearings invocation examples:

Expand Down
35 changes: 11 additions & 24 deletions bin/fm-brief.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
# findings instead go through the note: CANDIDATE status line (Rule 4;
# AGENTS.md section 6) for firstmate to route.
# Ship and scout briefs include a Grounding section requiring a search of the
# configured knowledge store (config/knowledge-store; absent defaults to the
# RAG's query_rag_hybrid/query_rag tool on rag_qdrant_server, byte-identical to
# configured knowledge store (config/knowledge-store, resolved by
# bin/fm-knowledge-store-lib.sh; absent defaults to the RAG, byte-identical to
# this script's historical wording) and the local memory store before the
# first substantive action, a repeated search whenever a later obstacle or
# subject comes up since latency is the only cost, a check of the configured
Expand Down Expand Up @@ -186,29 +186,16 @@ fi
PROJECTS="${FM_PROJECTS_OVERRIDE:-$FM_HOME/projects}"

# Grounding wording is named by this home's optional config/knowledge-store
# (docs/configuration.md): line 1 is the store's name as it reads in worker
# text, line 2 is the search-instructions clause inserted in parentheses after
# it. A NONEXISTENT file keeps this script's historical upstream wording, so
# every home without the file gets a byte-identical brief; a PRESENT file
# (including a 0-byte one) that lacks either line is refused, since a silent
# default there would be exactly the unfollowable-instruction failure this
# setting exists to prevent. The existence check must not be a non-empty
# check (`-s`): a 0-byte file must hit the same refusal as a one-line file,
# not silently fall back to the default.
KS_NAME="the RAG"
# shellcheck disable=SC2016 # single quotes are deliberate: the backticks must stay literal
KS_INSTRUCTIONS='`query_rag_hybrid` or `query_rag` on the `rag_qdrant_server` MCP server, with `query_text` set and `user_roles` passed, empty if you have none'
KS_FILE="$FM_HOME/config/knowledge-store"
if [ -f "$KS_FILE" ]; then
ks_name_line=$(sed -n '1p' "$KS_FILE")
ks_instructions_line=$(sed -n '2p' "$KS_FILE")
if [ -z "$ks_name_line" ] || [ -z "$ks_instructions_line" ]; then
echo "error: $KS_FILE must have the store name on line 1 and search instructions on line 2" >&2
exit 1
fi
KS_NAME=$ks_name_line
KS_INSTRUCTIONS=$ks_instructions_line
# (docs/configuration.md): bin/fm-knowledge-store-lib.sh owns reading it, the
# absent-file default, and the refusal of a present but malformed file.
# shellcheck source=bin/fm-knowledge-store-lib.sh
. "$SCRIPT_DIR/fm-knowledge-store-lib.sh"
if ! fm_knowledge_store_read "$FM_HOME/config"; then
echo "error: $FM_KS_ERROR" >&2
exit 1
fi
KS_NAME=$FM_KS_NAME
KS_INSTRUCTIONS=$FM_KS_INSTRUCTIONS

# A needs-decision line is the source firstmate relays to the captain, so every
# scaffold asks for the decision-card elements owned by captain-hold-lifecycle.
Expand Down
67 changes: 67 additions & 0 deletions bin/fm-knowledge-store-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # FM_KS_* fields are output globals for sourcing callers.
# Knowledge-store resolution primitives.
# Usage: . bin/fm-knowledge-store-lib.sh
#
# The optional local config/knowledge-store setting names the org-wide
# knowledge store this home's installed MCP servers actually provide
# (docs/configuration.md "Knowledge store naming"). This library is the one
# owner of reading it; bin/fm-brief.sh sources it for generated Grounding
# wording and bin/fm-knowledge-store.sh prints it for skills such as
# /retrospective.
#
# Line 1 is the store's name as it reads in agent-facing text, line 2 the
# search-instructions clause, and optional line 3 the backend key: `rag`
# (rag_qdrant_server) or `pp-brain`. Without line 3 the backend is derived
# from the MCP server line 2 names - `rag_qdrant_server` is `rag`,
# `pp-brain` or `search_knowledge` is `pp-brain` - and anything else is
# `other`, a store whose write contract is not known here.
# A NONEXISTENT file resolves to the historical upstream default, the RAG.
# A PRESENT file (including a 0-byte one) lacking line 1 or line 2, or carrying
# an unknown line-3 key, is refused rather than silently defaulted, since a
# silent default there is exactly the unfollowable-instruction failure the
# setting exists to prevent. The existence check must not be a non-empty
# check (`-s`): a 0-byte file must hit the same refusal as a one-line file.

FM_KS_FILE_NAME="knowledge-store"
FM_KS_NAME=""
FM_KS_INSTRUCTIONS=""
FM_KS_BACKEND=""
FM_KS_ERROR=""

# fm_knowledge_store_read <config-dir>
# Sets FM_KS_NAME, FM_KS_INSTRUCTIONS, and FM_KS_BACKEND; on refusal returns 1
# with FM_KS_ERROR set.
fm_knowledge_store_read() {
local file="$1/$FM_KS_FILE_NAME" name instructions backend
FM_KS_ERROR=""
FM_KS_NAME="the RAG"
# shellcheck disable=SC2016 # single quotes are deliberate: the backticks must stay literal
FM_KS_INSTRUCTIONS='`query_rag_hybrid` or `query_rag` on the `rag_qdrant_server` MCP server, with `query_text` set and `user_roles` passed, empty if you have none'
FM_KS_BACKEND="rag"
[ -f "$file" ] || return 0
name=$(sed -n '1p' "$file")
instructions=$(sed -n '2p' "$file")
backend=$(sed -n '3p' "$file")
if [ -z "$name" ] || [ -z "$instructions" ]; then
FM_KS_ERROR="$file must have the store name on line 1 and search instructions on line 2"
return 1
fi
case "$backend" in
rag|pp-brain) ;;
"")
case "$instructions" in
*rag_qdrant_server*) backend=rag ;;
*pp-brain*|*search_knowledge*) backend=pp-brain ;;
*) backend=other ;;
esac
;;
*)
FM_KS_ERROR="$file line 3 must be a backend key, rag or pp-brain, or be absent"
return 1
;;
esac
FM_KS_NAME=$name
FM_KS_INSTRUCTIONS=$instructions
FM_KS_BACKEND=$backend
}
41 changes: 41 additions & 0 deletions bin/fm-knowledge-store.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Print the org-wide knowledge store this home is configured with.
# Usage:
# fm-knowledge-store.sh read
#
# `read` prints three lines - `name=<store name>`, `backend=<rag|pp-brain|other>`,
# and `search=<search-instructions clause>` - resolved from the optional
# config/knowledge-store under $FM_HOME (default: this code root). An absent
# file prints the upstream RAG default; a malformed one exits 1 naming the
# problem. bin/fm-knowledge-store-lib.sh owns the format and derivation.
set -eu

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FM_ROOT="${FM_ROOT_OVERRIDE:-$(cd "$SCRIPT_DIR/.." && pwd)}"
FM_HOME="${FM_HOME:-${FM_ROOT_OVERRIDE:-$FM_ROOT}}"
CONFIG="${FM_CONFIG_OVERRIDE:-$FM_HOME/config}"

# shellcheck source=bin/fm-knowledge-store-lib.sh
. "$SCRIPT_DIR/fm-knowledge-store-lib.sh"

usage() {
sed -n '2,10{s/^# \{0,1\}//;p;}' "$0"
}

case "${1:-}" in
read)
[ "$#" -eq 1 ] || { usage >&2; exit 2; }
if ! fm_knowledge_store_read "$CONFIG"; then
printf 'knowledge-store: %s\n' "$FM_KS_ERROR" >&2
exit 1
fi
printf 'name=%s\nbackend=%s\nsearch=%s\n' "$FM_KS_NAME" "$FM_KS_BACKEND" "$FM_KS_INSTRUCTIONS"
;;
-h|--help)
usage
;;
*)
usage >&2
exit 2
;;
esac
3 changes: 2 additions & 1 deletion bin/fm-test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ family_for_basename() {
fm-composer-ghost.test.sh|fm-composer-lib.test.sh|\
fm-crew-state.test.sh|fm-captain-hold-lifecycle.test.sh|\
fm-documentation-audiences.test.sh|fm-ensure-agents-md.test.sh|fm-grok-harness.test.sh|\
fm-kimi-harness.test.sh|fm-muse-harness.test.sh|fm-herdr-lab.test.sh|fm-lint.test.sh|\
fm-kimi-harness.test.sh|fm-knowledge-store.test.sh|fm-muse-harness.test.sh|fm-herdr-lab.test.sh|fm-lint.test.sh|\
fm-lint-workflows.test.sh|\
fm-operational-input.test.sh|fm-pal-council.test.sh|fm-pi-primary-types.test.sh|\
fm-send-popup-settle.test.sh|fm-send-settle.test.sh|\
Expand Down Expand Up @@ -428,6 +428,7 @@ tests/fm-herdr-submit-confirm-live-e2e.test.sh 20
tests/fm-herdr-version-floor-live-e2e.test.sh 20
tests/fm-inactive-reconcile.test.sh 41671
tests/fm-kimi-harness.test.sh 15092
tests/fm-knowledge-store.test.sh 120
tests/fm-lint-workflows.test.sh 744
tests/fm-muse-harness.test.sh 27414
tests/fm-muse-signals-live-e2e.test.sh 21
Expand Down
8 changes: 5 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ There is no shared learnings file by captain decision.

## Knowledge store naming (config/knowledge-store)

`bin/fm-brief.sh`'s Grounding section tells every generated ship and scout worker to search a knowledge store before its first substantive action and before working around any gotcha.
`bin/fm-brief.sh`'s Grounding section tells every generated ship and scout worker to search a knowledge store before its first substantive action and before working around any gotcha, and the internal [`/retrospective` skill](../.agents/skills/retrospective/SKILL.md) recalls from and, with approval, writes to the same store as its org-wide layer.
The optional local, gitignored `config/knowledge-store` names that store for a home whose installed MCP servers do not match the upstream default.
Line 1 is the store's name as it should read in worker-facing text (e.g. `PP Brain`); line 2 is the search-instructions clause inserted in parentheses right after the name (e.g. the exact MCP tool, its arguments, and any follow-up contract).
Either line present but blank, or the file present but empty, is refused rather than silently falling back.
Absent keeps this script's historical wording naming the RAG's `query_rag_hybrid`/`query_rag` tool on the `rag_qdrant_server` MCP server, byte-identical to briefs generated before this setting existed.
Optional line 3 is the backend key, `rag` or `pp-brain`, which tells `/retrospective` which write tools the store has; without it the backend is derived from the MCP server line 2 names (`rag_qdrant_server` is `rag`, `pp-brain` or `search_knowledge` is `pp-brain`), and any other store is `other`, recalled from but never written by the skill.
Either of the first two lines present but blank, the file present but empty, or an unknown line-3 key is refused rather than silently falling back.
Absent resolves to the RAG: briefs keep this script's historical wording naming the RAG's `query_rag_hybrid`/`query_rag` tool on the `rag_qdrant_server` MCP server, byte-identical to briefs generated before this setting existed, and `/retrospective` uses the `rag` backend.
`bin/fm-knowledge-store.sh read` prints the resolved `name`, `backend`, and `search` values; `bin/fm-knowledge-store-lib.sh` is the one reader both consumers share.
It is inherited into secondmate homes (`FM_INHERITABLE_CONFIG` in [`bin/fm-config-inherit-lib.sh`](../bin/fm-config-inherit-lib.sh)): a secondmate's own crewmates get generated briefs from the same code, so an uninherited setting would silently regress them to a knowledge store the home's MCP servers do not have installed, reproducing the same failure this setting exists to fix.

## Startup memory budget (config/startup-memory-budget)
Expand Down
2 changes: 2 additions & 0 deletions docs/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The shared no-mistakes gate refusal for fleet lifecycle entrypoints is summarize
| `fm-captain-hold.sh` | Hold tasks for the captain, record the captain's answers, gate investigation completion, and report record divergence between the status log and the backlog |
| `fm-decision-hold.sh` | One-release compatibility shim mapping the retired decision commands onto fm-captain-hold.sh |
| `fm-brief.sh` | Scaffold ship (explicit `--mode`), scout, secondmate-charter, and Herdr-lab briefs |
| `fm-knowledge-store.sh` | Print the home's resolved org-wide knowledge store (`name`, `backend`, `search`) for skills such as `/retrospective` |
| `fm-knowledge-store-lib.sh` | Single owner of reading `config/knowledge-store` and deriving its backend, shared by the brief and the read command |
| `fm-herdr-lab.sh` | Provision and guardedly operate an isolated, never-default Herdr lab session |
| `fm-install-herdr.sh` | Install CI's exact-version Herdr pin with official asset URL, SHA-256, and protocol checks |
| `fm-install-treehouse.sh`| Install CI's exact-version Treehouse pin for real-Herdr E2E that needs spawn worktrees |
Expand Down
Loading
Loading