Compare commits

..

1 Commits

Author SHA1 Message Date
ms-835-build
2e8e8aa83b fix(framework): drop unsupported --comment from tea pr approve/reject; route review body via durable comment (#835)
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
tea v0.11.1 defines no --comment/-comment flag on `pr approve` or `pr
reject`, so pr-review.sh's Gitea approve/reject paths errored with
"flag provided but not defined: -comment" whenever a review body was
supplied, breaking the durable formal-review path fleet-wide.

Remove --comment from both tea invocations and, when a review body is
present, post it via the same verified Gitea comments REST API path
the `comment` action already uses (#812) — extracted into a shared
gitea_post_verified_comment() helper so all three actions share one
write+read-back-verified implementation instead of duplicating it.

Extends the existing #812 regression harness
(test-pr-review-gitea-comment.sh) with a `tea` stub that rejects
unknown flags exactly like real tea v0.11.1, so it fails RED against
the pre-fix wrapper and passes GREEN after.

Closes #835.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 03:58:51 -05:00
12 changed files with 15 additions and 518 deletions

View File

@@ -91,19 +91,13 @@ remote = urlparse(f"//{remote_host}")
if configured.scheme not in {"http", "https"} or configured.hostname != remote.hostname: if configured.scheme not in {"http", "https"} or configured.hostname != remote.hostname:
raise SystemExit(1) raise SystemExit(1)
# Normalize by scheme: an implicit (portless) HTTP(S) URL and its explicit configured_port = configured.port
# default-port form (":80" for http, ":443" for https) name the same remote_port = remote.port
# provider endpoint. Apply that equivalence symmetrically -- whichever side if remote_port is None:
# omits the port is treated as carrying the scheme's default port -- so default_port = 80 if configured.scheme == "http" else 443
# "configured implicit vs. remote explicit" and "configured explicit vs. if configured_port not in {None, default_port}:
# remote implicit" both match. (The remote side here is always an HTTP(S) raise SystemExit(1)
# authority; an SSH remote's transport port is stripped by get_remote_host elif configured_port != remote_port:
# before reaching this comparison, since it identifies an unrelated
# service on the same host, not the HTTP(S) provider port.)
default_port = 80 if configured.scheme == "http" else 443
normalized_configured = configured.port if configured.port is not None else default_port
normalized_remote = remote.port if remote.port is not None else default_port
if normalized_configured != normalized_remote:
raise SystemExit(1) raise SystemExit(1)
raise SystemExit(0) raise SystemExit(0)
PY PY
@@ -438,11 +432,7 @@ get_remote_host() {
fi fi
if [[ "$remote_url" =~ ^ssh://([^/]+)/ ]]; then if [[ "$remote_url" =~ ^ssh://([^/]+)/ ]]; then
local host="${BASH_REMATCH[1]}" local host="${BASH_REMATCH[1]}"
host="${host##*@}" echo "${host##*@}"
# Strip an SSH transport port (e.g. "git.example:2222"): it names the
# SSH daemon port, not the HTTP(S) provider API port, and must not
# feed gitea_url_matches_host's port comparison (#850).
echo "${host%%:*}"
return 0 return 0
fi fi
if [[ "$remote_url" =~ ^git@([^:]+): ]]; then if [[ "$remote_url" =~ ^git@([^:]+): ]]; then

View File

@@ -73,7 +73,7 @@ case "${PR_REVIEW_TEST_MODE:-}" in
request-changes) request-changes)
[[ "$*" == "pr reject 123 --repo mosaicstack/stack --login mosaicstack" ]] || exit 91 [[ "$*" == "pr reject 123 --repo mosaicstack/stack --login mosaicstack" ]] || exit 91
;; ;;
legacy-fallback|comment-success|http-success|prefix-success|subpath-success|port-success|scp-ssh-success|url-ssh-success|ssh-transport-port-success|explicit-default-port-success|write-transport-failure|write-http-failure|readback-failure) legacy-fallback|comment-success|http-success|prefix-success|subpath-success|port-success|scp-ssh-success|url-ssh-success|write-transport-failure|write-http-failure|readback-failure)
if [[ "$*" == pr\ comment* ]]; then if [[ "$*" == pr\ comment* ]]; then
# tea v0.11.1 treats the nonexistent subcommand as `tea pr list` and exits 0. # tea v0.11.1 treats the nonexistent subcommand as `tea pr list` and exits 0.
printf '%s\n' 'INDEX TITLE STATE' printf '%s\n' 'INDEX TITLE STATE'
@@ -144,7 +144,7 @@ case "${PR_REVIEW_TEST_MODE:-}" in
write-http-failure) write-http-failure)
write_response 500 '{"message":"simulated rejection"}' write_response 500 '{"message":"simulated rejection"}'
;; ;;
approve|request-changes|comment-success|http-success|prefix-success|subpath-success|port-success|scp-ssh-success|url-ssh-success|ssh-transport-port-success|explicit-default-port-success|readback-failure) approve|request-changes|comment-success|http-success|prefix-success|subpath-success|port-success|scp-ssh-success|url-ssh-success|readback-failure)
if [[ "$method" == "POST" && "$url" == "$PR_REVIEW_EXPECTED_API_BASE/issues/123/comments" ]]; then if [[ "$method" == "POST" && "$url" == "$PR_REVIEW_EXPECTED_API_BASE/issues/123/comments" ]]; then
PR_REVIEW_PAYLOAD="$payload" python3 - <<'PY' PR_REVIEW_PAYLOAD="$payload" python3 - <<'PY'
import json import json
@@ -291,23 +291,6 @@ grep -q '^POST https://git.example/api/v1/repos/owner/repo/issues/123/comments$'
run_review url-ssh-success comment durable-body https://git.example ssh://git@git.example/owner/repo.git owner/repo run_review url-ssh-success comment durable-body https://git.example ssh://git@git.example/owner/repo.git owner/repo
grep -q '^POST https://git.example/api/v1/repos/owner/repo/issues/123/comments$' "$CURL_LOG" grep -q '^POST https://git.example/api/v1/repos/owner/repo/issues/123/comments$' "$CURL_LOG"
# #850 (follow-up to #812): an SSH remote's transport port (e.g. `ssh://
# git@host:2222/...`) must NOT be compared against the configured HTTP(S) API
# URL's port -- they identify unrelated properties (SSH daemon port vs. HTTP(S)
# provider port) of the same Gitea host. Before the fix, host-match required
# the configured URL to carry the identical port, so this failed closed even
# though both remote and configured URL name the same host.
run_review ssh-transport-port-success comment durable-body https://git.example ssh://git@git.example:2222/owner/repo.git owner/repo
grep -q '^POST https://git.example/api/v1/repos/owner/repo/issues/123/comments$' "$CURL_LOG"
# #850 (follow-up to #812): an explicit default HTTP(S) port on the remote
# (`https://host:443/...`) must be treated as equal to an implicit
# (portless) configured URL on BOTH sides -- the pre-fix comparison only
# normalized the default port when the REMOTE side was portless, so the
# inverse (explicit remote, implicit configured) form failed closed.
run_review explicit-default-port-success comment durable-body https://git.example https://git.example:443/owner/repo.git owner/repo
grep -q '^POST https://git.example/api/v1/repos/owner/repo/issues/123/comments$' "$CURL_LOG"
if run_review write-transport-failure comment durable-body; then if run_review write-transport-failure comment durable-body; then
echo "Expected provider transport failure to return nonzero" >&2 echo "Expected provider transport failure to return nonzero" >&2
exit 1 exit 1

View File

@@ -50,21 +50,6 @@ if ! [[ "$FILE_PATH" =~ \.(ts|tsx|js|jsx|mjs|cjs)$ ]]; then
exit 0 exit 0
fi fi
# Deps preflight (#856): this hook is the common gate-entry seam the delivery
# cycle invokes on every Edit/Write/MultiEdit — it fires before any pnpm-based
# gate (test/lint/typecheck/format:check) runs against the edited file. In a
# freshly created git worktree (pnpm workspaces do NOT share node_modules
# across worktrees), node_modules/.bin is empty until `pnpm install` has run,
# so gate binaries (tsc/eslint/prettier/vitest) fail with a raw, illegible
# `sh: 1: <tool>: not found` that is indistinguishable from a real failure.
# Fail legibly here instead, before that raw error has a chance to surface.
BIN_DIR="$PROJECT_ROOT/node_modules/.bin"
if [ ! -d "$BIN_DIR" ] || [ -z "$(ls -A "$BIN_DIR" 2>/dev/null)" ]; then
echo "deps not installed — run pnpm install" >&2
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [ERROR] deps not installed — run pnpm install ($BIN_DIR is missing or empty)" >> "$LOG_FILE"
exit 1
fi
# Call the main QA handler with extracted parameters # Call the main QA handler with extracted parameters
if [ -f ~/.config/mosaic/tools/qa/qa-hook-handler.sh ]; then if [ -f ~/.config/mosaic/tools/qa/qa-hook-handler.sh ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Calling QA handler for $FILE_PATH" >> "$LOG_FILE" echo "[$(date '+%Y-%m-%d %H:%M:%S')] Calling QA handler for $FILE_PATH" >> "$LOG_FILE"

View File

@@ -1,116 +0,0 @@
#!/usr/bin/env bash
# Regression harness for #856: worker git-worktrees under a fresh `git worktree
# add` have no node_modules until `pnpm install` runs (pnpm workspaces do NOT
# share node_modules across worktrees). Before the fix, the gate-entry seam
# (qa-hook-stdin.sh, registered as the PostToolUse hook for every Edit/Write/
# MultiEdit in runtime/claude/settings.json) silently let a raw
# `sh: 1: <tool>: not found` surface from any downstream gate invocation —
# indistinguishable from a real test/lint failure (false-red).
#
# Asserts:
# 1. RED (documented): a completely fresh worktree with no node_modules/.bin
# at all produces the raw "not found" for a gate binary — this is the
# defect the fix prevents from reaching the operator un-annotated.
# 2. With node_modules/.bin missing entirely, the seam exits nonzero with
# the legible sentinel "deps not installed — run pnpm install" instead
# of silently proceeding (exit 0) into a would-be raw not-found.
# 3. With node_modules/.bin present but empty, same legible-sentinel
# behavior (covers `git worktree add` immediately followed by an
# as-yet-incomplete/interrupted install).
# 4. Once node_modules/.bin is populated (post `pnpm install`), the seam
# proceeds normally (exit 0) — the preflight does not false-positive.
# 5. Non-JS/TS files are unaffected (existing skip behavior preserved).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOOK="$SCRIPT_DIR/qa-hook-stdin.sh"
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
fail=0
fail_msg() {
echo "FAIL: $*" >&2
fail=1
}
run_hook() {
local file_path="$1"
printf '{"tool_name":"Edit","tool_input":{"file_path":"%s"}}' "$file_path" | "$HOOK"
}
make_fixture_repo() {
local dir="$1"
mkdir -p "$dir"
git -C "$dir" init -q .
git -C "$dir" -c user.email=fixture@test -c user.name=fixture commit -q --allow-empty -m init
}
# --- Scenario 1: RED — document the pre-fix raw not-found a gate hits when
# node_modules/.bin is entirely absent (this is what the preflight now
# intercepts before any gate command runs).
RED_DIR="$TMP_DIR/red-fixture"
make_fixture_repo "$RED_DIR"
RED_OUTPUT=$(PATH="/usr/bin:/bin" sh -c 'tsc --noEmit' 2>&1) && RED_STATUS=0 || RED_STATUS=$?
case "$RED_OUTPUT" in
*"not found"*) ;;
*) fail_msg "expected the raw un-preflighted invocation to demonstrate 'not found'; got: $RED_OUTPUT" ;;
esac
[[ "$RED_STATUS" -ne 0 ]] || fail_msg "expected raw invocation without deps installed to fail"
# --- Scenario 2: node_modules/.bin missing entirely -> legible sentinel, nonzero.
MISSING_DIR="$TMP_DIR/missing-bin"
make_fixture_repo "$MISSING_DIR"
echo "console.log(1)" > "$MISSING_DIR/x.ts"
OUTPUT=$(cd "$MISSING_DIR" && run_hook "$MISSING_DIR/x.ts" 2>&1) && STATUS=0 || STATUS=$?
[[ "$STATUS" -ne 0 ]] || fail_msg "missing node_modules/.bin: expected nonzero exit, got 0"
case "$OUTPUT" in
*"deps not installed"*"pnpm install"*) ;;
*) fail_msg "missing node_modules/.bin: expected legible sentinel, got: $OUTPUT" ;;
esac
# --- Scenario 3: node_modules/.bin present but empty -> legible sentinel, nonzero.
EMPTY_DIR="$TMP_DIR/empty-bin"
make_fixture_repo "$EMPTY_DIR"
mkdir -p "$EMPTY_DIR/node_modules/.bin"
echo "console.log(1)" > "$EMPTY_DIR/x.ts"
OUTPUT=$(cd "$EMPTY_DIR" && run_hook "$EMPTY_DIR/x.ts" 2>&1) && STATUS=0 || STATUS=$?
[[ "$STATUS" -ne 0 ]] || fail_msg "empty node_modules/.bin: expected nonzero exit, got 0"
case "$OUTPUT" in
*"deps not installed"*"pnpm install"*) ;;
*) fail_msg "empty node_modules/.bin: expected legible sentinel, got: $OUTPUT" ;;
esac
# --- Scenario 4: node_modules/.bin populated (post `pnpm install`) -> proceeds normally.
OK_DIR="$TMP_DIR/installed-bin"
make_fixture_repo "$OK_DIR"
mkdir -p "$OK_DIR/node_modules/.bin"
printf '#!/bin/sh\necho ok\n' > "$OK_DIR/node_modules/.bin/tsc"
chmod +x "$OK_DIR/node_modules/.bin/tsc"
echo "console.log(1)" > "$OK_DIR/x.ts"
OUTPUT=$(cd "$OK_DIR" && run_hook "$OK_DIR/x.ts" 2>&1) && STATUS=0 || STATUS=$?
[[ "$STATUS" -eq 0 ]] || fail_msg "populated node_modules/.bin: expected exit 0, got $STATUS ($OUTPUT)"
case "$OUTPUT" in
*"deps not installed"*) fail_msg "populated node_modules/.bin: unexpected sentinel fired: $OUTPUT" ;;
*) ;;
esac
# --- Scenario 5: non-JS/TS files are unaffected by the preflight (still
# skipped before the deps check, regardless of node_modules state).
NONJS_DIR="$TMP_DIR/nonjs"
make_fixture_repo "$NONJS_DIR"
echo "# doc" > "$NONJS_DIR/README.md"
OUTPUT=$(cd "$NONJS_DIR" && run_hook "$NONJS_DIR/README.md" 2>&1) && STATUS=0 || STATUS=$?
[[ "$STATUS" -eq 0 ]] || fail_msg "non-JS/TS file: expected exit 0 (skip), got $STATUS ($OUTPUT)"
case "$OUTPUT" in
*"deps not installed"*) fail_msg "non-JS/TS file: preflight incorrectly fired: $OUTPUT" ;;
*) ;;
esac
if [[ "$fail" -eq 0 ]]; then
echo "deps-preflight regression passed (5/5 scenarios)"
fi
exit "$fail"

View File

@@ -25,7 +25,7 @@
"lint": "eslint src", "lint": "eslint src",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"test": "vitest run --passWithNoTests && pnpm run test:framework-shell", "test": "vitest run --passWithNoTests && pnpm run test:framework-shell",
"test:framework-shell": "python3 src/lease-broker/daemon_deadline_unittest.py && python3 src/lease-broker/normative_fragments_unittest.py && python3 src/lease-broker/receipt_challenge_unittest.py && python3 src/lease-broker/context_recovery_unittest.py && python3 src/lease-broker/recovery_runtime_unittest.py && python3 src/lease-broker/recovery_b1_adversarial_unittest.py && python3 src/lease-broker/framework_skill_portability_unittest.py && python3 src/mutator-gate/runtime_tools_unittest.py && python3 src/mutator-gate/runtime_launch_guard_unittest.py && python3 framework/tools/lease-broker/check-runtime-launches.py --root ../.. && bash framework/tools/codex/test-pr-diff-context.sh && bash framework/tools/qa/test-deps-preflight.sh && bash framework/tools/git/test-pr-review-gitea-comment.sh" "test:framework-shell": "python3 src/lease-broker/daemon_deadline_unittest.py && python3 src/lease-broker/normative_fragments_unittest.py && python3 src/lease-broker/receipt_challenge_unittest.py && python3 src/lease-broker/context_recovery_unittest.py && python3 src/lease-broker/recovery_runtime_unittest.py && python3 src/lease-broker/recovery_b1_adversarial_unittest.py && python3 src/lease-broker/framework_skill_portability_unittest.py && python3 src/mutator-gate/runtime_tools_unittest.py && python3 src/mutator-gate/runtime_launch_guard_unittest.py && python3 framework/tools/lease-broker/check-runtime-launches.py --root ../.. && bash framework/tools/codex/test-pr-diff-context.sh"
}, },
"dependencies": { "dependencies": {
"@mosaicstack/brain": "workspace:*", "@mosaicstack/brain": "workspace:*",

View File

@@ -661,27 +661,13 @@ describe('whole mutator-class lease gate', () => {
test('observer revocation and monotonic TTL expiry deny the next mutator', async () => { test('observer revocation and monotonic TTL expiry deny the next mutator', async () => {
const { socket } = await startBroker(); const { socket } = await startBroker();
const sessionId = await register(socket); const sessionId = await register(socket);
const pending = await beginVerification(socket, sessionId, 'claude', 1, 1);
// Establish the lease with a normal (non-racing) TTL first and prove it
// authorizes. This "still valid" check is setup, not a TTL-expiry
// assertion, so it must not share a lease with a 1-second TTL: on a
// contended push-CI host, scheduling delay alone between promote() and
// this authorize() call can consume that entire 1-second margin and
// spuriously deny it (CI#1945). Using a generous TTL here removes that
// real-time race without touching lease-gate security semantics.
const pending = await beginVerification(socket, sessionId, 'claude');
await promote(socket, sessionId, pending.receipt_challenge!); await promote(socket, sessionId, pending.receipt_challenge!);
expect(await authorize(socket, sessionId, 'claude', 'Bash')).toMatchObject({ expect(await authorize(socket, sessionId, 'claude', 'Bash')).toMatchObject({
ok: true, ok: true,
decision: 'allow', decision: 'allow',
}); });
// A dedicated, isolated short-TTL lease drives the deliberate monotonic
// expiry demonstration below. It is never used for anything but the
// wait-then-expire assertion, so there is no setup work racing its
// 1-second window.
const shortLived = await beginVerification(socket, sessionId, 'claude', 1, 1, 2);
await promote(socket, sessionId, shortLived.receipt_challenge!);
await new Promise((resolve) => setTimeout(resolve, 1_100)); await new Promise((resolve) => setTimeout(resolve, 1_100));
expect(await authorize(socket, sessionId, 'claude', 'Bash')).toMatchObject({ expect(await authorize(socket, sessionId, 'claude', 'Bash')).toMatchObject({
ok: false, ok: false,
@@ -689,7 +675,7 @@ describe('whole mutator-class lease gate', () => {
decision: 'deny', decision: 'deny',
}); });
const refreshed = await beginVerification(socket, sessionId, 'claude', 1, 300, 3); const refreshed = await beginVerification(socket, sessionId, 'claude', 1, 300, 2);
await promote(socket, sessionId, refreshed.receipt_challenge!); await promote(socket, sessionId, refreshed.receipt_challenge!);
expect( expect(
await request(socket, { await request(socket, {

View File

@@ -217,22 +217,12 @@ git fetch origin
mkdir -p ~/src/${projectName}-worktrees mkdir -p ~/src/${projectName}-worktrees
git worktree add ~/src/${projectName}-worktrees/<task-slug> -b <branch-name> origin/main git worktree add ~/src/${projectName}-worktrees/<task-slug> -b <branch-name> origin/main
cd ~/src/${projectName}-worktrees/<task-slug> cd ~/src/${projectName}-worktrees/<task-slug>
pnpm install --frozen-lockfile --prefer-offline
# ... all work happens here ... # ... all work happens here ...
git push origin <branch-name> git push origin <branch-name>
cd ~/src/${projectName} && git worktree remove ~/src/${projectName}-worktrees/<task-slug> cd ~/src/${projectName} && git worktree remove ~/src/${projectName}-worktrees/<task-slug>
\`\`\` \`\`\`
Worktrees path: \`~/src/<repo>-worktrees/<task-slug>\` — NEVER use /tmp. Worktrees path: \`~/src/<repo>-worktrees/<task-slug>\` — NEVER use /tmp.`);
\`pnpm install --frozen-lockfile --prefer-offline\` MUST run immediately after
\`git worktree add\`/\`cd\`, BEFORE any gate (\`pnpm test\`/\`lint\`/\`typecheck\`/\`format:check\`)
is invoked. pnpm workspaces do NOT share \`node_modules\` across separate git
worktrees — a fresh worktree has an empty \`node_modules/.bin\`, so every gate
binary (\`tsc\`/\`eslint\`/\`prettier\`/\`vitest\`) fails \`sh: 1: <tool>: not found\`
until deps are installed. That failure is indistinguishable from a real
test/lint failure — a false-red gate. Never skip this step and never reorder
it after the first gate invocation.`);
// 6. Completion gates // 6. Completion gates
sections.push(`# Completion Gates — ENFORCED sections.push(`# Completion Gates — ENFORCED

View File

@@ -1,50 +0,0 @@
# Skill: glpi-create — Open a New GLPI Ticket
> Create a new GLPI helpdesk ticket. Mutates GLPI — confirm the details before running.
## When to use
- Logging a new incident or request that should live in the helpdesk queue.
## Required information
- **title** — short subject line.
- **content** — description of the issue / request.
## Optional
- **priority** — `1`=VeryLow, `2`=Low, `3`=Medium (default), `4`=High, `5`=VeryHigh, `6`=Major.
- **type** — `1`=Incident (default), `2`=Request.
## Command
Wraps the existing tooling:
```bash
~/.config/mosaic/tools/glpi/ticket-create.sh \
-t "<title>" \
-c "<content>" \
[-p <priority>] \
[-y <type>] \
[-f json]
```
Example:
```bash
~/.config/mosaic/tools/glpi/ticket-create.sh \
-t "Paint-area camera install" \
-c "Ordered 2 cameras for Paint and stock; schedule mounting + NVR config." \
-p 3 -y 2
```
## After creating
- Note the returned **ticket ID** — you'll need it for **[[glpi-followup]]** and
**[[glpi-solve]]**.
- If it should also be tracked as brain work, add a matching task (see the `add-task` skill).
## Guardrails
- Confirm title/content/priority with the user before creating — a ticket is outward-facing.
- Never echo GLPI tokens.

View File

@@ -1,56 +0,0 @@
# Skill: glpi-followup — Add a Followup to a GLPI Ticket
> Post a followup (comment / progress note / resolution writeup) to a GLPI ticket.
> This documents work but does **not** change the ticket status — to close a ticket
> out, follow with **[[glpi-solve]]** to set status to Solved.
## When to use
- Recording progress, a decision, or a root-cause/resolution note on a ticket.
- The documentation step that usually precedes closing a ticket out (`glpi-solve`).
## Critical quirk
Use the **top-level `/ITILFollowup` endpoint**, NOT `/Ticket/<id>/ITILFollowup`. The
sub-resource path returns permission errors even with a Super-Admin profile.
## Procedure
### 1. Session + creds
```bash
SESSION=$(~/.config/mosaic/tools/glpi/session-init.sh -q)
source ~/.config/mosaic/tools/_lib/credentials.sh && load_credentials glpi
```
### 2. Post the followup
```bash
TICKET_ID=<id>
CONTENT="<the followup text>"
curl -sk -X POST "${GLPI_URL}/ITILFollowup" \
-H "App-Token: $GLPI_APP_TOKEN" \
-H "Session-Token: $SESSION" \
-H "Content-Type: application/json" \
-d "$(jq -n --argjson id "$TICKET_ID" --arg c "$CONTENT" \
'{input:{itemtype:"Ticket", items_id:$id, content:$c}}')"
```
Expect HTTP 201. Building the payload with `jq` keeps quotes/newlines in the content safe.
### 3. Long or multi-paragraph content
Write the note to a file first, then read it into the payload:
```bash
curl -sk -X POST "${GLPI_URL}/ITILFollowup" \
-H "App-Token: $GLPI_APP_TOKEN" -H "Session-Token: $SESSION" \
-H "Content-Type: application/json" \
-d "$(jq -n --argjson id "$TICKET_ID" --rawfile c /path/to/note.md \
'{input:{itemtype:"Ticket", items_id:$id, content:$c}}')"
```
## Guardrails
- Never echo the GLPI app/user/session tokens.
- A followup alone leaves the ticket open. If the work is done, run **[[glpi-solve]]** next.

View File

@@ -1,57 +0,0 @@
# Skill: glpi-list — Query GLPI Tickets
> Quick lookups of GLPI helpdesk tickets by status or recency. Read-only.
## When to use
- "What tickets are open / pending?" · "Show recent tickets" · finding a ticket ID
before running **[[glpi-followup]]** or **[[glpi-solve]]**.
## Command
Wraps the existing tooling:
```bash
GLPI=~/.config/mosaic/tools/glpi
# Most recent tickets (default 50, newest first)
"$GLPI/ticket-list.sh"
# Filter by status: new | processing | pending | solved | closed
"$GLPI/ticket-list.sh" -s pending
# JSON output (for parsing / piping to jq) and a custom limit
"$GLPI/ticket-list.sh" -s processing -f json -l 20
```
Status IDs: 1 New · 2/3 Processing · 4 Pending · 5 Solved · 6 Closed.
## Details lookup for one ticket
When you have an ID and want the full record:
```bash
SESSION=$(~/.config/mosaic/tools/glpi/session-init.sh -q)
source ~/.config/mosaic/tools/_lib/credentials.sh && load_credentials glpi
curl -sk "${GLPI_URL}/Ticket/<id>?expand_dropdowns=true" \
-H "App-Token: $GLPI_APP_TOKEN" -H "Session-Token: $SESSION" \
| jq '{id, name, status, date, date_mod}'
# Followups on a ticket
curl -sk "${GLPI_URL}/Ticket/<id>/ITILFollowup" \
-H "App-Token: $GLPI_APP_TOKEN" -H "Session-Token: $SESSION" \
| jq '.[] | {date, content}'
```
(Reading followups via the sub-resource is fine — only _creating_ them requires the
top-level `/ITILFollowup` endpoint. See **[[glpi-followup]]**.)
## Present to user
Group by status, one line per ticket: `#<id> · <title> · <status> · <last-modified>`.
Use neutral phrasing — no "OVERDUE"/"URGENT".
## Guardrails
- Read-only. Never echo GLPI tokens.
- To sync tickets into brain data instead, use `python tools/sync_glpi.py` (not this skill).

View File

@@ -1,96 +0,0 @@
# Skill: glpi-solve — Close Out a GLPI Ticket
> Properly close out a completed GLPI helpdesk ticket. Completing the work is not
> enough — the ticket **status must be set to "Solved"**, which is what triggers
> GLPI's config-driven auto-close. Posting a resolution followup documents the work
> but does **not** change status, so a ticket left at Solved-less status stays open.
## When to use
- Any time work on a GLPI ticket is finished and it should be closed out.
- After posting a root-cause / resolution writeup as an `/ITILFollowup`.
- During a cleanup sweep of tickets that are done in reality but still open in GLPI.
## The rule (from an operator, 2026-07-20)
**"Solved" is the correct terminal state to set — not "Closed."** GLPI is configured
to auto-close Solved tickets after its delay. If you only post a followup and never set
status, the ticket sits open (this bit us on a real incident where resolution followups
were posted but status was never advanced, leaving tickets open, which the operator had
to mark Solved by hand).
Close-out = **followup (optional but preferred) + set status to Solved.**
## GLPI status IDs
| ID | Status | |
| ----- | --------------------- | -------------------------------------------- |
| 1 | New | |
| 2 | Processing (assigned) | |
| 3 | Processing (planned) | |
| 4 | Pending / Waiting | |
| **5** | **Solved** | ← set this on close-out |
| 6 | Closed | ← happens automatically; do not set manually |
## Procedure
### 1. Get a session token
```bash
SESSION=$(~/.config/mosaic/tools/glpi/session-init.sh -q)
source ~/.config/mosaic/tools/_lib/credentials.sh && load_credentials glpi
```
### 2. (Preferred) Post the resolution followup
Use the **top-level `/ITILFollowup` endpoint** — the `/Ticket/<id>/ITILFollowup`
sub-resource returns permission errors even as Super-Admin (known GLPI quirk).
```bash
TICKET_ID=<id>
curl -sk -X POST "${GLPI_URL}/ITILFollowup" \
-H "App-Token: $GLPI_APP_TOKEN" \
-H "Session-Token: $SESSION" \
-H "Content-Type: application/json" \
-d "{\"input\":{\"itemtype\":\"Ticket\",\"items_id\":${TICKET_ID},\"content\":\"<resolution summary>\"}}"
```
### 3. Set status to Solved (the step that actually closes it out)
```bash
curl -sk -X PUT "${GLPI_URL}/Ticket/${TICKET_ID}" \
-H "App-Token: $GLPI_APP_TOKEN" \
-H "Session-Token: $SESSION" \
-H "Content-Type: application/json" \
-d "{\"input\":{\"id\":${TICKET_ID},\"status\":5}}"
```
Expect HTTP 200/201. GLPI will auto-close it later per its config — leave status at 5.
### 4. Verify
```bash
curl -sk "${GLPI_URL}/Ticket/${TICKET_ID}?expand_dropdowns=true" \
-H "App-Token: $GLPI_APP_TOKEN" -H "Session-Token: $SESSION" \
| jq '{id, name, status}'
```
`status` should read `Solved` (or `5`).
## Optional: sweep for done-but-open tickets
List tickets still open (New/Processing/Pending) to spot ones whose work is actually
finished but were never marked Solved:
```bash
~/.config/mosaic/tools/glpi/ticket-list.sh -s processing -f table
~/.config/mosaic/tools/glpi/ticket-list.sh -s pending -f table
```
Review each; for any that are genuinely resolved, run steps 23.
## Guardrails
- Read-only until you intend to close — confirm the ticket is actually done first.
- Never echo the GLPI app/user/session tokens.
- Set **Solved (5)**, never Closed (6) — auto-close owns that transition.

View File

@@ -1,62 +0,0 @@
# Skill: glpi-sweep — Find Done-But-Open Tickets
> Read-only sweep for tickets that are finished in reality but still sitting open in
> GLPI (never moved to Solved). Surfaces the exact miss an operator caught on 2026-07-20
> (a real incident where an affected ticket had resolution followups posted but was left
> open). For each one that's genuinely done, close it out with **[[glpi-solve]]**.
## When to use
- Periodic hygiene pass (e.g. before a weekly update or month-end).
- After a burst of ticket work, to catch any you resolved-in-followup but never Solved.
## Why this exists
Posting an `/ITILFollowup` documents work but does **not** change status. Tickets only
auto-close once set to **Solved (status 5)**. Anything left at New/Processing/Pending
stays open indefinitely. This sweep finds those.
## Procedure
### 1. List still-open tickets by status
```bash
GLPI=~/.config/mosaic/tools/glpi
"$GLPI/ticket-list.sh" -s new -f table
"$GLPI/ticket-list.sh" -s processing -f table
"$GLPI/ticket-list.sh" -s pending -f table
```
(GLPI status IDs: 1 New · 2/3 Processing · 4 Pending · 5 Solved · 6 Closed.)
### 2. Triage
For each open ticket, judge whether the underlying work is actually finished — check
its latest followups and cross-reference brain tasks / recent work. Read-only here;
change nothing yet.
Reasonable "probably done" signals:
- A resolution/root-cause followup already posted, but status never advanced.
- The related brain task is `done`, or the fix shipped and was confirmed.
- Requester confirmed resolution but the ticket was never Solved.
### 3. Present the candidates
List them for review before touching anything — never bulk-solve blindly:
```
Open tickets that look resolved:
- #<id> "<title>" — <why it looks done> → glpi-solve?
```
### 4. Close out the confirmed ones
For each ticket the user (or clear evidence) confirms is done, run **[[glpi-solve]]**
(optionally **[[glpi-followup]]** first if a closing note is warranted).
## Guardrails
- Read-only until a ticket is confirmed done — do not auto-solve on a guess.
- Never echo GLPI tokens.
- Set **Solved (5)**, never Closed (6) — GLPI auto-close owns that transition.