sneakoscope 0.3.0
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.
- package/LICENSE +21 -0
- package/README.md +272 -0
- package/bin/sks.mjs +8 -0
- package/docs/PERFORMANCE.md +39 -0
- package/package.json +46 -0
- package/src/cli/main.mjs +358 -0
- package/src/core/codex-adapter.mjs +49 -0
- package/src/core/db-safety.mjs +347 -0
- package/src/core/decision-contract.mjs +120 -0
- package/src/core/fsx.mjs +328 -0
- package/src/core/hooks-runtime.mjs +110 -0
- package/src/core/hproof.mjs +39 -0
- package/src/core/init.mjs +135 -0
- package/src/core/mission.mjs +56 -0
- package/src/core/no-question-guard.mjs +53 -0
- package/src/core/questions.mjs +99 -0
- package/src/core/retention.mjs +140 -0
- package/src/core/rust-accelerator.mjs +19 -0
- package/src/core/triwiki-attention.mjs +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DCODEX contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Sneakoscope Codex
|
|
2
|
+
|
|
3
|
+
Sneakoscope Codex is a zero-runtime-dependency Node.js harness for running Codex CLI in a more controlled project workflow. It adds mandatory clarification before autonomous work, a Ralph no-question execution loop, H-Proof completion gates, conservative database safety checks, bounded logs/storage, and optional GPT Image 2 visual cartridges.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g sneakoscope
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The npm package name is `sneakoscope`; the command is branded as SKS and exposed as lowercase `sks` for shell portability.
|
|
10
|
+
|
|
11
|
+
`@openai/codex` is intentionally not bundled. Install Codex separately, or set `SKS_CODEX_BIN` to the Codex executable you want Sneakoscope Codex to supervise.
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Node.js `>=20.11`
|
|
16
|
+
- Codex CLI authentication for live Ralph runs
|
|
17
|
+
- No runtime npm dependencies in the Sneakoscope Codex package
|
|
18
|
+
- Optional Rust helper: compile `crates/sks-core` yourself and expose `sks-rs` on `PATH`, or set `SKS_RS_BIN`
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
sks doctor --fix
|
|
24
|
+
sks init
|
|
25
|
+
sks selftest --mock
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Create a Ralph mission:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
sks ralph prepare "결제 실패 재시도 로직 개선"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Answer every generated slot, seal the decision contract, then run:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cat .sneakoscope/missions/<MISSION_ID>/questions.md
|
|
38
|
+
cp .sneakoscope/missions/<MISSION_ID>/required-answers.schema.json answers.json
|
|
39
|
+
# edit answers.json
|
|
40
|
+
sks ralph answer <MISSION_ID> answers.json
|
|
41
|
+
sks ralph run <MISSION_ID> --max-cycles 8
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For a local smoke test that does not call a model:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
sks ralph run latest --mock
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## What Sneakoscope Codex Adds
|
|
51
|
+
|
|
52
|
+
- **Mandatory clarification**: `ralph prepare` generates required decision slots before autonomous execution can start.
|
|
53
|
+
- **Sealed decision contract**: `ralph answer` validates answers and writes `decision-contract.json`.
|
|
54
|
+
- **No-question Ralph loop**: after `ralph run` starts, Ralph must resolve ambiguity with the sealed contract instead of asking the user.
|
|
55
|
+
- **Database guard**: destructive DB operations, production writes, unsafe Supabase MCP configuration, and direct live SQL mutations are blocked or warned on.
|
|
56
|
+
- **H-Proof done gate**: completion requires supported critical claims, reviewed DB safety state, acceptable visual/wiki drift, and required test evidence.
|
|
57
|
+
- **Bounded runtime state**: child process output is tailed, logs are rotated/compacted, and old mission artifacts can be pruned.
|
|
58
|
+
- **Visual cartridges**: `gx` creates metadata-first visual cartridges where `vgraph.json` remains the source of truth and image generation is delegated to Codex/GPT Image 2.
|
|
59
|
+
|
|
60
|
+
## Ralph Workflow
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
ralph prepare
|
|
64
|
+
-> create mission
|
|
65
|
+
-> generate questions.md and required-answers.schema.json
|
|
66
|
+
|
|
67
|
+
ralph answer
|
|
68
|
+
-> validate answers.json
|
|
69
|
+
-> seal decision-contract.json
|
|
70
|
+
|
|
71
|
+
ralph run
|
|
72
|
+
-> activate no-question lock
|
|
73
|
+
-> scan database safety state
|
|
74
|
+
-> run supervised Codex cycles
|
|
75
|
+
-> evaluate done-gate.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Core invariants:
|
|
79
|
+
|
|
80
|
+
1. Ralph can ask questions only during `prepare`.
|
|
81
|
+
2. `run` is locked until every required answer is supplied.
|
|
82
|
+
3. New ambiguity during `run` is resolved by the sealed decision ladder.
|
|
83
|
+
4. Hooks help enforce the policy, but the Sneakoscope Codex supervisor and mission files remain the source of truth.
|
|
84
|
+
5. Database destructive operations are never allowed.
|
|
85
|
+
6. Generated images are not authoritative; `vgraph.json` is.
|
|
86
|
+
7. Unsupported critical claims block completion.
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
sks doctor [--fix] [--json]
|
|
92
|
+
sks init [--force]
|
|
93
|
+
sks selftest [--mock]
|
|
94
|
+
|
|
95
|
+
sks ralph prepare "task"
|
|
96
|
+
sks ralph answer <mission-id|latest> <answers.json>
|
|
97
|
+
sks ralph run <mission-id|latest> [--mock] [--max-cycles N]
|
|
98
|
+
sks ralph status <mission-id|latest>
|
|
99
|
+
|
|
100
|
+
sks db policy
|
|
101
|
+
sks db scan [--migrations] [--json]
|
|
102
|
+
sks db mcp-config --project-ref <ref> [--features database,docs]
|
|
103
|
+
sks db classify --sql "DROP TABLE users"
|
|
104
|
+
sks db classify --command "supabase db reset"
|
|
105
|
+
sks db check --sql "SELECT * FROM users LIMIT 10"
|
|
106
|
+
sks db check --command "supabase db reset"
|
|
107
|
+
sks db check --file ./migration.sql
|
|
108
|
+
|
|
109
|
+
sks hproof check [mission-id|latest]
|
|
110
|
+
sks gx init [name]
|
|
111
|
+
sks gx render|validate|drift
|
|
112
|
+
sks profile show
|
|
113
|
+
sks profile set <model>
|
|
114
|
+
sks gc [--dry-run] [--json]
|
|
115
|
+
sks stats [--json]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`sks memory` is currently an alias for garbage collection/retention handling.
|
|
119
|
+
|
|
120
|
+
## Database Safety
|
|
121
|
+
|
|
122
|
+
Sneakoscope Codex treats database access as high risk across Supabase MCP, Supabase CLI, Postgres, Prisma, Drizzle, Knex, Sequelize, `psql`, SQL files, and MCP-shaped payloads.
|
|
123
|
+
|
|
124
|
+
Always blocked:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
DROP DATABASE / SCHEMA / TABLE / VIEW / FUNCTION / TRIGGER / TYPE / EXTENSION
|
|
128
|
+
TRUNCATE
|
|
129
|
+
mass DELETE / UPDATE
|
|
130
|
+
ALTER TABLE ... DROP / RENAME
|
|
131
|
+
CREATE OR REPLACE
|
|
132
|
+
DROP ... CASCADE
|
|
133
|
+
GRANT / REVOKE
|
|
134
|
+
DISABLE RLS
|
|
135
|
+
supabase db reset / push
|
|
136
|
+
supabase migration repair / squash
|
|
137
|
+
project or branch delete/reset/merge commands
|
|
138
|
+
production writes
|
|
139
|
+
direct live writes through execute_sql
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Allowed by default:
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
SELECT, WITH ... SELECT, SHOW, EXPLAIN, DESCRIBE
|
|
146
|
+
read-only, project-scoped Supabase MCP
|
|
147
|
+
local or preview migration-file proposals when the sealed contract allows them
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Recommended Supabase MCP URL shape:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
https://mcp.supabase.com/mcp?project_ref=<project_ref>&read_only=true&features=database,docs
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Useful checks:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
sks db policy
|
|
160
|
+
sks db scan --migrations
|
|
161
|
+
sks db mcp-config --project-ref <supabase_project_ref>
|
|
162
|
+
sks db check --sql "DROP TABLE users"
|
|
163
|
+
sks db check --command "supabase db reset"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Hooks are strongest for Codex tool execution paths, but Sneakoscope Codex does not rely on hooks alone. Ralph startup also scans DB/MCP configuration, and the supervised prompt embeds the DB policy.
|
|
167
|
+
|
|
168
|
+
## H-Proof Done Gate
|
|
169
|
+
|
|
170
|
+
Ralph completion is evaluated through `.sneakoscope/missions/<MISSION_ID>/done-gate.json`.
|
|
171
|
+
|
|
172
|
+
A mission cannot pass when:
|
|
173
|
+
|
|
174
|
+
- `decision-contract.json` is missing
|
|
175
|
+
- unsupported critical claims are present
|
|
176
|
+
- a database safety violation or destructive DB attempt is recorded
|
|
177
|
+
- DB safety logs exist but have not been reviewed
|
|
178
|
+
- required tests lack evidence
|
|
179
|
+
- visual or wiki drift is marked `high`
|
|
180
|
+
|
|
181
|
+
Run the evaluator directly with:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
sks hproof check latest
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Runtime State
|
|
188
|
+
|
|
189
|
+
`sks init` creates the local control surface:
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
.sneakoscope/ mission state, policy, retention, logs, GX cartridges
|
|
193
|
+
.codex/config.toml Codex profiles used by Sneakoscope Codex
|
|
194
|
+
.codex/hooks.json hook entrypoints
|
|
195
|
+
.agents/skills/ Sneakoscope Codex helper skills
|
|
196
|
+
AGENTS.md managed repository rules block
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Storage is intentionally bounded:
|
|
200
|
+
|
|
201
|
+
- process stdout/stderr are kept as bounded tails
|
|
202
|
+
- large outputs are written to files
|
|
203
|
+
- recursive scans have file/depth caps
|
|
204
|
+
- `sks gc` compacts oversized JSONL logs and prunes old artifacts
|
|
205
|
+
- `sks stats` reports package and `.sneakoscope` storage size
|
|
206
|
+
|
|
207
|
+
See [docs/PERFORMANCE.md](docs/PERFORMANCE.md) for the detailed resource policy.
|
|
208
|
+
|
|
209
|
+
## Visual Cartridges
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
sks gx init architecture-atlas
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This creates:
|
|
216
|
+
|
|
217
|
+
```text
|
|
218
|
+
.sneakoscope/gx/cartridges/<name>/vgraph.json
|
|
219
|
+
.sneakoscope/gx/cartridges/<name>/beta.json
|
|
220
|
+
.sneakoscope/gx/cartridges/<name>/image-prompt.md
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The intended flow is metadata first:
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
vgraph.json
|
|
227
|
+
-> image-prompt.md
|
|
228
|
+
-> Codex $imagegen / GPT Image 2
|
|
229
|
+
-> sheet.png
|
|
230
|
+
-> vision parse.json
|
|
231
|
+
-> validate against vgraph.json
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## TriWiki Context Compression
|
|
235
|
+
|
|
236
|
+
TriWiki is a harness-level context selection strategy, not a model-internal modification. It scores claims and memory entries by geometric distance, authority, freshness, risk, and token cost, then builds small context capsules for the current mission.
|
|
237
|
+
|
|
238
|
+
Default context layers:
|
|
239
|
+
|
|
240
|
+
```text
|
|
241
|
+
Q4 control bits
|
|
242
|
+
Q3 tags
|
|
243
|
+
Q2 fact cards when useful
|
|
244
|
+
Q1 evidence snippets for verification
|
|
245
|
+
Q0 raw logs only when necessary
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Package Layout
|
|
249
|
+
|
|
250
|
+
```text
|
|
251
|
+
bin/sks.mjs CLI executable
|
|
252
|
+
src/cli/main.mjs command router and Ralph loop
|
|
253
|
+
src/core/db-safety.mjs SQL, CLI, and MCP payload classifier
|
|
254
|
+
src/core/hproof.mjs done-gate evaluator
|
|
255
|
+
src/core/init.mjs project bootstrap and hook/skill installation
|
|
256
|
+
src/core/retention.mjs storage report and garbage collection policy
|
|
257
|
+
src/core/triwiki-attention.mjs
|
|
258
|
+
docs/PERFORMANCE.md resource and leak policy
|
|
259
|
+
crates/sks-core/ optional Rust helper source, not shipped in npm package
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The published npm package is allowlisted to `bin`, `src`, `docs`, `README.md`, and `LICENSE`; `.sneakoscope`, `.codex`, `.agents`, Rust sources, archives, and local state are excluded.
|
|
263
|
+
|
|
264
|
+
## Development
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npm run packcheck
|
|
268
|
+
npm run selftest
|
|
269
|
+
npm run doctor
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`npm run selftest` uses the mock path and does not call a model. Live Ralph runs require a working Codex CLI installation and authentication.
|
package/bin/sks.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Sneakoscope Codex performance and leak policy
|
|
2
|
+
|
|
3
|
+
Sneakoscope Codex v0.2 is designed to keep runtime, package size, RAM, and storage bounded.
|
|
4
|
+
|
|
5
|
+
## Speed
|
|
6
|
+
|
|
7
|
+
- `codex exec` output is streamed to files and only a bounded tail is retained in memory.
|
|
8
|
+
- Ralph cycles run under a timeout and bounded max cycles.
|
|
9
|
+
- TriWiki claim selection uses bounded top-K selection instead of sorting unbounded context into prompts.
|
|
10
|
+
- `sks gc` runs after Ralph cycles by default.
|
|
11
|
+
|
|
12
|
+
## Package size
|
|
13
|
+
|
|
14
|
+
- The npm package has zero runtime dependencies.
|
|
15
|
+
- `@openai/codex` is no longer bundled. Users install Codex separately or set `SKS_CODEX_BIN`.
|
|
16
|
+
- Optional Rust source is in `crates/` for the Git repo, but is excluded from the npm package by the `files` allowlist.
|
|
17
|
+
|
|
18
|
+
## Memory leaks
|
|
19
|
+
|
|
20
|
+
- Child process stdout/stderr never accumulate unbounded strings.
|
|
21
|
+
- Large outputs are written to log files and returned as tails.
|
|
22
|
+
- Recursive file walking has file/depth caps.
|
|
23
|
+
- No long-lived global caches are used.
|
|
24
|
+
|
|
25
|
+
## Storage leaks
|
|
26
|
+
|
|
27
|
+
- `.sneakoscope/policy.json` controls retention.
|
|
28
|
+
- Old missions, old Ralph cycle directories, arenas, temp files, and oversized JSONL logs are removed or rotated by `sks gc`.
|
|
29
|
+
- `sks stats` reports package/state size.
|
|
30
|
+
|
|
31
|
+
## Rust decision
|
|
32
|
+
|
|
33
|
+
Rust is useful for CPU-heavy long-running kernels, but not for the default npm package yet: native binaries increase package size and create OS/architecture install failure modes. Sneakoscope Codex therefore ships a zero-dependency Node runtime by default and includes an optional zero-dependency Rust helper source at `crates/sks-core` for future builds or users who want to compile locally.
|
|
34
|
+
|
|
35
|
+
## Database safety resource policy
|
|
36
|
+
|
|
37
|
+
Sneakoscope Codex v0.3 adds a DB Safety Guard without adding runtime dependencies. It scans hook payloads and CLI commands with bounded string traversal and blocks high-risk database operations before Codex can execute them.
|
|
38
|
+
|
|
39
|
+
Blocked classes include destructive SQL, direct remote SQL mutation, `supabase db reset`, `supabase db push`, migration history repair/squash, and project/branch destructive commands. The guard is intentionally conservative: when unsure, it blocks or warns rather than allowing a potentially destructive database operation.
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sneakoscope",
|
|
3
|
+
"displayName": "Sneakoscope Codex",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "Sneakoscope Codex: database-safe, performance-bounded Codex CLI harness with Ralph no-question loop, H-Proof gates, GPT Image 2 workflow, and TriWiki compression.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sks": "bin/sks.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"src",
|
|
13
|
+
"docs",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.11"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"selftest": "node ./bin/sks.mjs selftest --mock",
|
|
22
|
+
"doctor": "node ./bin/sks.mjs doctor",
|
|
23
|
+
"packcheck": "find bin src -name '*.mjs' -print0 | xargs -0 -n1 node --check",
|
|
24
|
+
"prepack": "npm run packcheck && npm run selftest",
|
|
25
|
+
"prepublishOnly": "npm run packcheck && npm run selftest"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"codex",
|
|
29
|
+
"sks",
|
|
30
|
+
"ai-agent",
|
|
31
|
+
"harness",
|
|
32
|
+
"ralph",
|
|
33
|
+
"llm-wiki",
|
|
34
|
+
"gpt-image-2",
|
|
35
|
+
"resource-safe",
|
|
36
|
+
"database-safe",
|
|
37
|
+
"supabase-mcp",
|
|
38
|
+
"bounded-memory",
|
|
39
|
+
"storage-safe",
|
|
40
|
+
"rust-optional",
|
|
41
|
+
"supabase",
|
|
42
|
+
"mcp-safety",
|
|
43
|
+
"db-guardian"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT"
|
|
46
|
+
}
|