@groundnuty/macf 0.2.38 → 0.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/.build-info.json +2 -2
  2. package/dist/cli/claude-sh.d.ts.map +1 -1
  3. package/dist/cli/claude-sh.js +13 -0
  4. package/dist/cli/claude-sh.js.map +1 -1
  5. package/dist/cli/commands/fleet-doctor-inject.d.ts +52 -0
  6. package/dist/cli/commands/fleet-doctor-inject.d.ts.map +1 -0
  7. package/dist/cli/commands/fleet-doctor-inject.js +100 -0
  8. package/dist/cli/commands/fleet-doctor-inject.js.map +1 -0
  9. package/dist/cli/commands/fleet-doctor.d.ts +236 -0
  10. package/dist/cli/commands/fleet-doctor.d.ts.map +1 -0
  11. package/dist/cli/commands/fleet-doctor.js +481 -0
  12. package/dist/cli/commands/fleet-doctor.js.map +1 -0
  13. package/dist/cli/commands/fleet.d.ts +83 -0
  14. package/dist/cli/commands/fleet.d.ts.map +1 -0
  15. package/dist/cli/commands/fleet.js +225 -0
  16. package/dist/cli/commands/fleet.js.map +1 -0
  17. package/dist/cli/commands/init.d.ts.map +1 -1
  18. package/dist/cli/commands/init.js +8 -0
  19. package/dist/cli/commands/init.js.map +1 -1
  20. package/dist/cli/commands/migrate.d.ts +1 -0
  21. package/dist/cli/commands/migrate.d.ts.map +1 -1
  22. package/dist/cli/commands/registry-prune.d.ts +43 -6
  23. package/dist/cli/commands/registry-prune.d.ts.map +1 -1
  24. package/dist/cli/commands/registry-prune.js +53 -14
  25. package/dist/cli/commands/registry-prune.js.map +1 -1
  26. package/dist/cli/commands/restart-self.d.ts +111 -0
  27. package/dist/cli/commands/restart-self.d.ts.map +1 -0
  28. package/dist/cli/commands/restart-self.js +312 -0
  29. package/dist/cli/commands/restart-self.js.map +1 -0
  30. package/dist/cli/commands/routing-doctor-gh.d.ts +29 -0
  31. package/dist/cli/commands/routing-doctor-gh.d.ts.map +1 -0
  32. package/dist/cli/commands/routing-doctor-gh.js +103 -0
  33. package/dist/cli/commands/routing-doctor-gh.js.map +1 -0
  34. package/dist/cli/commands/routing-doctor.d.ts +183 -0
  35. package/dist/cli/commands/routing-doctor.d.ts.map +1 -0
  36. package/dist/cli/commands/routing-doctor.js +504 -0
  37. package/dist/cli/commands/routing-doctor.js.map +1 -0
  38. package/dist/cli/commands/update.d.ts.map +1 -1
  39. package/dist/cli/commands/update.js +9 -0
  40. package/dist/cli/commands/update.js.map +1 -1
  41. package/dist/cli/host-prelude.d.ts +50 -0
  42. package/dist/cli/host-prelude.d.ts.map +1 -0
  43. package/dist/cli/host-prelude.js +256 -0
  44. package/dist/cli/host-prelude.js.map +1 -0
  45. package/dist/cli/index.js +89 -0
  46. package/dist/cli/index.js.map +1 -1
  47. package/package.json +2 -2
  48. package/plugin/rules/coordination.md +10 -0
  49. package/plugin/rules/silent-fallback-hazards.md +19 -4
  50. package/scripts/emit-turn-receipt.sh +44 -4
@@ -11,6 +11,16 @@
11
11
  # structurally (closes the #437 send≠receipt gap). A prompt with NO marker
12
12
  # (a typed prompt, a non-routed turn) is a no-op — exit 0, emit nothing.
13
13
  #
14
+ # DR-030 keystone (groundnuty/macf#568): IN ADDITION to the span, this hook
15
+ # appends one LOCAL turn-receipt line per marker to
16
+ # `$(dirname MACF_LOG_PATH)/processed-receipts.jsonl`
17
+ # (`{"ts":<epoch-ms>,"run_id":"<run_id>","agent":"<agent>"}`). The channel-server
18
+ # reads the most-recent receipt for `/health.last_processed`, making the
19
+ # passive-Processed tier a real LOCAL self-report (no Tempo round-trip). The
20
+ # receipt is ADDITIVE and does NOT depend on curl/openssl or a live OTLP endpoint;
21
+ # it is fail-open + non-blocking like the rest of this async hook (MACF_LOG_PATH
22
+ # unset → receipt skipped, a graceful no-op).
23
+ #
14
24
  # Registered `async: true` (settings.json) so it never adds turn latency. It
15
25
  # NEVER blocks the turn: any failure path exits 0 (with a stderr WARN on a
16
26
  # genuine emit error — fail-loud per silent-fallback-hazards.md Instance 8).
@@ -39,19 +49,49 @@ fi
39
49
  MARKERS="$(printf '%s' "$PROMPT" | grep -oE '\[macf-route:[0-9]+:[a-z0-9-]+\]' | sort -u || true)"
40
50
  [ -z "$MARKERS" ] && exit 0
41
51
 
42
- # Need curl + openssl to emit; absent degrade silently (no span, no noise).
43
- command -v curl >/dev/null 2>&1 || exit 0
44
- command -v openssl >/dev/null 2>&1 || exit 0
52
+ # The OTLP span needs curl + openssl. The LOCAL receipt below does NOT it must
53
+ # land regardless (DR-030 passive-Processed is a real LOCAL self-report, working
54
+ # even on a host without curl/openssl or without a live OTLP endpoint). So gate
55
+ # ONLY the span on a flag; never exit before writing the receipt.
56
+ CAN_EMIT_SPAN=1
57
+ command -v curl >/dev/null 2>&1 || CAN_EMIT_SPAN=0
58
+ command -v openssl >/dev/null 2>&1 || CAN_EMIT_SPAN=0
45
59
 
46
60
  BASE="${OTEL_EXPORTER_OTLP_ENDPOINT:-http://orzech-dev-agents-monitoring.tail491af.ts.net:4318}"
47
61
  BASE="${BASE%/v1/traces}"
48
62
 
49
- # One independent span per distinct marker (own trace/span id + timestamp).
63
+ # DR-030 local turn-receipt sink (groundnuty/macf#568): a sibling of MACF_LOG_PATH.
64
+ # Empty when MACF_LOG_PATH is unset → the receipt write is skipped (graceful no-op).
65
+ RECEIPT_SINK=""
66
+ [ -n "${MACF_LOG_PATH:-}" ] && RECEIPT_SINK="$(dirname "$MACF_LOG_PATH")/processed-receipts.jsonl"
67
+
68
+ # One independent span per distinct marker (own trace/span id + timestamp), plus
69
+ # one local receipt per marker (the receipt lands even when the span can't).
50
70
  printf '%s\n' "$MARKERS" | while IFS= read -r MARKER; do
51
71
  [ -z "$MARKER" ] && continue
52
72
  RUN_ID="$(printf '%s' "$MARKER" | sed -E 's/.*\[macf-route:([0-9]+):([a-z0-9-]+)\].*/\1/')"
53
73
  AGENT="$(printf '%s' "$MARKER" | sed -E 's/.*\[macf-route:([0-9]+):([a-z0-9-]+)\].*/\2/')"
54
74
 
75
+ # DR-030 keystone: append the LOCAL turn-receipt — ADDITIVE to the span — so the
76
+ # agent's own /health.last_processed self-reports "I processed routed traffic at
77
+ # T" without Tempo. Fail-open + non-blocking (any error swallowed; this async
78
+ # hook must NEVER fail a turn). epoch-ms: `date +%s%3N` is GNU; a BSD/mac date
79
+ # leaves a literal `N` → fall back to seconds×1000 (the `*N` glob catches it).
80
+ if [ -n "$RECEIPT_SINK" ]; then
81
+ TS_MS="$(date +%s%3N 2>/dev/null || true)"
82
+ case "$TS_MS" in
83
+ *N|'' ) TS_MS="$(( $(date +%s) * 1000 ))" ;;
84
+ esac
85
+ {
86
+ mkdir -p "$(dirname "$RECEIPT_SINK")" 2>/dev/null &&
87
+ printf '{"ts":%s,"run_id":"%s","agent":"%s"}\n' "$TS_MS" "$RUN_ID" "$AGENT" >> "$RECEIPT_SINK"
88
+ } 2>/dev/null || true
89
+ fi
90
+
91
+ # Span requires curl + openssl; the local receipt above already landed, so just
92
+ # skip the span for this marker when we can't emit it.
93
+ [ "$CAN_EMIT_SPAN" = 1 ] || continue
94
+
55
95
  # Nanosecond epoch. `date +%s%N` is GNU-only (substrate is Linux); on a BSD/mac
56
96
  # date that prints a literal `N`, fall back to seconds×1e9.
57
97
  NOW="$(date +%s%N 2>/dev/null || true)"