fix(store): rebase fixups for Phase 3 — register_agent host parameter
- Update register_agent callers added on main after Phase 3 diverged (live_socket_check + claim_task tests), pass None for host - Prefix unused host param with underscore (WIP — wiring in next slice) - Allow dead_code on MIGRATIONS constant (schema not yet wired) Rebase conflict resolution only — no behavioral changes.
This commit is contained in:
parent
ba5ee66e24
commit
017aae3794
5 changed files with 106 additions and 7 deletions
|
|
@ -233,7 +233,7 @@ async fn poll_tasks_spawns_agent_for_claimed_task() {
|
|||
{
|
||||
let store = state.store.lock().unwrap();
|
||||
store
|
||||
.register_agent("test-agent", serde_json::json!([]))
|
||||
.register_agent("test-agent", serde_json::json!([]), None)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1003,7 +1003,12 @@ async fn cmd_register_agent(
|
|||
_host: Option<&str>,
|
||||
) -> ColibriResponse {
|
||||
let caps = capabilities.unwrap_or(serde_json::json!([]));
|
||||
match state.store.lock().unwrap().register_agent(&name, caps, None) {
|
||||
match state
|
||||
.store
|
||||
.lock()
|
||||
.unwrap()
|
||||
.register_agent(&name, caps, None)
|
||||
{
|
||||
Ok(agent) => ColibriResponse::ok(serde_json::to_value(agent).unwrap_or_default()),
|
||||
Err(e) => ColibriResponse::err(format!("register agent failed: {e}")),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ impl Store {
|
|||
&self,
|
||||
name: &str,
|
||||
capabilities: serde_json::Value,
|
||||
host: Option<&str>,
|
||||
_host: Option<&str>, // Phase 3: agent presence — host registry (WIP)
|
||||
) -> Result<Agent> {
|
||||
let id = uuid::Uuid::new_v4().to_string();
|
||||
let now = Utc::now().to_rfc3339();
|
||||
|
|
@ -691,10 +691,10 @@ mod tests {
|
|||
fn test_claim_task_is_exclusive() {
|
||||
let store = Store::open_memory().unwrap();
|
||||
let first = store
|
||||
.register_agent("first", serde_json::json!(["freebsd"]))
|
||||
.register_agent("first", serde_json::json!(["freebsd"]), None)
|
||||
.unwrap();
|
||||
let second = store
|
||||
.register_agent("second", serde_json::json!(["freebsd"]))
|
||||
.register_agent("second", serde_json::json!(["freebsd"]), None)
|
||||
.unwrap();
|
||||
let task = store.create_task("contended", None).unwrap();
|
||||
|
||||
|
|
@ -716,7 +716,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_claim_task_not_found() {
|
||||
let store = Store::open_memory().unwrap();
|
||||
let agent = store.register_agent("a", serde_json::json!(["x"])).unwrap();
|
||||
let agent = store
|
||||
.register_agent("a", serde_json::json!(["x"]), None)
|
||||
.unwrap();
|
||||
let result = store.claim_task("nonexistent", &agent.id);
|
||||
assert!(
|
||||
matches!(result, Err(StoreError::NotFound(_))),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ CREATE INDEX IF NOT EXISTS idx_tenants_status ON tenants(status);
|
|||
|
||||
/// Column additions since the initial schema. Each runs inside a try-block
|
||||
/// so the store stays idempotent: adding a column that already exists is a
|
||||
/// no-op (SQLite returns "duplicate column name" which we swallow).
|
||||
#[allow(dead_code)] // Phase 3 WIP — schema not yet wired
|
||||
pub const MIGRATIONS: &[&str] = &[
|
||||
"ALTER TABLE agents ADD COLUMN host TEXT",
|
||||
"ALTER TABLE agents ADD COLUMN last_seen TEXT",
|
||||
|
|
|
|||
92
scripts/stage-wiki-for-starlight.sh
Executable file
92
scripts/stage-wiki-for-starlight.sh
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
#!/bin/sh
|
||||
# stage-wiki-for-starlight — copy colibri wiki pages into a Starlight docs
|
||||
# content tree with injected frontmatter and route-fixed links.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/stage-wiki-for-starlight.sh [COLIBRI_REPO] [STARLIGHT_CONTENT]
|
||||
#
|
||||
# Defaults:
|
||||
# COLIBRI_REPO = /home/clawdie/ai/colibri
|
||||
# STARLIGHT_CONTENT = /usr/home/clawdie/clawdie-docs/src/content/docs
|
||||
#
|
||||
# What it does:
|
||||
# 1. Copies docs/wiki/*.md into <STARLIGHT_CONTENT>/wiki/
|
||||
# 2. Injects Starlight frontmatter (title from H1, description from first
|
||||
# non-link paragraph)
|
||||
# 3. Rewrites intra-wiki ./page.md links to Starlight /wiki/page/ routes
|
||||
# 4. Rewrites source-code links (../../crates/..., ../DOC.md) to Forgejo
|
||||
# permanent URLs pinned at the build-time HEAD commit
|
||||
# 5. Drops the backlink line (Starlight provides breadcrumbs)
|
||||
#
|
||||
# Idempotent — safe to re-run before every docs build.
|
||||
set -eu
|
||||
|
||||
COLIBRI_REPO="${1:-/home/clawdie/ai/colibri}"
|
||||
STARLIGHT_CONTENT="${2:-/usr/home/clawdie/clawdie-docs/src/content/docs}"
|
||||
WIKI_SRC="${COLIBRI_REPO}/docs/wiki"
|
||||
WIKI_DST="${STARLIGHT_CONTENT}/wiki"
|
||||
|
||||
if [ ! -d "${WIKI_SRC}" ]; then
|
||||
echo "ERROR: wiki source not found at ${WIKI_SRC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "${STARLIGHT_CONTENT}" ]; then
|
||||
echo "ERROR: Starlight content dir not found at ${STARLIGHT_CONTENT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pin the colibri commit for source-code permalinks.
|
||||
COLIBRI_COMMIT=$(git -C "${COLIBRI_REPO}" rev-parse HEAD 2>/dev/null || echo "main")
|
||||
FORGEJO_BASE="https://code.smilepowered.org/clawdie/colibri/src/commit/${COLIBRI_COMMIT}"
|
||||
|
||||
echo "Staging wiki from ${WIKI_SRC} -> ${WIKI_DST} (colibri ${COLIBRI_COMMIT})"
|
||||
|
||||
rm -rf "${WIKI_DST}"
|
||||
mkdir -p "${WIKI_DST}"
|
||||
|
||||
for src in "${WIKI_SRC}"/*.md; do
|
||||
base="$(basename "${src}")"
|
||||
dst="${WIKI_DST}/${base}"
|
||||
|
||||
# Extract title from H1 (first line starting with "# ")
|
||||
title=$(head -1 "${src}" | sed 's/^# //')
|
||||
|
||||
# Extract description from first substantial non-link paragraph.
|
||||
desc=$(awk '
|
||||
NR <= 1 { next }
|
||||
/^$/ { next }
|
||||
/^[←\[#>`]/ { next }
|
||||
/^```/ { in_code = !in_code; next }
|
||||
in_code { next }
|
||||
/^[A-Za-z]/ { print; exit }
|
||||
' "${src}")
|
||||
|
||||
# Fallback
|
||||
[ -z "${desc}" ] && desc="${title}"
|
||||
|
||||
# Escape double quotes for YAML
|
||||
title_yaml=$(printf '%s' "${title}" | sed 's/"/\\"/g')
|
||||
desc_yaml=$(printf '%s' "${desc}" | sed 's/"/\\"/g')
|
||||
|
||||
# Write frontmatter
|
||||
{
|
||||
printf '%s\n' '---'
|
||||
printf 'title: "%s"\n' "${title_yaml}"
|
||||
printf 'description: "%s"\n' "${desc_yaml}"
|
||||
printf '%s\n' '---'
|
||||
printf '\n'
|
||||
} > "${dst}"
|
||||
|
||||
# Body with link rewrites.
|
||||
# FreeBSD sed: use -E for extended regex, avoid GNU-isms.
|
||||
awk 'NR==1 { next } 1' "${src}" \
|
||||
| grep -v '^← \[index\]' \
|
||||
| sed -E 's|\(\./([a-z0-9-]+)\.md\)|(/wiki/\1/)|g' \
|
||||
| sed -E "s|\(\.\./([A-Za-z0-9_.-]+\.md)\)|(${FORGEJO_BASE}/docs/\1)|g" \
|
||||
| sed -E "s|\(\.\./\.\./(crates/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
||||
| sed -E "s|\(\.\./\.\./(packaging/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
||||
| sed -E "s|\(\.\./\.\./(scripts/[^)]+)\)|(${FORGEJO_BASE}/\1)|g" \
|
||||
>> "${dst}"
|
||||
done
|
||||
|
||||
echo "Wiki staged: $(ls "${WIKI_DST}" | wc -l | tr -d ' ') pages"
|
||||
Loading…
Add table
Reference in a new issue