@routinecrew/routinecode 2.31.63 → 2.31.67
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/bin/cli.sh +7 -0
- package/bin/prompt-vault.js +1 -1
- package/bin/rc-config.js +2 -0
- package/bin/rc-credit-turn.js +1 -218
- package/bin/rc-grant.js +1 -78
- package/bin/rc-team.js +1 -591
- package/bin/seal-open.js +1 -1
- package/hooks/architect-runner.sh +159 -0
- package/hooks/cc-compat-watch.js +1 -70
- package/hooks/hooks-config.json +18 -0
- package/hooks/lib/cc-surface.json +2 -2
- package/hooks/lib/config_bash_track.py +390 -0
- package/hooks/lib/config_guard.py +103 -0
- package/hooks/lib/emit_raw.py +11 -1
- package/hooks/lib/known_solution.py +1 -1
- package/hooks/lib/sync_manager.py +96 -1
- package/hooks/lib/tests/test_config_bash_track.py +189 -0
- package/hooks/lib/tests/test_maintenance_sync.py +190 -0
- package/hooks/maintenance-runner.sh +450 -0
- package/hooks/pending-drainer.sh +12 -7
- package/hooks/post-agent-return.sh +1 -1
- package/hooks/post-bash-knowledge.sh +2 -2
- package/hooks/post-bash-verify.sh +28 -3
- package/hooks/post-build-check.sh +5 -5
- package/hooks/post-delegation-nudge.sh +1 -1
- package/hooks/post-domain-knowledge-record.sh +1 -1
- package/hooks/post-edit-track.sh +26 -1
- package/hooks/post-knowledge-query.sh +2 -2
- package/hooks/pre-agent-briefing.sh +16 -0
- package/hooks/pre-agent-spawn.mjs +1 -1
- package/hooks/pre-bash-guard.sh +19 -0
- package/hooks/pre-edit-config-gate.sh +16 -0
- package/hooks/pre-edit-domain-gate.sh +5 -5
- package/hooks/pre-edit-guard.sh +9 -0
- package/hooks/pre-edit-knowledge-gate.sh +2 -2
- package/hooks/pre-maintenance-guard.sh +48 -0
- package/hooks/pre-read-knowledge-inject.sh +1 -1
- package/hooks/pre-secret-guard.sh +1 -1
- package/hooks/recorder-runner.sh +16 -1
- package/hooks/save-user-message.sh +1 -1
- package/hooks/session-start.sh +69 -7
- package/hooks/stop-claim-check.sh +1 -1
- package/hooks/stop-claim-check.v3.sh +107 -1
- package/hooks/stop-knowledge-remind.sh +2 -2
- package/hooks/user-prompt-submit.sh +23 -7
- package/mcp-db-manager/dist/analyzers/duplicate-detector.js +1 -1
- package/mcp-db-manager/dist/core/model-parser.js +1 -1
- package/mcp-db-manager/dist/core/schema-reader.js +1 -1
- package/mcp-db-manager/dist/executors/migration-executor.js +1 -1
- package/mcp-db-manager/dist/generators/migration-generator.js +1 -1
- package/mcp-db-manager/dist/index.js +1 -1
- package/mcp-db-manager/dist/validators/schema-validator.js +1 -1
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.js +1 -1
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.js +1 -1
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/type-comparator.js +1 -1
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/attestation.js +1 -1
- package/mcp-dev-tester/dist/browser/playwright-manager.js +1 -1
- package/mcp-dev-tester/dist/browser/ui-tester.js +1 -1
- package/mcp-dev-tester/dist/config/project-config.js +1 -1
- package/mcp-dev-tester/dist/index.js +1 -1
- package/mcp-dev-tester/dist/testers/api-tester.js +1 -1
- package/mcp-doc-fetcher/dist/index.js +1 -1
- package/mcp-html-renderer/dist/index.js +1 -1
- package/mcp-html-renderer/dist/preview.js +1 -1
- package/mcp-html-renderer/dist/template-engine.js +1 -1
- package/mcp-intelligence/dist/concept-catalog.js +1 -1
- package/mcp-intelligence/dist/concept-server-proxy.js +1 -1
- package/mcp-intelligence/dist/config-auth.js +1 -1
- package/mcp-intelligence/dist/contracts.generated.js +1 -1
- package/mcp-intelligence/dist/domain-templates.js +1 -1
- package/mcp-intelligence/dist/grounding.js +1 -1
- package/mcp-intelligence/dist/handlers.js +1 -1
- package/mcp-intelligence/dist/index.js +1 -1
- package/mcp-intelligence/dist/intelligence-file.js +1 -1
- package/mcp-intelligence/dist/knowledge-critic.js +1 -1
- package/mcp-intelligence/dist/knowledge-handlers.js +1 -1
- package/mcp-intelligence/dist/mention-extractor.js +1 -1
- package/mcp-intelligence/dist/provenance.js +1 -1
- package/mcp-intelligence/dist/semantic-embedder.js +1 -1
- package/mcp-log-watcher/dist/config-auth.js +1 -1
- package/mcp-log-watcher/dist/file-watcher.js +1 -1
- package/mcp-log-watcher/dist/index.js +1 -1
- package/mcp-log-watcher/dist/known-solutions.js +1 -1
- package/mcp-log-watcher/dist/log-store.js +1 -1
- package/mcp-log-watcher/dist/websocket-server.js +1 -1
- package/mcp-plan-manager/dist/__tests__/file-ops-knowledge-dir.test.js +1 -0
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.js +1 -1
- package/mcp-plan-manager/dist/file-ops.js +1 -1
- package/mcp-plan-manager/dist/index.js +1 -1
- package/mcp-plan-manager/dist/plan-parser.js +1 -1
- package/mcp-project-context/dist/git-ops.js +1 -1
- package/mcp-project-context/dist/index.js +1 -1
- package/mcp-project-context/dist/project-analysis.js +1 -1
- package/mcp-routinecode/dist/agent-tracker.js +1 -1
- package/mcp-routinecode/dist/attestation.js +1 -1
- package/mcp-routinecode/dist/blast-radius.js +1 -1
- package/mcp-routinecode/dist/changeset.js +1 -1
- package/mcp-routinecode/dist/config-auth.js +1 -1
- package/mcp-routinecode/dist/config-map/arch-graph.js +1 -0
- package/mcp-routinecode/dist/config-map/architect-store.js +1 -0
- package/mcp-routinecode/dist/config-map/assign.js +1 -0
- package/mcp-routinecode/dist/config-map/audit-cli.js +1 -0
- package/mcp-routinecode/dist/config-map/audit.js +1 -0
- package/mcp-routinecode/dist/config-map/briefing.js +1 -0
- package/mcp-routinecode/dist/config-map/decisions.js +1 -0
- package/mcp-routinecode/dist/config-map/decls.js +1 -0
- package/mcp-routinecode/dist/config-map/extract.js +1 -0
- package/mcp-routinecode/dist/config-map/gate.js +1 -0
- package/mcp-routinecode/dist/config-map/hash.js +1 -0
- package/mcp-routinecode/dist/config-map/ident-norm.js +1 -0
- package/mcp-routinecode/dist/config-map/index-store.js +1 -0
- package/mcp-routinecode/dist/config-map/light-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/link.js +1 -0
- package/mcp-routinecode/dist/config-map/lookup.js +1 -0
- package/mcp-routinecode/dist/config-map/louvain.js +1 -0
- package/mcp-routinecode/dist/config-map/maintenance-cli.js +1 -0
- package/mcp-routinecode/dist/config-map/names.js +1 -0
- package/mcp-routinecode/dist/config-map/proposals.js +1 -0
- package/mcp-routinecode/dist/config-map/recheck.js +1 -0
- package/mcp-routinecode/dist/config-map/repo-id.js +1 -0
- package/mcp-routinecode/dist/config-map/rule-import.js +1 -0
- package/mcp-routinecode/dist/config-map/scc.js +1 -0
- package/mcp-routinecode/dist/config-map/shape-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/shape.js +1 -0
- package/mcp-routinecode/dist/config-map/snapshot.js +1 -0
- package/mcp-routinecode/dist/config-map/stable-id.js +1 -0
- package/mcp-routinecode/dist/config-map/store.js +1 -0
- package/mcp-routinecode/dist/config-map/task-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/templates.js +1 -0
- package/mcp-routinecode/dist/config-map/types.js +1 -0
- package/mcp-routinecode/dist/contracts.generated.js +1 -1
- package/mcp-routinecode/dist/coverage.js +1 -1
- package/mcp-routinecode/dist/explorer-advisor.js +1 -1
- package/mcp-routinecode/dist/failure-tracker.js +1 -1
- package/mcp-routinecode/dist/file-lock-registry.js +1 -1
- package/mcp-routinecode/dist/file-risk-scorer.js +1 -1
- package/mcp-routinecode/dist/index.js +1 -1
- package/mcp-routinecode/dist/known-solutions.js +1 -1
- package/mcp-routinecode/dist/ledger-miner.js +1 -1
- package/mcp-routinecode/dist/observed-draft.js +1 -1
- package/mcp-routinecode/dist/pattern-matcher.js +1 -1
- package/mcp-routinecode/dist/route-match.js +1 -1
- package/mcp-routinecode/dist/routines.js +1 -1
- package/mcp-routinecode/dist/rule-engine.js +1 -1
- package/mcp-routinecode/dist/rule-promoter.js +1 -1
- package/mcp-routinecode/dist/telemetry-analyzer.js +1 -1
- package/mcp-routinecode/dist/test-runner.js +1 -1
- package/mcp-routinecode/dist/verification.js +0 -0
- package/mcp-routinecode/dist/viral-loop.js +1 -1
- package/mcp-routinecode/package.json +3 -1
- package/package.json +3 -2
- package/plugin/agents/analyzer.md.sealed +1 -0
- package/plugin/agents/architect.md.sealed +1 -0
- package/plugin/agents/crawler.md.sealed +1 -0
- package/plugin/agents/explorer.md.sealed +1 -0
- package/plugin/agents/implementor.md.sealed +1 -0
- package/plugin/agents/looker.md.sealed +1 -0
- package/plugin/agents/planner.md.sealed +1 -0
- package/plugin/agents/recorder.md.sealed +1 -0
- package/plugin/agents/reviewer.md.sealed +1 -0
- package/plugin/agents/verifier.md.sealed +1 -0
- package/plugin/commands/analyze.md.sealed +1 -0
- package/plugin/commands/plan.md.sealed +1 -0
- package/plugin/commands/rc.md.sealed +1 -0
- package/plugin/commands/receipt.md.sealed +1 -0
- package/plugin/commands/recharge.md.sealed +1 -0
- package/plugin/commands/routines.md.sealed +1 -0
- package/plugin/commands/share.md.sealed +1 -0
- package/plugin/routinecode-prompt.md.sealed +1 -0
- package/hooks/tests/cd-bypass.test.py +0 -57
- package/hooks/tests/design09-client.test.py +0 -471
- package/hooks/tests/dev-mode.test.py +0 -62
- package/hooks/tests/gate-integration.test.sh +0 -300
- package/hooks/tests/in-project-relax.test.py +0 -106
- package/hooks/tests/knowledge-loop.test.sh +0 -89
- package/hooks/tests/ledger-bench.sh +0 -115
- package/hooks/tests/ledger-chaos.test.sh +0 -185
- package/hooks/tests/ledger-compat.test.sh +0 -138
- package/hooks/tests/ledger-integration.test.sh +0 -200
- package/hooks/tests/ledger-unit.test.sh +0 -300
- package/hooks/tests/mcp-name-wiring.test.sh +0 -64
- package/hooks/tests/rm-guard.test.py +0 -108
- package/hooks/tests/secret-guard-bypass.test.sh +0 -107
- package/hooks/tests/secret-guard.test.sh +0 -604
- package/hooks/tests/secret-premask.test.py +0 -179
- package/hooks/tests/stop-autoproceed.test.sh +0 -60
- package/hooks/tests/stop-claim-check-v3-sim.sh +0 -224
- package/hooks/tests/stop-claim-check-v3.test.sh +0 -373
- package/hooks/tests/stop-claim-check.test.sh +0 -224
- package/mcp-db-manager/dist/analyzers/duplicate-detector.d.ts +0 -48
- package/mcp-db-manager/dist/analyzers/duplicate-detector.d.ts.map +0 -1
- package/mcp-db-manager/dist/core/model-parser.d.ts +0 -71
- package/mcp-db-manager/dist/core/model-parser.d.ts.map +0 -1
- package/mcp-db-manager/dist/core/schema-reader.d.ts +0 -69
- package/mcp-db-manager/dist/core/schema-reader.d.ts.map +0 -1
- package/mcp-db-manager/dist/executors/migration-executor.d.ts +0 -14
- package/mcp-db-manager/dist/executors/migration-executor.d.ts.map +0 -1
- package/mcp-db-manager/dist/generators/migration-generator.d.ts +0 -69
- package/mcp-db-manager/dist/generators/migration-generator.d.ts.map +0 -1
- package/mcp-db-manager/dist/index.d.ts +0 -7
- package/mcp-db-manager/dist/index.d.ts.map +0 -1
- package/mcp-db-manager/dist/types.d.ts +0 -382
- package/mcp-db-manager/dist/types.d.ts.map +0 -1
- package/mcp-db-manager/dist/validators/schema-validator.d.ts +0 -56
- package/mcp-db-manager/dist/validators/schema-validator.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.d.ts +0 -18
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/type-comparator.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/type-comparator.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/attestation.d.ts +0 -36
- package/mcp-dev-tester/dist/attestation.d.ts.map +0 -1
- package/mcp-dev-tester/dist/browser/playwright-manager.d.ts +0 -148
- package/mcp-dev-tester/dist/browser/playwright-manager.d.ts.map +0 -1
- package/mcp-dev-tester/dist/browser/ui-tester.d.ts +0 -28
- package/mcp-dev-tester/dist/browser/ui-tester.d.ts.map +0 -1
- package/mcp-dev-tester/dist/config/project-config.d.ts +0 -94
- package/mcp-dev-tester/dist/config/project-config.d.ts.map +0 -1
- package/mcp-dev-tester/dist/index.d.ts +0 -3
- package/mcp-dev-tester/dist/index.d.ts.map +0 -1
- package/mcp-dev-tester/dist/testers/api-tester.d.ts +0 -77
- package/mcp-dev-tester/dist/testers/api-tester.d.ts.map +0 -1
- package/mcp-dev-tester/dist/types.d.ts +0 -423
- package/mcp-dev-tester/dist/types.d.ts.map +0 -1
- package/mcp-doc-fetcher/dist/index.d.ts +0 -17
- package/mcp-doc-fetcher/dist/index.d.ts.map +0 -1
- package/mcp-html-renderer/dist/index.d.ts +0 -3
- package/mcp-html-renderer/dist/index.d.ts.map +0 -1
- package/mcp-html-renderer/dist/preview.d.ts +0 -15
- package/mcp-html-renderer/dist/preview.d.ts.map +0 -1
- package/mcp-html-renderer/dist/template-engine.d.ts +0 -46
- package/mcp-html-renderer/dist/template-engine.d.ts.map +0 -1
- package/mcp-intelligence/dist/concept-catalog.d.ts +0 -142
- package/mcp-intelligence/dist/concept-catalog.d.ts.map +0 -1
- package/mcp-intelligence/dist/concept-server-proxy.d.ts +0 -38
- package/mcp-intelligence/dist/concept-server-proxy.d.ts.map +0 -1
- package/mcp-intelligence/dist/config-auth.d.ts +0 -18
- package/mcp-intelligence/dist/config-auth.d.ts.map +0 -1
- package/mcp-intelligence/dist/contracts.generated.d.ts +0 -58
- package/mcp-intelligence/dist/contracts.generated.d.ts.map +0 -1
- package/mcp-intelligence/dist/domain-templates.d.ts +0 -25
- package/mcp-intelligence/dist/domain-templates.d.ts.map +0 -1
- package/mcp-intelligence/dist/grounding.d.ts +0 -77
- package/mcp-intelligence/dist/grounding.d.ts.map +0 -1
- package/mcp-intelligence/dist/handlers.d.ts +0 -72
- package/mcp-intelligence/dist/handlers.d.ts.map +0 -1
- package/mcp-intelligence/dist/index.d.ts +0 -3
- package/mcp-intelligence/dist/index.d.ts.map +0 -1
- package/mcp-intelligence/dist/intelligence-file.d.ts +0 -82
- package/mcp-intelligence/dist/intelligence-file.d.ts.map +0 -1
- package/mcp-intelligence/dist/knowledge-critic.d.ts +0 -28
- package/mcp-intelligence/dist/knowledge-critic.d.ts.map +0 -1
- package/mcp-intelligence/dist/knowledge-handlers.d.ts +0 -358
- package/mcp-intelligence/dist/knowledge-handlers.d.ts.map +0 -1
- package/mcp-intelligence/dist/mention-extractor.d.ts +0 -13
- package/mcp-intelligence/dist/mention-extractor.d.ts.map +0 -1
- package/mcp-intelligence/dist/provenance.d.ts +0 -28
- package/mcp-intelligence/dist/provenance.d.ts.map +0 -1
- package/mcp-intelligence/dist/semantic-embedder.d.ts +0 -25
- package/mcp-intelligence/dist/semantic-embedder.d.ts.map +0 -1
- package/mcp-log-watcher/dist/config-auth.d.ts +0 -16
- package/mcp-log-watcher/dist/config-auth.d.ts.map +0 -1
- package/mcp-log-watcher/dist/file-watcher.d.ts +0 -36
- package/mcp-log-watcher/dist/file-watcher.d.ts.map +0 -1
- package/mcp-log-watcher/dist/index.d.ts +0 -3
- package/mcp-log-watcher/dist/index.d.ts.map +0 -1
- package/mcp-log-watcher/dist/known-solutions.d.ts +0 -60
- package/mcp-log-watcher/dist/known-solutions.d.ts.map +0 -1
- package/mcp-log-watcher/dist/log-store.d.ts +0 -72
- package/mcp-log-watcher/dist/log-store.d.ts.map +0 -1
- package/mcp-log-watcher/dist/types.d.ts +0 -52
- package/mcp-log-watcher/dist/types.d.ts.map +0 -1
- package/mcp-log-watcher/dist/websocket-server.d.ts +0 -44
- package/mcp-log-watcher/dist/websocket-server.d.ts.map +0 -1
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.d.ts +0 -7
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.d.ts.map +0 -1
- package/mcp-plan-manager/dist/file-ops.d.ts +0 -39
- package/mcp-plan-manager/dist/file-ops.d.ts.map +0 -1
- package/mcp-plan-manager/dist/index.d.ts +0 -23
- package/mcp-plan-manager/dist/index.d.ts.map +0 -1
- package/mcp-plan-manager/dist/plan-parser.d.ts +0 -76
- package/mcp-plan-manager/dist/plan-parser.d.ts.map +0 -1
- package/mcp-project-context/dist/git-ops.d.ts +0 -40
- package/mcp-project-context/dist/git-ops.d.ts.map +0 -1
- package/mcp-project-context/dist/index.d.ts +0 -20
- package/mcp-project-context/dist/index.d.ts.map +0 -1
- package/mcp-project-context/dist/project-analysis.d.ts +0 -50
- package/mcp-project-context/dist/project-analysis.d.ts.map +0 -1
- package/mcp-routinecode/dist/agent-tracker.d.ts +0 -68
- package/mcp-routinecode/dist/attestation.d.ts +0 -37
- package/mcp-routinecode/dist/blast-radius.d.ts +0 -83
- package/mcp-routinecode/dist/changeset.d.ts +0 -86
- package/mcp-routinecode/dist/config-auth.d.ts +0 -15
- package/mcp-routinecode/dist/contracts.generated.d.ts +0 -57
- package/mcp-routinecode/dist/coverage.d.ts +0 -49
- package/mcp-routinecode/dist/explorer-advisor.d.ts +0 -34
- package/mcp-routinecode/dist/failure-tracker.d.ts +0 -32
- package/mcp-routinecode/dist/file-lock-registry.d.ts +0 -31
- package/mcp-routinecode/dist/file-risk-scorer.d.ts +0 -27
- package/mcp-routinecode/dist/index.d.ts +0 -13
- package/mcp-routinecode/dist/known-solutions.d.ts +0 -57
- package/mcp-routinecode/dist/ledger-miner.d.ts +0 -19
- package/mcp-routinecode/dist/observed-draft.d.ts +0 -42
- package/mcp-routinecode/dist/pattern-matcher.d.ts +0 -14
- package/mcp-routinecode/dist/route-match.d.ts +0 -24
- package/mcp-routinecode/dist/routines.d.ts +0 -59
- package/mcp-routinecode/dist/rule-engine.d.ts +0 -53
- package/mcp-routinecode/dist/rule-promoter.d.ts +0 -22
- package/mcp-routinecode/dist/telemetry-analyzer.d.ts +0 -56
- package/mcp-routinecode/dist/test-runner.d.ts +0 -66
- package/mcp-routinecode/dist/verification.d.ts +0 -173
- package/mcp-routinecode/dist/viral-loop.d.ts +0 -227
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Phase 1 Sprint 4: Chaos tests — abnormal conditions
|
|
3
|
-
|
|
4
|
-
set -u
|
|
5
|
-
|
|
6
|
-
LIB_DIR="/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib"
|
|
7
|
-
export PYTHONPATH="$LIB_DIR"
|
|
8
|
-
|
|
9
|
-
pass=0
|
|
10
|
-
fail=0
|
|
11
|
-
|
|
12
|
-
assert_eq() {
|
|
13
|
-
local name="$1" got="$2" expected="$3"
|
|
14
|
-
if [ "$got" = "$expected" ]; then
|
|
15
|
-
printf ' \033[32mPASS\033[0m %s\n' "$name"
|
|
16
|
-
pass=$((pass + 1))
|
|
17
|
-
else
|
|
18
|
-
printf ' \033[31mFAIL\033[0m %s (got=%s expected=%s)\n' "$name" "$got" "$expected"
|
|
19
|
-
fail=$((fail + 1))
|
|
20
|
-
fi
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
echo "=== Phase 1 Chaos Tests ==="
|
|
24
|
-
|
|
25
|
-
# 1. 동시 다중 세션 — 5 세션 × 100 write = 500 entries, corrupt 0 (threading 사용)
|
|
26
|
-
TEST_DIR=$(mktemp -d)
|
|
27
|
-
mkdir -p "$TEST_DIR"
|
|
28
|
-
RESULT=$(LEDGER_OVERRIDE="$TEST_DIR" python3 - <<'PYEOF'
|
|
29
|
-
import os, sys, json
|
|
30
|
-
import threading
|
|
31
|
-
sys.path.insert(0, "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib")
|
|
32
|
-
import ledger
|
|
33
|
-
from pathlib import Path
|
|
34
|
-
|
|
35
|
-
test_dir = Path(os.environ['LEDGER_OVERRIDE'])
|
|
36
|
-
ledger.LEDGER_DIR = test_dir
|
|
37
|
-
ledger.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
38
|
-
ledger.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
39
|
-
ledger.ARCHIVE_DIR = test_dir / 'archive'
|
|
40
|
-
ledger.ROTATING_MARKER = test_dir / 'current.jsonl.rotating'
|
|
41
|
-
|
|
42
|
-
def writer(sess_id, n):
|
|
43
|
-
for i in range(n):
|
|
44
|
-
ledger.write_evidence(
|
|
45
|
-
session_id=sess_id, source_hook='chaos-test',
|
|
46
|
-
category='bash_action', subcategory='test', outcome='success',
|
|
47
|
-
payload={'i': i}
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
threads = []
|
|
51
|
-
for sid in range(5):
|
|
52
|
-
t = threading.Thread(target=writer, args=(f'sess-{sid}', 100))
|
|
53
|
-
threads.append(t)
|
|
54
|
-
t.start()
|
|
55
|
-
for t in threads:
|
|
56
|
-
t.join()
|
|
57
|
-
|
|
58
|
-
# Validate
|
|
59
|
-
total = 0
|
|
60
|
-
corrupt = 0
|
|
61
|
-
try:
|
|
62
|
-
with open(ledger.CURRENT_PATH) as f:
|
|
63
|
-
for line in f:
|
|
64
|
-
line = line.strip()
|
|
65
|
-
if not line:
|
|
66
|
-
continue
|
|
67
|
-
total += 1
|
|
68
|
-
try:
|
|
69
|
-
json.loads(line)
|
|
70
|
-
except:
|
|
71
|
-
corrupt += 1
|
|
72
|
-
except FileNotFoundError:
|
|
73
|
-
pass
|
|
74
|
-
print(f"{total},{corrupt}")
|
|
75
|
-
PYEOF
|
|
76
|
-
)
|
|
77
|
-
rm -rf "$TEST_DIR"
|
|
78
|
-
total=$(echo "$RESULT" | cut -d',' -f1)
|
|
79
|
-
corrupt=$(echo "$RESULT" | cut -d',' -f2)
|
|
80
|
-
assert_eq "1. 5 sessions × 100 concurrent writes — total=500" "$total" "500"
|
|
81
|
-
assert_eq "1b. concurrent writes — corrupt=0" "$corrupt" "0"
|
|
82
|
-
|
|
83
|
-
# 2. 권한 없음 (0444 ledger file) → fail-open
|
|
84
|
-
TEST_DIR=$(mktemp -d)
|
|
85
|
-
mkdir -p "$TEST_DIR"
|
|
86
|
-
touch "$TEST_DIR/current.jsonl"
|
|
87
|
-
chmod 0444 "$TEST_DIR/current.jsonl" # read-only
|
|
88
|
-
RESULT=$(LEDGER_OVERRIDE="$TEST_DIR" python3 - <<'PYEOF' 2>/dev/null
|
|
89
|
-
import os, sys
|
|
90
|
-
sys.path.insert(0, "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib")
|
|
91
|
-
import ledger
|
|
92
|
-
from pathlib import Path
|
|
93
|
-
test_dir = Path(os.environ['LEDGER_OVERRIDE'])
|
|
94
|
-
ledger.LEDGER_DIR = test_dir
|
|
95
|
-
ledger.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
96
|
-
ledger.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
97
|
-
ledger.ARCHIVE_DIR = test_dir / 'archive'
|
|
98
|
-
ledger.ROTATING_MARKER = test_dir / 'current.jsonl.rotating'
|
|
99
|
-
|
|
100
|
-
# write_evidence should fail-open (return None, not crash)
|
|
101
|
-
result = ledger.write_evidence(session_id='test', source_hook='chaos')
|
|
102
|
-
# Hook should not raise. result is None or evidence_id.
|
|
103
|
-
print('FAIL_OPEN_OK' if True else 'CRASH')
|
|
104
|
-
PYEOF
|
|
105
|
-
)
|
|
106
|
-
chmod 0644 "$TEST_DIR/current.jsonl" 2>/dev/null
|
|
107
|
-
rm -rf "$TEST_DIR"
|
|
108
|
-
assert_eq "2. read-only ledger → fail-open (no crash)" "$RESULT" "FAIL_OPEN_OK"
|
|
109
|
-
|
|
110
|
-
# 3. Corrupt entry 수동 주입 → reader skip + 정상 entry 반환
|
|
111
|
-
TEST_DIR=$(mktemp -d)
|
|
112
|
-
echo '{"schema_v":1,"evidence_id":"ev-1","ts_ns":1,"session_id":"s","source_hook":"h"}' > "$TEST_DIR/current.jsonl"
|
|
113
|
-
echo 'this is not json' >> "$TEST_DIR/current.jsonl"
|
|
114
|
-
echo '{"schema_v":1,"evidence_id":"ev-2","ts_ns":2,"session_id":"s","source_hook":"h"}' >> "$TEST_DIR/current.jsonl"
|
|
115
|
-
echo 'another corrupt line {' >> "$TEST_DIR/current.jsonl"
|
|
116
|
-
echo '{"schema_v":1,"evidence_id":"ev-3","ts_ns":3,"session_id":"s","source_hook":"h"}' >> "$TEST_DIR/current.jsonl"
|
|
117
|
-
|
|
118
|
-
RESULT=$(LEDGER_OVERRIDE="$TEST_DIR" python3 -c "
|
|
119
|
-
import os, sys
|
|
120
|
-
sys.path.insert(0, '$LIB_DIR')
|
|
121
|
-
import ledger_reader
|
|
122
|
-
from pathlib import Path
|
|
123
|
-
ledger_reader.CURRENT_PATH = Path(os.environ['LEDGER_OVERRIDE']) / 'current.jsonl'
|
|
124
|
-
ledger_reader.PERSISTENT_PATH = Path(os.environ['LEDGER_OVERRIDE']) / 'persistent.jsonl'
|
|
125
|
-
results = ledger_reader.query_evidence(session_id='s')
|
|
126
|
-
print(len(results))
|
|
127
|
-
")
|
|
128
|
-
rm -rf "$TEST_DIR"
|
|
129
|
-
assert_eq "3. corrupt entries skipped, 3 valid returned" "$RESULT" "3"
|
|
130
|
-
|
|
131
|
-
# 4. Hard redact rejection (token survives redaction → entry rejected)
|
|
132
|
-
TEST_DIR=$(mktemp -d)
|
|
133
|
-
RESULT=$(LEDGER_OVERRIDE="$TEST_DIR" python3 - <<'PYEOF' 2>/dev/null
|
|
134
|
-
import os, sys
|
|
135
|
-
sys.path.insert(0, "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib")
|
|
136
|
-
import ledger
|
|
137
|
-
from pathlib import Path
|
|
138
|
-
test_dir = Path(os.environ['LEDGER_OVERRIDE'])
|
|
139
|
-
ledger.LEDGER_DIR = test_dir
|
|
140
|
-
ledger.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
141
|
-
ledger.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
142
|
-
ledger.ARCHIVE_DIR = test_dir / 'archive'
|
|
143
|
-
ledger.ROTATING_MARKER = test_dir / 'current.jsonl.rotating'
|
|
144
|
-
|
|
145
|
-
ev_id = ledger.write_evidence(
|
|
146
|
-
session_id='s', source_hook='h',
|
|
147
|
-
payload={'leaked': 'ghp_abcdefghijklmnopqrstuvwxyz0123456789'}
|
|
148
|
-
)
|
|
149
|
-
print('REJECTED' if ev_id is None else 'ACCEPTED_LEAK')
|
|
150
|
-
PYEOF
|
|
151
|
-
)
|
|
152
|
-
rm -rf "$TEST_DIR"
|
|
153
|
-
assert_eq "4. Hard redact rejects token leak" "$RESULT" "REJECTED"
|
|
154
|
-
|
|
155
|
-
# 5. Disk full simulation (write to /dev/full or read-only dir)
|
|
156
|
-
TEST_DIR="/tmp/chaos-readonly-$$"
|
|
157
|
-
mkdir -p "$TEST_DIR"
|
|
158
|
-
chmod 0555 "$TEST_DIR" # readonly directory → mkdir inside fails
|
|
159
|
-
RESULT=$(LEDGER_OVERRIDE="$TEST_DIR/sub" python3 - <<'PYEOF' 2>/dev/null
|
|
160
|
-
import os, sys
|
|
161
|
-
sys.path.insert(0, "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib")
|
|
162
|
-
import ledger
|
|
163
|
-
from pathlib import Path
|
|
164
|
-
test_dir = Path(os.environ['LEDGER_OVERRIDE'])
|
|
165
|
-
ledger.LEDGER_DIR = test_dir
|
|
166
|
-
ledger.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
167
|
-
ledger.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
168
|
-
ledger.ARCHIVE_DIR = test_dir / 'archive'
|
|
169
|
-
ledger.ROTATING_MARKER = test_dir / 'current.jsonl.rotating'
|
|
170
|
-
|
|
171
|
-
# Write should fail-open
|
|
172
|
-
try:
|
|
173
|
-
ledger.write_evidence(session_id='s', source_hook='h')
|
|
174
|
-
print('NO_CRASH')
|
|
175
|
-
except Exception as e:
|
|
176
|
-
print(f'CRASHED: {e}')
|
|
177
|
-
PYEOF
|
|
178
|
-
)
|
|
179
|
-
chmod 0755 "$TEST_DIR" 2>/dev/null
|
|
180
|
-
rm -rf "$TEST_DIR"
|
|
181
|
-
assert_eq "5. Read-only parent dir → fail-open (no crash)" "$RESULT" "NO_CRASH"
|
|
182
|
-
|
|
183
|
-
echo ""
|
|
184
|
-
echo "=== Result: ${pass} PASS / ${fail} FAIL ==="
|
|
185
|
-
[ "$fail" -eq 0 ] && exit 0 || exit 1
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Phase 1 Sprint 4: Compatibility check
|
|
3
|
-
# Python 3.6~3.12 syntax check (실제 다중 Python 환경 없이 syntax-level 검증)
|
|
4
|
-
|
|
5
|
-
set -u
|
|
6
|
-
|
|
7
|
-
LIB_DIR="/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib"
|
|
8
|
-
|
|
9
|
-
pass=0
|
|
10
|
-
fail=0
|
|
11
|
-
|
|
12
|
-
check() {
|
|
13
|
-
local name="$1" cond="$2"
|
|
14
|
-
if eval "$cond" >/dev/null 2>&1; then
|
|
15
|
-
printf ' \033[32mPASS\033[0m %s\n' "$name"
|
|
16
|
-
pass=$((pass + 1))
|
|
17
|
-
else
|
|
18
|
-
printf ' \033[31mFAIL\033[0m %s\n' "$name"
|
|
19
|
-
fail=$((fail + 1))
|
|
20
|
-
fi
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
echo "=== Phase 1 Compatibility Check ==="
|
|
24
|
-
|
|
25
|
-
# 1. Current Python version
|
|
26
|
-
CURRENT=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
|
27
|
-
echo "Current Python: $CURRENT"
|
|
28
|
-
echo ""
|
|
29
|
-
|
|
30
|
-
# 2. ledger.py syntax check
|
|
31
|
-
check "ledger.py syntax valid" "python3 -c 'import py_compile; py_compile.compile(\"$LIB_DIR/ledger.py\", doraise=True)'"
|
|
32
|
-
|
|
33
|
-
# 3. ledger_reader.py syntax check
|
|
34
|
-
check "ledger_reader.py syntax valid" "python3 -c 'import py_compile; py_compile.compile(\"$LIB_DIR/ledger_reader.py\", doraise=True)'"
|
|
35
|
-
|
|
36
|
-
# 4. AST-based feature usage check (3.6+ vs newer)
|
|
37
|
-
RESULT=$(python3 - <<'PYEOF'
|
|
38
|
-
import ast
|
|
39
|
-
import sys
|
|
40
|
-
|
|
41
|
-
LIB_DIR = "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib"
|
|
42
|
-
|
|
43
|
-
# Features we should NOT use (3.10+)
|
|
44
|
-
FORBIDDEN = {
|
|
45
|
-
'walrus_operator': 'NamedExpr', # 3.8 (we allow), but let's track
|
|
46
|
-
'match_statement': 'Match', # 3.10
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
# Features we accept (3.6+)
|
|
50
|
-
import os
|
|
51
|
-
for fname in ['ledger.py', 'ledger_reader.py']:
|
|
52
|
-
path = os.path.join(LIB_DIR, fname)
|
|
53
|
-
with open(path) as f:
|
|
54
|
-
tree = ast.parse(f.read())
|
|
55
|
-
|
|
56
|
-
issues = []
|
|
57
|
-
for node in ast.walk(tree):
|
|
58
|
-
# Match statement (3.10+)
|
|
59
|
-
if hasattr(ast, 'Match') and isinstance(node, ast.Match):
|
|
60
|
-
issues.append(f'Match statement at line {node.lineno}')
|
|
61
|
-
|
|
62
|
-
if issues:
|
|
63
|
-
print(f'{fname}: {issues}')
|
|
64
|
-
else:
|
|
65
|
-
print(f'{fname}: OK (no 3.10+ features)')
|
|
66
|
-
PYEOF
|
|
67
|
-
)
|
|
68
|
-
echo "$RESULT" | grep -q "OK (no 3.10+ features)" && {
|
|
69
|
-
echo "$RESULT" | head -2
|
|
70
|
-
pass=$((pass + 1))
|
|
71
|
-
printf ' \033[32mPASS\033[0m 4. No 3.10+ features (match statement)\n'
|
|
72
|
-
} || {
|
|
73
|
-
fail=$((fail + 1))
|
|
74
|
-
printf ' \033[31mFAIL\033[0m 4. 3.10+ features detected\n'
|
|
75
|
-
echo "$RESULT"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
# 5. time.time_ns fallback check
|
|
79
|
-
check "5. time.time_ns fallback (3.6 case)" \
|
|
80
|
-
"python3 -c 'import sys; sys.path.insert(0, \"$LIB_DIR\"); import ledger; ledger.time = type(\"t\", (), {\"time\": lambda: 1.0}); ts = ledger._now_ns(); assert ts > 0, ts'"
|
|
81
|
-
|
|
82
|
-
# 6. f-string usage (3.6+) — by definition we use it
|
|
83
|
-
check "6. f-string compat (3.6+)" \
|
|
84
|
-
"grep -q \"f'\\|f\\\"\" \"$LIB_DIR/ledger.py\""
|
|
85
|
-
|
|
86
|
-
# 7. pathlib usage check
|
|
87
|
-
check "7. pathlib (3.5+) usage" \
|
|
88
|
-
"grep -q 'from pathlib import' \"$LIB_DIR/ledger.py\""
|
|
89
|
-
|
|
90
|
-
# 8. secrets.token_hex (3.6+)
|
|
91
|
-
check "8. secrets.token_hex (3.6+) usage" \
|
|
92
|
-
"grep -q 'secrets.token_hex' \"$LIB_DIR/ledger.py\""
|
|
93
|
-
|
|
94
|
-
# 9. Ensure no walrus (3.8+) — optional check for 3.6/3.7 compat
|
|
95
|
-
WALRUS=$(python3 -c "
|
|
96
|
-
import ast, sys
|
|
97
|
-
with open('$LIB_DIR/ledger.py') as f:
|
|
98
|
-
tree = ast.parse(f.read())
|
|
99
|
-
found = False
|
|
100
|
-
for node in ast.walk(tree):
|
|
101
|
-
if hasattr(ast, 'NamedExpr') and isinstance(node, ast.NamedExpr):
|
|
102
|
-
found = True
|
|
103
|
-
break
|
|
104
|
-
print('NO_WALRUS' if not found else 'HAS_WALRUS')
|
|
105
|
-
")
|
|
106
|
-
if [ "$WALRUS" = "NO_WALRUS" ]; then
|
|
107
|
-
printf ' \033[32mPASS\033[0m 9. No walrus operator (3.6/3.7 compat)\n'
|
|
108
|
-
pass=$((pass + 1))
|
|
109
|
-
else
|
|
110
|
-
printf ' \033[31mFAIL\033[0m 9. Walrus operator detected (breaks 3.6/3.7)\n'
|
|
111
|
-
fail=$((fail + 1))
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
# 10. Type hints (3.5+ compatible — using dict/list/Optional from typing)
|
|
115
|
-
HINT_OK=$(python3 -c "
|
|
116
|
-
# Newer 3.9+ allows 'list[X]' but we should use 'List[X]' for 3.6 compat
|
|
117
|
-
# Or no annotations at all (we mostly do this)
|
|
118
|
-
import re
|
|
119
|
-
with open('$LIB_DIR/ledger.py') as f:
|
|
120
|
-
src = f.read()
|
|
121
|
-
# Check for 3.9+ generic builtins like 'list[int]', 'dict[str, str]'
|
|
122
|
-
new_generics = re.findall(r'\b(list|dict|tuple|set)\[', src)
|
|
123
|
-
print('OK' if not new_generics else f'NEW_GENERICS: {new_generics[:3]}')
|
|
124
|
-
")
|
|
125
|
-
if [ "$HINT_OK" = "OK" ]; then
|
|
126
|
-
printf ' \033[32mPASS\033[0m 10. No 3.9+ generic builtins (list[X], dict[X,Y])\n'
|
|
127
|
-
pass=$((pass + 1))
|
|
128
|
-
else
|
|
129
|
-
printf ' \033[31mFAIL\033[0m 10. 3.9+ generics detected: %s\n' "$HINT_OK"
|
|
130
|
-
fail=$((fail + 1))
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
echo ""
|
|
134
|
-
echo "=== Result: ${pass} PASS / ${fail} FAIL ==="
|
|
135
|
-
echo ""
|
|
136
|
-
echo "Note: 실제 Python 3.6~3.12 multi-environment 검증은 CI 환경에서 추가."
|
|
137
|
-
echo " 현재는 syntax + AST level 호환성 체크만 수행."
|
|
138
|
-
[ "$fail" -eq 0 ] && exit 0 || exit 1
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Phase 1 Sprint 4: Integration tests (env-var based, robust quoting)
|
|
3
|
-
|
|
4
|
-
set -u
|
|
5
|
-
|
|
6
|
-
HOOKS_DIR="/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks"
|
|
7
|
-
LIB_DIR="$HOOKS_DIR/lib"
|
|
8
|
-
# 실 사용자 데이터(~/.routinecode/ledger·run) 무접촉 — 임시 HOME·런타임 디렉토리에서만 실행한다.
|
|
9
|
-
TEST_HOME=$(mktemp -d)
|
|
10
|
-
trap 'rm -rf "$TEST_HOME"' EXIT
|
|
11
|
-
export HOME="$TEST_HOME"
|
|
12
|
-
export XDG_RUNTIME_DIR="$TEST_HOME/run"
|
|
13
|
-
TRACKER="$XDG_RUNTIME_DIR/routinecode-deploy-tracker.jsonl"
|
|
14
|
-
LEDGER="$HOME/.routinecode/ledger/current.jsonl"
|
|
15
|
-
export SID="integration-test-$$"
|
|
16
|
-
export LIB_DIR
|
|
17
|
-
export LEDGER
|
|
18
|
-
|
|
19
|
-
pass=0
|
|
20
|
-
fail=0
|
|
21
|
-
|
|
22
|
-
clean_ledger() {
|
|
23
|
-
rm -rf "$TEST_HOME/.routinecode/ledger" "$TRACKER" "$XDG_RUNTIME_DIR/routinecode-edit-tracker.json"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
# Get last entry for our SID
|
|
27
|
-
last_entry_field() {
|
|
28
|
-
# $1 = python expression on entry 'e'
|
|
29
|
-
EXPR="$1" python3 -c "
|
|
30
|
-
import os, json, sys
|
|
31
|
-
sid = os.environ['SID']
|
|
32
|
-
expr = os.environ['EXPR']
|
|
33
|
-
try:
|
|
34
|
-
with open(os.environ['LEDGER']) as f:
|
|
35
|
-
lines = f.readlines()
|
|
36
|
-
except FileNotFoundError:
|
|
37
|
-
print('NONE')
|
|
38
|
-
sys.exit(0)
|
|
39
|
-
for line in reversed(lines):
|
|
40
|
-
line = line.strip()
|
|
41
|
-
if not line: continue
|
|
42
|
-
try:
|
|
43
|
-
e = json.loads(line)
|
|
44
|
-
except json.JSONDecodeError:
|
|
45
|
-
continue
|
|
46
|
-
if e.get('session_id') == sid:
|
|
47
|
-
p = e.get('payload', {}) or {}
|
|
48
|
-
print(eval(expr))
|
|
49
|
-
sys.exit(0)
|
|
50
|
-
print('NONE')
|
|
51
|
-
"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
session_count() {
|
|
55
|
-
python3 -c "
|
|
56
|
-
import os, json
|
|
57
|
-
sid = os.environ['SID']
|
|
58
|
-
n = 0
|
|
59
|
-
try:
|
|
60
|
-
with open(os.environ['LEDGER']) as f:
|
|
61
|
-
for line in f:
|
|
62
|
-
try:
|
|
63
|
-
e = json.loads(line)
|
|
64
|
-
if e.get('session_id') == sid: n += 1
|
|
65
|
-
except: pass
|
|
66
|
-
except FileNotFoundError: pass
|
|
67
|
-
print(n)
|
|
68
|
-
"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
assert_eq() {
|
|
72
|
-
local name="$1" got="$2" expected="$3"
|
|
73
|
-
if [ "$got" = "$expected" ]; then
|
|
74
|
-
printf ' \033[32mPASS\033[0m %s\n' "$name"
|
|
75
|
-
pass=$((pass + 1))
|
|
76
|
-
else
|
|
77
|
-
printf ' \033[31mFAIL\033[0m %s\n got=%s\n expected=%s\n' "$name" "$got" "$expected"
|
|
78
|
-
fail=$((fail + 1))
|
|
79
|
-
fi
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
run_hook() {
|
|
83
|
-
# $1 = hook script, $2 = JSON input
|
|
84
|
-
echo "$2" | "$1" >/dev/null 2>&1
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
echo "=== Phase 1 Integration Tests (v2) ==="
|
|
88
|
-
|
|
89
|
-
# 1. post-bash-verify: npm publish success
|
|
90
|
-
clean_ledger
|
|
91
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
92
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"npm publish\"},\"tool_response\":{\"stdout\":\"+ pkg@1.0.0\",\"exit_code\":0}}"
|
|
93
|
-
got=$(last_entry_field "f\"{e.get('category')}/{e.get('subcategory')}/{e.get('outcome')}\"")
|
|
94
|
-
assert_eq "1. post-bash-verify npm publish" "$got" "bash_action/npm_publish/success"
|
|
95
|
-
|
|
96
|
-
# 2. post-bash-verify: git commit failure (exit 1)
|
|
97
|
-
clean_ledger
|
|
98
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
99
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"git commit -m test\"},\"tool_response\":{\"stdout\":\"\",\"exit_code\":1}}"
|
|
100
|
-
got=$(last_entry_field "f\"{e.get('subcategory')}/{e.get('outcome')}\"")
|
|
101
|
-
assert_eq "2. post-bash-verify git commit fail" "$got" "git_commit/failure"
|
|
102
|
-
|
|
103
|
-
# 3. post-edit-track: Edit
|
|
104
|
-
clean_ledger
|
|
105
|
-
run_hook "$HOOKS_DIR/post-edit-track.sh" \
|
|
106
|
-
"{\"tool_name\":\"Edit\",\"session_id\":\"$SID\",\"tool_input\":{\"file_path\":\"/tmp/test.ts\",\"old_string\":\"foo\",\"new_string\":\"bar\"}}"
|
|
107
|
-
got=$(last_entry_field "f\"{e.get('category')}/{e.get('subcategory')}/{p.get('file')}/{('old_string_hash' in p)}\"")
|
|
108
|
-
assert_eq "3. post-edit-track Edit + hashes" "$got" "code_change/edit_write//tmp/test.ts/True"
|
|
109
|
-
|
|
110
|
-
# 4. post-edit-track: Write
|
|
111
|
-
clean_ledger
|
|
112
|
-
PAYLOAD='{"tool_name":"Write","session_id":"'"$SID"'","tool_input":{"file_path":"/tmp/new.txt","content":"line1\nline2\nline3"}}'
|
|
113
|
-
run_hook "$HOOKS_DIR/post-edit-track.sh" "$PAYLOAD"
|
|
114
|
-
got=$(last_entry_field "f\"{e.get('subcategory')}/{p.get('lines_count')}\"")
|
|
115
|
-
assert_eq "4. post-edit-track Write file_create" "$got" "file_create/3"
|
|
116
|
-
|
|
117
|
-
# 5. post-build-check: success
|
|
118
|
-
clean_ledger
|
|
119
|
-
run_hook "$HOOKS_DIR/post-build-check.sh" \
|
|
120
|
-
"{\"tool_name\":\"mcp__routinecode__build_check\",\"session_id\":\"$SID\",\"tool_response\":{\"success\":true,\"errors\":[]}}"
|
|
121
|
-
got=$(last_entry_field "f\"{e.get('category')}/{e.get('subcategory')}/{e.get('outcome')}\"")
|
|
122
|
-
assert_eq "5. post-build-check success" "$got" "verification/build_check/success"
|
|
123
|
-
|
|
124
|
-
# 6. post-build-check: failure
|
|
125
|
-
clean_ledger
|
|
126
|
-
run_hook "$HOOKS_DIR/post-build-check.sh" \
|
|
127
|
-
"{\"tool_name\":\"mcp__routinecode__build_check\",\"session_id\":\"$SID\",\"tool_response\":{\"success\":false,\"errors\":[\"e1\",\"e2\"]}}"
|
|
128
|
-
got=$(last_entry_field "f\"{e.get('outcome')}/{p.get('error_count')}\"")
|
|
129
|
-
assert_eq "6. post-build-check failure + error_count" "$got" "failure/2"
|
|
130
|
-
|
|
131
|
-
# 7. post-tool-universal: Grep
|
|
132
|
-
clean_ledger
|
|
133
|
-
run_hook "$HOOKS_DIR/post-tool-universal.sh" \
|
|
134
|
-
"{\"tool_name\":\"Grep\",\"session_id\":\"$SID\",\"tool_input\":{\"pattern\":\"foo\",\"path\":\"/tmp\"},\"tool_response\":{\"stdout\":\"/tmp/a.ts\\n/tmp/b.ts\"}}"
|
|
135
|
-
got=$(last_entry_field "f\"{e.get('subcategory')}/{p.get('pattern')}\"")
|
|
136
|
-
assert_eq "7. post-tool-universal Grep" "$got" "grep_search/foo"
|
|
137
|
-
|
|
138
|
-
# 8. post-tool-universal: Read
|
|
139
|
-
clean_ledger
|
|
140
|
-
run_hook "$HOOKS_DIR/post-tool-universal.sh" \
|
|
141
|
-
"{\"tool_name\":\"Read\",\"session_id\":\"$SID\",\"tool_input\":{\"file_path\":\"/tmp/a.ts\"},\"tool_response\":{\"stdout\":\"abc\"}}"
|
|
142
|
-
got=$(last_entry_field "f\"{e.get('subcategory')}/{p.get('file')}\"")
|
|
143
|
-
assert_eq "8. post-tool-universal Read" "$got" "file_read//tmp/a.ts"
|
|
144
|
-
|
|
145
|
-
# 9. post-agent-return: explorer with file:line refs (2 entries: main + proxy)
|
|
146
|
-
clean_ledger
|
|
147
|
-
run_hook "$HOOKS_DIR/post-agent-return.sh" \
|
|
148
|
-
"{\"tool_name\":\"Agent\",\"session_id\":\"$SID\",\"tool_input\":{\"subagent_type\":\"explorer\",\"description\":\"find auth\"},\"tool_response\":{\"content\":\"Found at app.ts:42 and auth.ts:10 and middleware.ts:5\"}}"
|
|
149
|
-
got=$(session_count)
|
|
150
|
-
assert_eq "9. post-agent-return explorer → 2 entries (main + proxy)" "$got" "2"
|
|
151
|
-
|
|
152
|
-
# 10. Dual-write verification
|
|
153
|
-
clean_ledger
|
|
154
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
155
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"git push\"},\"tool_response\":{\"stdout\":\"main -> main\",\"exit_code\":0}}"
|
|
156
|
-
legacy_size=0; ledger_size=0
|
|
157
|
-
[ -f "$TRACKER" ] && legacy_size=$(wc -l < "$TRACKER" | tr -d ' ')
|
|
158
|
-
[ -f "$LEDGER" ] && ledger_size=$(wc -l < "$LEDGER" | tr -d ' ')
|
|
159
|
-
got="legacy=$legacy_size,ledger=$ledger_size"
|
|
160
|
-
assert_eq "10. dual-write (legacy + ledger 둘 다 1)" "$got" "legacy=1,ledger=1"
|
|
161
|
-
|
|
162
|
-
# 11. Token redaction
|
|
163
|
-
clean_ledger
|
|
164
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
165
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"git push https://ghp_abcdefghijklmnopqrstuvwxyz0123456789@github.com/x/y\"},\"tool_response\":{\"stdout\":\"\",\"exit_code\":0}}"
|
|
166
|
-
leak=$(grep -c "ghp_abcdef" "$LEDGER" 2>/dev/null; true)
|
|
167
|
-
leak=$(echo "$leak" | head -1 | tr -d ' \n')
|
|
168
|
-
[ -z "$leak" ] && leak=0
|
|
169
|
-
assert_eq "11. Token redaction (ghp_ leak count = 0)" "$leak" "0"
|
|
170
|
-
|
|
171
|
-
# 12. Reader query_evidence by category
|
|
172
|
-
clean_ledger
|
|
173
|
-
for op in "npm publish" "git push" "git commit -m x"; do
|
|
174
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
175
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"$op\"},\"tool_response\":{\"stdout\":\"\",\"exit_code\":0}}"
|
|
176
|
-
done
|
|
177
|
-
got=$(python3 -c "
|
|
178
|
-
import sys, os
|
|
179
|
-
sys.path.insert(0, os.environ['LIB_DIR'])
|
|
180
|
-
import ledger_reader
|
|
181
|
-
print(len(ledger_reader.query_evidence(session_id=os.environ['SID'], categories=['bash_action'])))
|
|
182
|
-
")
|
|
183
|
-
assert_eq "12. Reader query_evidence by category → 3" "$got" "3"
|
|
184
|
-
|
|
185
|
-
# 13. Reader latest_for
|
|
186
|
-
clean_ledger
|
|
187
|
-
run_hook "$HOOKS_DIR/post-bash-verify.sh" \
|
|
188
|
-
"{\"tool_name\":\"Bash\",\"session_id\":\"$SID\",\"tool_input\":{\"command\":\"npm publish\"},\"tool_response\":{\"stdout\":\"\",\"exit_code\":0}}"
|
|
189
|
-
got=$(python3 -c "
|
|
190
|
-
import sys, os
|
|
191
|
-
sys.path.insert(0, os.environ['LIB_DIR'])
|
|
192
|
-
import ledger_reader
|
|
193
|
-
r = ledger_reader.latest_for(os.environ['SID'], category='bash_action', subcategory='npm_publish')
|
|
194
|
-
print(r.get('outcome') if r else 'NONE')
|
|
195
|
-
")
|
|
196
|
-
assert_eq "13. Reader latest_for npm_publish → success" "$got" "success"
|
|
197
|
-
|
|
198
|
-
echo ""
|
|
199
|
-
echo "=== Result: ${pass} PASS / ${fail} FAIL ==="
|
|
200
|
-
[ "$fail" -eq 0 ] && exit 0 || exit 1
|