@matt82198/aesop 0.1.0-beta.3 → 0.1.0-beta.4

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 (108) hide show
  1. package/CHANGELOG.md +37 -94
  2. package/CLAUDE-TEMPLATE.md +115 -0
  3. package/README.md +89 -264
  4. package/aesop.config.example.json +27 -26
  5. package/bin/CLAUDE.md +39 -0
  6. package/bin/cli.js +368 -24
  7. package/daemons/CLAUDE.md +33 -0
  8. package/daemons/backup-fleet.sh +92 -21
  9. package/daemons/run-watchdog.sh +90 -10
  10. package/dash/CLAUDE.md +32 -0
  11. package/dash/dash-extra.mjs +194 -21
  12. package/dash/watchdog-gui.sh +23 -6
  13. package/docs/BEHAVIORAL-PR-REVIEW.md +86 -0
  14. package/docs/CHECKPOINTING.md +100 -0
  15. package/docs/DISPATCH-MODEL.md +11 -7
  16. package/docs/FORENSICS.md +204 -0
  17. package/docs/GOVERNANCE.md +4 -2
  18. package/docs/HOOK-INSTALL.md +307 -0
  19. package/docs/HOW-THE-LOOP-WORKS.md +175 -0
  20. package/docs/MEMORY-TEMPLATE.md +61 -0
  21. package/docs/README.md +44 -0
  22. package/docs/RELIABILITY.md +61 -0
  23. package/docs/RESTORE.md +397 -0
  24. package/docs/SCRIPTS-POLICY.md +97 -0
  25. package/docs/spikes/tiered-cognition/ACTIVATION.md +125 -0
  26. package/docs/spikes/tiered-cognition/DESIGN.md +287 -0
  27. package/docs/spikes/tiered-cognition/FINDINGS.md +113 -0
  28. package/docs/spikes/tiered-cognition/README.md +29 -0
  29. package/docs/spikes/tiered-cognition/aesop-cognition.example.md +32 -0
  30. package/docs/spikes/tiered-cognition/force-model-policy.merged.mjs +673 -0
  31. package/docs/spikes/tiered-cognition/strip-tools-hook.mjs +434 -0
  32. package/hooks/CLAUDE.md +38 -0
  33. package/hooks/claude/force-model-policy.mjs +159 -0
  34. package/hooks/pre-push-policy.sh +753 -0
  35. package/monitor/.signal-state.json +3 -0
  36. package/monitor/ACTIONS.log +1 -0
  37. package/monitor/BRIEF.md +24 -0
  38. package/monitor/CHARTER.md +29 -8
  39. package/monitor/CLAUDE.md +40 -0
  40. package/monitor/SIGNALS.json +54 -0
  41. package/monitor/collect-signals.mjs +529 -62
  42. package/package.json +12 -3
  43. package/skills/CLAUDE.md +3 -0
  44. package/skills/power/SKILL.md +161 -0
  45. package/tools/CLAUDE.md +191 -0
  46. package/tools/__pycache__/buildlog.cpython-314.pyc +0 -0
  47. package/tools/__pycache__/ci_merge_wait.cpython-314.pyc +0 -0
  48. package/tools/__pycache__/ensure_state.cpython-314.pyc +0 -0
  49. package/tools/__pycache__/eod_sweep.cpython-314.pyc +0 -0
  50. package/tools/__pycache__/fleet_ledger.cpython-314.pyc +0 -0
  51. package/tools/__pycache__/heartbeat.cpython-314.pyc +0 -0
  52. package/tools/__pycache__/inbox_drain.cpython-314.pyc +0 -0
  53. package/tools/__pycache__/launch_tui.cpython-314.pyc +0 -0
  54. package/tools/__pycache__/orchestrator_status.cpython-314.pyc +0 -0
  55. package/tools/__pycache__/power_selftest.cpython-314.pyc +0 -0
  56. package/tools/__pycache__/prepublish_scan.cpython-314.pyc +0 -0
  57. package/tools/__pycache__/rotate_logs.cpython-314.pyc +0 -0
  58. package/tools/__pycache__/scanner_selftest.cpython-314.pyc +0 -0
  59. package/tools/__pycache__/secret_scan.cpython-314.pyc +0 -0
  60. package/tools/__pycache__/stall_check.cpython-314.pyc +0 -0
  61. package/tools/__pycache__/verify_dash.cpython-314.pyc +0 -0
  62. package/tools/__pycache__/verify_submit_encoding.cpython-314.pyc +0 -0
  63. package/tools/agent-forensics.sh +186 -0
  64. package/tools/buildlog.py +182 -0
  65. package/tools/ci_merge_wait.py +204 -0
  66. package/tools/ensure_state.py +94 -0
  67. package/tools/eod_sweep.py +239 -0
  68. package/tools/fleet_ledger.py +272 -0
  69. package/tools/heartbeat.py +131 -0
  70. package/tools/inbox_drain.py +249 -0
  71. package/tools/launch_tui.py +51 -3
  72. package/tools/lock.mjs +211 -0
  73. package/tools/metrics_gate.py +205 -0
  74. package/tools/orchestrator_status.py +99 -0
  75. package/tools/power_selftest.py +386 -0
  76. package/tools/prepublish_scan.py +84 -0
  77. package/tools/proposals.mjs +248 -0
  78. package/tools/reconstitute.sh +467 -0
  79. package/tools/rotate_logs.py +228 -0
  80. package/tools/scanner_selftest.py +303 -0
  81. package/tools/secret_scan.py +131 -31
  82. package/tools/stall_check.py +172 -0
  83. package/tools/verify_dash.py +694 -0
  84. package/tools/verify_submit_encoding.py +194 -0
  85. package/ui/CLAUDE.md +109 -0
  86. package/ui/__pycache__/agents.cpython-314.pyc +0 -0
  87. package/ui/__pycache__/collectors.cpython-314.pyc +0 -0
  88. package/ui/__pycache__/config.cpython-314.pyc +0 -0
  89. package/ui/__pycache__/csrf.cpython-314.pyc +0 -0
  90. package/ui/__pycache__/handler.cpython-314.pyc +0 -0
  91. package/ui/__pycache__/render.cpython-314.pyc +0 -0
  92. package/ui/__pycache__/serve.cpython-314.pyc +0 -0
  93. package/ui/__pycache__/sse.cpython-314.pyc +0 -0
  94. package/ui/agents.py +179 -0
  95. package/ui/api/__init__.py +84 -0
  96. package/ui/api/__pycache__/__init__.cpython-314.pyc +0 -0
  97. package/ui/api/__pycache__/submit.cpython-314.pyc +0 -0
  98. package/ui/api/__pycache__/tracker.cpython-314.pyc +0 -0
  99. package/ui/api/submit.py +58 -0
  100. package/ui/api/tracker.py +116 -0
  101. package/ui/collectors.py +586 -0
  102. package/ui/config.py +114 -0
  103. package/ui/csrf.py +140 -0
  104. package/ui/handler.py +426 -0
  105. package/ui/render.py +29 -0
  106. package/ui/serve.py +68 -796
  107. package/ui/sse.py +168 -0
  108. package/ui/templates/dashboard.html +1202 -0
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Aesop UI API — tracker CRUD logic (wave-10 P0 split from handler.py).
4
+
5
+ Free functions: take already-parsed request input (headers/body bytes/path
6
+ params extracted by ui/handler.py) and call collectors' tracker CRUD,
7
+ returning (status_code, dict). No self/HTTP coupling -- ui/handler.py owns
8
+ parsing the raw request and writing the HTTP response bytes.
9
+
10
+ Every mutation here is CSRF-gated via api.validate_mutation() (create) or a
11
+ direct csrf.validate_csrf_request() check performed by the caller before
12
+ delete (see ui/handler.py's handle_tracker_mutate -- CSRF is checked once,
13
+ before the path is even parsed, matching the pre-split handler's ordering).
14
+
15
+ Reads collectors' tracker CRUD, which itself reads config.X live via
16
+ `import config` -- see ui/CLAUDE.md load-bearing rule.
17
+ """
18
+ import json
19
+
20
+ from . import validate_mutation
21
+ from collectors import (create_tracker_item, delete_tracker_item,
22
+ get_tracker_items, update_tracker_item)
23
+
24
+
25
+ def list_items(status=None, priority=None):
26
+ """GET /api/tracker -- list items with optional status/priority filters.
27
+
28
+ Returns:
29
+ (200, items_list) on success.
30
+ (500, error_dict) on failure.
31
+ """
32
+ try:
33
+ items = get_tracker_items(status=status, priority=priority)
34
+ return 200, items
35
+ except Exception as e:
36
+ return 500, {"error": str(e)}
37
+
38
+
39
+ def create(headers, body_bytes):
40
+ """POST /api/tracker -- create a tracker item. CSRF-gated.
41
+
42
+ Args:
43
+ headers: request headers (case-insensitive dict-like).
44
+ body_bytes: raw request body already read + bounded by the caller.
45
+
46
+ Returns:
47
+ (201, item_dict) on success.
48
+ (403, error_dict) on CSRF failure.
49
+ (400, error_dict) on invalid Content-Length or invalid JSON.
50
+ (500, error_dict) on any other failure.
51
+ """
52
+ try:
53
+ ok, result = validate_mutation(headers, body_bytes)
54
+ if not ok:
55
+ status, error = result
56
+ return status, error
57
+ item = create_tracker_item(result)
58
+ return 201, item
59
+ except json.JSONDecodeError:
60
+ return 400, {"error": "Invalid JSON"}
61
+ except Exception as e:
62
+ return 500, {"error": str(e)}
63
+
64
+
65
+ def update(item_id, body_bytes):
66
+ """POST /api/tracker/<id> (default action) -- update a tracker item.
67
+
68
+ CSRF must already have been validated by the caller before invoking this
69
+ (see ui/handler.py's handle_tracker_mutate: CSRF is checked once up front,
70
+ shared with the delete branch). This function only handles JSON parse +
71
+ the update itself, matching the pre-split handler's behavior where a
72
+ malformed JSON body on this path falls through to a generic error rather
73
+ than a dedicated "Invalid JSON" 400 (unlike create()).
74
+
75
+ Args:
76
+ item_id: tracker item id extracted from the URL path by the caller.
77
+ body_bytes: raw request body already read + bounded by the caller.
78
+
79
+ Returns:
80
+ (200, item_dict) on success.
81
+ (404, error_dict) if item_id is unknown.
82
+ (500, error_dict) on any other failure (including malformed JSON --
83
+ preserves the pre-split handler's behavior).
84
+ """
85
+ try:
86
+ body_str = (body_bytes or b'').decode('utf-8', errors='ignore')
87
+ update_data = json.loads(body_str)
88
+ item = update_tracker_item(item_id, update_data)
89
+ return 200, item
90
+ except Exception as e:
91
+ if "404" in str(e):
92
+ return 404, {"error": str(e)}
93
+ return 500, {"error": str(e)}
94
+
95
+
96
+ def delete(item_id):
97
+ """POST /api/tracker/<id>?action=delete -- soft-delete (archive) an item.
98
+
99
+ CSRF must already have been validated by the caller before invoking this
100
+ (see update()'s docstring -- same shared up-front check).
101
+
102
+ Idempotent: deleting an already-archived item succeeds again (re-sets
103
+ status to "archived"), it does not error.
104
+
105
+ Returns:
106
+ (200, item_dict) on success.
107
+ (404, error_dict) if item_id is unknown.
108
+ (500, error_dict) on any other failure.
109
+ """
110
+ try:
111
+ item = delete_tracker_item(item_id)
112
+ return 200, item
113
+ except Exception as e:
114
+ if "404" in str(e):
115
+ return 404, {"error": str(e)}
116
+ return 500, {"error": str(e)}