@routinecrew/routinecode 2.31.63 → 2.31.71
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/rm_guard.py +124 -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 +24 -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,471 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""design 09 클라이언트 소관 회귀 테스트 — presence(§2) + credit 3단 사다리(§8.4·§10).
|
|
3
|
-
|
|
4
|
-
fakehome(HOME 오버라이드) + 로컬 mock HTTP 서버로 실서버 호출 0, 실 ~/.routinecode 무접촉.
|
|
5
|
-
|
|
6
|
-
1. presence: 봉투 화이트리스트·패턴 검증(mock 서버 수신), 1일 1회 dedup,
|
|
7
|
-
opt-out(env·config), fail-open(서버 다운), 미프로비저닝(config 부재) 동작
|
|
8
|
-
2. pre-credit-guard: SKIP / OK / SOFT(+graceStartedAt set-if-absent) / BLOCK(hard 우선)
|
|
9
|
-
3. user-prompt-submit: flags off=무감산, shadow=음수 감산+관측 라벨+무차단,
|
|
10
|
-
gate=BLOCKED, soft=D-N grace 안내·만료 문구
|
|
11
|
-
|
|
12
|
-
실행: python3 design09-client.test.py (exit 0 = 전부 통과)
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
import json
|
|
16
|
-
import os
|
|
17
|
-
import re
|
|
18
|
-
import shutil
|
|
19
|
-
import subprocess
|
|
20
|
-
import sys
|
|
21
|
-
import tempfile
|
|
22
|
-
import threading
|
|
23
|
-
from datetime import datetime, timedelta, timezone
|
|
24
|
-
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
25
|
-
|
|
26
|
-
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
27
|
-
HOOKS = os.path.dirname(HERE)
|
|
28
|
-
REPO = os.path.dirname(HOOKS)
|
|
29
|
-
LIB = os.path.join(HOOKS, "lib")
|
|
30
|
-
PRESENCE = os.path.join(LIB, "presence.py")
|
|
31
|
-
|
|
32
|
-
PASS = []
|
|
33
|
-
FAIL = []
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def check(name, cond, detail=""):
|
|
37
|
-
if cond:
|
|
38
|
-
PASS.append(name)
|
|
39
|
-
print(f" PASS {name}")
|
|
40
|
-
else:
|
|
41
|
-
FAIL.append((name, detail))
|
|
42
|
-
print(f" FAIL {name} :: {detail}")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# ────────────────────────────────────────────────────────────
|
|
46
|
-
# mock presence sink
|
|
47
|
-
# ────────────────────────────────────────────────────────────
|
|
48
|
-
class Handler(BaseHTTPRequestHandler):
|
|
49
|
-
requests = []
|
|
50
|
-
consumes = []
|
|
51
|
-
# 서버 권위 consume 응답(테스트마다 교체): (HTTP status, JSON body)
|
|
52
|
-
consume_resp = (200, {"result": True, "data": {"balanceAfter": 49}})
|
|
53
|
-
|
|
54
|
-
def do_POST(self):
|
|
55
|
-
length = int(self.headers.get("Content-Length", 0) or 0)
|
|
56
|
-
body = self.rfile.read(length)
|
|
57
|
-
try:
|
|
58
|
-
parsed = json.loads(body or b"{}")
|
|
59
|
-
except Exception:
|
|
60
|
-
parsed = None
|
|
61
|
-
if self.path.endswith("/growth-proxy/credit/consume"):
|
|
62
|
-
Handler.consumes.append(parsed)
|
|
63
|
-
code, payload = Handler.consume_resp
|
|
64
|
-
raw = json.dumps(payload).encode()
|
|
65
|
-
self.send_response(code)
|
|
66
|
-
self.send_header("Content-Type", "application/json")
|
|
67
|
-
self.send_header("Content-Length", str(len(raw)))
|
|
68
|
-
self.end_headers()
|
|
69
|
-
self.wfile.write(raw)
|
|
70
|
-
return
|
|
71
|
-
Handler.requests.append({"path": self.path, "body": parsed})
|
|
72
|
-
self.send_response(204)
|
|
73
|
-
self.end_headers()
|
|
74
|
-
|
|
75
|
-
def log_message(self, *a):
|
|
76
|
-
pass
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
server = HTTPServer(("127.0.0.1", 0), Handler)
|
|
80
|
-
PORT = server.server_address[1]
|
|
81
|
-
threading.Thread(target=server.serve_forever, daemon=True).start()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def fresh_home(config=None, credit_state=None, flags=None):
|
|
85
|
-
home = tempfile.mkdtemp(prefix="rc-d09-")
|
|
86
|
-
rc = os.path.join(home, ".routinecode")
|
|
87
|
-
os.makedirs(rc, exist_ok=True)
|
|
88
|
-
if config is not None:
|
|
89
|
-
json.dump(config, open(os.path.join(rc, "config.json"), "w"))
|
|
90
|
-
if credit_state is not None:
|
|
91
|
-
json.dump(credit_state, open(os.path.join(rc, "credit-state.json"), "w"))
|
|
92
|
-
if flags is not None:
|
|
93
|
-
json.dump({"flags": flags}, open(os.path.join(rc, "remote-flags.json"), "w"))
|
|
94
|
-
return home
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
# 차단(BLOCK) 케이스는 hook 이 재충전 페이지를 브라우저로 연다(하루 1회 표시 파일은 가짜 HOME 마다 새로 없음).
|
|
98
|
-
# 테스트가 실제 Mac 브라우저를 띄우지 않도록 open/xdg-open 을 무동작 스텁으로 가린다.
|
|
99
|
-
_NO_BROWSER = tempfile.mkdtemp(prefix="rc-nobrowser-")
|
|
100
|
-
for _b in ("open", "xdg-open"):
|
|
101
|
-
with open(os.path.join(_NO_BROWSER, _b), "w") as _f:
|
|
102
|
-
_f.write("#!/bin/sh\nexit 0\n")
|
|
103
|
-
os.chmod(os.path.join(_NO_BROWSER, _b), 0o755)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def base_env(home, server_url=None, extra=None):
|
|
107
|
-
env = dict(os.environ)
|
|
108
|
-
env["HOME"] = home
|
|
109
|
-
env["PATH"] = _NO_BROWSER + ":" + env.get("PATH", "")
|
|
110
|
-
env["ROUTINECODE_SERVER_URL"] = server_url or f"http://127.0.0.1:{PORT}"
|
|
111
|
-
for k in ("ROUTINECODE_TELEMETRY", "ROUTINECODE_CREDIT_BYPASS", "ROUTINECODE_CREDIT_GATE",
|
|
112
|
-
"ROUTINECODE_SESSION_PID", "ROUTINECODE_RECORDER", "RC_SERVER_BALANCE", "ROUTINECODE_API_KEY"):
|
|
113
|
-
env.pop(k, None)
|
|
114
|
-
# 크레딧 집행은 routinecode 로 띄운 세션에만 적용된다 → 세션 마커를 명시(실행 셸 env 와 무관하게 결정적).
|
|
115
|
-
env["ROUTINECODE_SESSION"] = "1"
|
|
116
|
-
if extra:
|
|
117
|
-
env.update(extra)
|
|
118
|
-
return env
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def run_presence(home, server_url=None, extra=None):
|
|
122
|
-
return subprocess.run(
|
|
123
|
-
[sys.executable, PRESENCE],
|
|
124
|
-
env=base_env(home, server_url, extra),
|
|
125
|
-
capture_output=True,
|
|
126
|
-
timeout=20,
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
# ────────────────────────────────────────────────────────────
|
|
131
|
-
# 1. presence
|
|
132
|
-
# ────────────────────────────────────────────────────────────
|
|
133
|
-
WHITELIST = {"machine_hash", "app_version", "os", "has_key", "locale", "ts"}
|
|
134
|
-
|
|
135
|
-
home1 = fresh_home(config={"userId": 7, "tenantId": 3, "apiKey": "rck_dummy", "machineId": "a1b2c3d4e5f60718"})
|
|
136
|
-
r = run_presence(home1)
|
|
137
|
-
check("presence: 첫 방출 exit 0", r.returncode == 0, str(r.stderr[:200]))
|
|
138
|
-
check("presence: 1회 수신", len(Handler.requests) == 1, f"got {len(Handler.requests)}")
|
|
139
|
-
if Handler.requests:
|
|
140
|
-
req = Handler.requests[0]
|
|
141
|
-
body = req["body"] or {}
|
|
142
|
-
check("presence: 경로 /api/v1/presence", req["path"] == "/api/v1/presence", req["path"])
|
|
143
|
-
check("presence: 필드 화이트리스트 준수", set(body.keys()) <= WHITELIST, str(body.keys()))
|
|
144
|
-
check("presence: 필수 3필드 존재", all(k in body for k in ("machine_hash", "app_version", "has_key")))
|
|
145
|
-
check("presence: machine_hash 패턴", bool(re.match(r"^[0-9a-f]{16}$", str(body.get("machine_hash", "")))), str(body.get("machine_hash")))
|
|
146
|
-
check(
|
|
147
|
-
"presence: machine_hash = sha1(machineId)[:16] (원문 비노출)",
|
|
148
|
-
body.get("machine_hash") != "a1b2c3d4e5f60718",
|
|
149
|
-
)
|
|
150
|
-
check(
|
|
151
|
-
"presence: app_version 패턴",
|
|
152
|
-
bool(re.match(r"^\d+\.\d+\.\d+([-.][0-9A-Za-z.-]+)?$", str(body.get("app_version", "")))),
|
|
153
|
-
str(body.get("app_version")),
|
|
154
|
-
)
|
|
155
|
-
check("presence: os enum", body.get("os") in ("darwin", "linux", "win", "other"), str(body.get("os")))
|
|
156
|
-
check("presence: has_key=true", body.get("has_key") is True)
|
|
157
|
-
check(
|
|
158
|
-
"presence: 계정 식별자 불포함",
|
|
159
|
-
not any(k in body for k in ("userId", "tenantId", "apiKey", "hostname", "cwd")),
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
# dedup: 같은 날 재실행 → 미방출
|
|
163
|
-
r = run_presence(home1)
|
|
164
|
-
check("presence: 같은 날 재실행 미방출(dedup)", r.returncode == 0 and len(Handler.requests) == 1, f"got {len(Handler.requests)}")
|
|
165
|
-
st = json.load(open(os.path.join(home1, ".routinecode", "presence-state.json")))
|
|
166
|
-
today = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
|
167
|
-
check("presence: presence-state lastSentDate=오늘", st.get("lastSentDate") == today, str(st))
|
|
168
|
-
|
|
169
|
-
# 날짜가 지난 상태파일 → 재방출
|
|
170
|
-
json.dump({"lastSentDate": "2000-01-01"}, open(os.path.join(home1, ".routinecode", "presence-state.json"), "w"))
|
|
171
|
-
r = run_presence(home1)
|
|
172
|
-
check("presence: 다른 날짜면 재방출", len(Handler.requests) == 2, f"got {len(Handler.requests)}")
|
|
173
|
-
|
|
174
|
-
# opt-out: config telemetryEnabled=false
|
|
175
|
-
home2 = fresh_home(config={"apiKey": "rck_dummy", "telemetryEnabled": False})
|
|
176
|
-
n0 = len(Handler.requests)
|
|
177
|
-
r = run_presence(home2)
|
|
178
|
-
check("presence: config opt-out 미방출", r.returncode == 0 and len(Handler.requests) == n0)
|
|
179
|
-
check(
|
|
180
|
-
"presence: opt-out 시 상태파일 미생성",
|
|
181
|
-
not os.path.exists(os.path.join(home2, ".routinecode", "presence-state.json")),
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
# opt-out: env ROUTINECODE_TELEMETRY=off
|
|
185
|
-
home3 = fresh_home(config={"apiKey": "rck_dummy"})
|
|
186
|
-
r = run_presence(home3, extra={"ROUTINECODE_TELEMETRY": "off"})
|
|
187
|
-
check("presence: env opt-out 미방출", r.returncode == 0 and len(Handler.requests) == n0)
|
|
188
|
-
|
|
189
|
-
# fail-open: 닫힌 포트 → exit 0, 발사 시점 기록은 남는다(§2.2)
|
|
190
|
-
home4 = fresh_home(config={"apiKey": "rck_dummy"})
|
|
191
|
-
r = run_presence(home4, server_url="http://127.0.0.1:1")
|
|
192
|
-
check("presence: 서버 다운 fail-open exit 0", r.returncode == 0, str(r.stderr[:200]))
|
|
193
|
-
check(
|
|
194
|
-
"presence: 발사 시점 기록(성공 무관)",
|
|
195
|
-
os.path.exists(os.path.join(home4, ".routinecode", "presence-state.json")),
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
# config 부재(설치 직후) — has_key=false, machine_hash는 nodename md5 → sha1
|
|
199
|
-
home5 = fresh_home()
|
|
200
|
-
n0 = len(Handler.requests)
|
|
201
|
-
r = run_presence(home5)
|
|
202
|
-
check("presence: config 부재도 방출", r.returncode == 0 and len(Handler.requests) == n0 + 1)
|
|
203
|
-
if len(Handler.requests) > n0:
|
|
204
|
-
body = Handler.requests[-1]["body"] or {}
|
|
205
|
-
check("presence: config 부재 has_key=false", body.get("has_key") is False)
|
|
206
|
-
check("presence: config 부재 machine_hash 패턴", bool(re.match(r"^[0-9a-f]{16}$", str(body.get("machine_hash", "")))))
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
# ────────────────────────────────────────────────────────────
|
|
210
|
-
# 2. pre-credit-guard — SKIP / OK / SOFT / BLOCK
|
|
211
|
-
# ────────────────────────────────────────────────────────────
|
|
212
|
-
PCG = os.path.join(HOOKS, "pre-credit-guard.sh")
|
|
213
|
-
CFG = {"userId": 7, "tenantId": 3, "plan": "free"}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
# 크레딧 게이트는 routinecode 유료 MCP 도구에만 적용된다(기본 도구 Bash/Edit 등은 절대 차단 안 함 — 2.31.16).
|
|
217
|
-
PAID_TOOL = "mcp__intelligence__get_patterns"
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def run_pcg(home, tool=PAID_TOOL):
|
|
221
|
-
return subprocess.run(
|
|
222
|
-
["bash", PCG],
|
|
223
|
-
input=json.dumps({"tool_name": tool}),
|
|
224
|
-
env=base_env(home),
|
|
225
|
-
capture_output=True,
|
|
226
|
-
text=True,
|
|
227
|
-
timeout=20,
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
def is_block(out):
|
|
232
|
-
# PreToolUse 차단 형식 = hookSpecificOutput.permissionDecision=deny (2.31.35~)
|
|
233
|
-
try:
|
|
234
|
-
o = json.loads(out.strip())
|
|
235
|
-
except Exception:
|
|
236
|
-
return False
|
|
237
|
-
return (o.get("hookSpecificOutput") or {}).get("permissionDecision") == "deny" or o.get("decision") == "block"
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
# SKIP: remote-flags 부재
|
|
241
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 0})
|
|
242
|
-
r = run_pcg(h)
|
|
243
|
-
check("pcg: flags 부재 → SKIP(통과)", r.returncode == 0 and r.stdout.strip() == "", r.stdout[:120])
|
|
244
|
-
|
|
245
|
-
# SKIP: hard·soft 둘 다 off (shadow만 on이어도 이 훅은 무관)
|
|
246
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 0}, flags={"creditShadowEnabled": True})
|
|
247
|
-
r = run_pcg(h)
|
|
248
|
-
check("pcg: shadow only → SKIP(차단 전용 훅 무관)", r.returncode == 0 and r.stdout.strip() == "")
|
|
249
|
-
|
|
250
|
-
# OK: soft on, 잔액 양수
|
|
251
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 5}, flags={"creditSoftGateEnabled": True})
|
|
252
|
-
r = run_pcg(h)
|
|
253
|
-
check("pcg: soft+잔액>0 → OK(통과)", r.returncode == 0 and r.stdout.strip() == "")
|
|
254
|
-
|
|
255
|
-
# SOFT: soft on, 잔액 0 → 통과 + graceStartedAt set-if-absent
|
|
256
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 0}, flags={"creditSoftGateEnabled": True})
|
|
257
|
-
r = run_pcg(h)
|
|
258
|
-
cs_path = os.path.join(h, ".routinecode", "credit-state.json")
|
|
259
|
-
cs = json.load(open(cs_path))
|
|
260
|
-
check("pcg: SOFT → 차단 없이 통과", r.returncode == 0 and r.stdout.strip() == "", r.stdout[:120])
|
|
261
|
-
check("pcg: SOFT → graceStartedAt 기록", bool(cs.get("graceStartedAt")), str(cs))
|
|
262
|
-
g1 = cs.get("graceStartedAt")
|
|
263
|
-
r = run_pcg(h)
|
|
264
|
-
cs = json.load(open(cs_path))
|
|
265
|
-
check("pcg: graceStartedAt set-if-absent(재실행 불변)", cs.get("graceStartedAt") == g1)
|
|
266
|
-
|
|
267
|
-
# BLOCK: hard on, 잔액 0
|
|
268
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 0}, flags={"creditGateEnabled": True})
|
|
269
|
-
r = run_pcg(h)
|
|
270
|
-
check("pcg: hard+잔액0 → BLOCK", is_block(r.stdout), r.stdout[:200])
|
|
271
|
-
|
|
272
|
-
# BLOCK 우선: hard+soft 동시 on
|
|
273
|
-
h = fresh_home(
|
|
274
|
-
config=CFG,
|
|
275
|
-
credit_state={"serviceId": "routinecode", "balance": 0},
|
|
276
|
-
flags={"creditGateEnabled": True, "creditSoftGateEnabled": True},
|
|
277
|
-
)
|
|
278
|
-
r = run_pcg(h)
|
|
279
|
-
check("pcg: hard+soft 동시 → hard 우선 BLOCK", is_block(r.stdout), r.stdout[:200])
|
|
280
|
-
|
|
281
|
-
# hard on, 잔액>0 → OK
|
|
282
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 3}, flags={"creditGateEnabled": True})
|
|
283
|
-
r = run_pcg(h)
|
|
284
|
-
check("pcg: hard+잔액>0 → OK", r.returncode == 0 and r.stdout.strip() == "")
|
|
285
|
-
|
|
286
|
-
# free tool은 게이트 무관 통과
|
|
287
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 0}, flags={"creditGateEnabled": True})
|
|
288
|
-
r = run_pcg(h, tool="mcp__routinecode__share_issue")
|
|
289
|
-
check("pcg: 잔액0+hard여도 share 도구 통과(회귀)", r.returncode == 0 and r.stdout.strip() == "")
|
|
290
|
-
|
|
291
|
-
# 기본 도구는 크레딧과 무관하게 절대 차단하지 않는다(호스트 CLI 브릭 방지)
|
|
292
|
-
r = run_pcg(h, tool="Bash")
|
|
293
|
-
check("pcg: 잔액0+hard여도 기본 도구(Bash) 통과", r.returncode == 0 and r.stdout.strip() == "")
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
# ────────────────────────────────────────────────────────────
|
|
297
|
-
# 3. user-prompt-submit — 서버 권위 차감 + 안내 문구 + 차감 대상(입력창 프롬프트만)
|
|
298
|
-
# ────────────────────────────────────────────────────────────
|
|
299
|
-
UPS = os.path.join(HOOKS, "user-prompt-submit.sh")
|
|
300
|
-
CFG_KEY = dict(CFG, apiKey="rck_dummy")
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
def run_ups(home, prompt="hi", extra=None):
|
|
304
|
-
return subprocess.run(
|
|
305
|
-
["bash", UPS],
|
|
306
|
-
input=json.dumps({"session_id": "d09testsession", "prompt": prompt}),
|
|
307
|
-
env=base_env(home, extra=extra),
|
|
308
|
-
capture_output=True,
|
|
309
|
-
text=True,
|
|
310
|
-
timeout=30,
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def last_json(out):
|
|
315
|
-
for line in reversed(out.strip().splitlines()):
|
|
316
|
-
line = line.strip()
|
|
317
|
-
if line.startswith("{"):
|
|
318
|
-
try:
|
|
319
|
-
return json.loads(line)
|
|
320
|
-
except Exception:
|
|
321
|
-
continue
|
|
322
|
-
return {}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
def balance_of(home):
|
|
326
|
-
try:
|
|
327
|
-
return json.load(open(os.path.join(home, ".routinecode", "credit-state.json"))).get("balance")
|
|
328
|
-
except Exception:
|
|
329
|
-
return None
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
def ctx(out):
|
|
333
|
-
return out.get("additionalContext") or (out.get("hookSpecificOutput") or {}).get("additionalContext") or ""
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
def server_ok(balance):
|
|
337
|
-
Handler.consume_resp = (200, {"result": True, "data": {"balanceAfter": balance}})
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
def consumed_by(fn):
|
|
341
|
-
n0 = len(Handler.consumes)
|
|
342
|
-
r = fn()
|
|
343
|
-
return r, len(Handler.consumes) - n0
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
# apiKey 없음(미로그인) → 서버 호출·감산 없음
|
|
347
|
-
server_ok(4)
|
|
348
|
-
h = fresh_home(config=CFG, credit_state={"serviceId": "routinecode", "balance": 5}, flags={"creditGateEnabled": True})
|
|
349
|
-
r, n = consumed_by(lambda: run_ups(h))
|
|
350
|
-
check("ups: apiKey 없음 → 서버 차감 호출 없음", n == 0, f"consumes={n}")
|
|
351
|
-
check("ups: apiKey 없음 → 무감산", balance_of(h) == 5, str(balance_of(h)))
|
|
352
|
-
|
|
353
|
-
# flags 전부 off → 서버가 판정(잔액 그대로), 안내 없음
|
|
354
|
-
server_ok(5)
|
|
355
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 5})
|
|
356
|
-
r, n = consumed_by(lambda: run_ups(h))
|
|
357
|
-
out = last_json(r.stdout)
|
|
358
|
-
check("ups: flags off → 서버 판정 1회", n == 1, f"consumes={n}")
|
|
359
|
-
check("ups: flags off → 잔액 불변", balance_of(h) == 5, str(balance_of(h)))
|
|
360
|
-
check("ups: flags off → continue true", out.get("continue") is True, r.stdout[:200])
|
|
361
|
-
|
|
362
|
-
# shadow → 서버 차감(5→4) 미러, 로컬 이중 감산 없음, 차단 없음
|
|
363
|
-
server_ok(4)
|
|
364
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 5}, flags={"creditShadowEnabled": True})
|
|
365
|
-
r, n = consumed_by(lambda: run_ups(h))
|
|
366
|
-
out = last_json(r.stdout)
|
|
367
|
-
check("ups: shadow → 서버 차감 1회", n == 1, f"consumes={n}")
|
|
368
|
-
check("ups: shadow → 서버 잔액 미러(이중 감산 없음)", balance_of(h) == 4, str(balance_of(h)))
|
|
369
|
-
check("ups: shadow → 차단 없음", out.get("continue") is True)
|
|
370
|
-
|
|
371
|
-
# shadow 저잔액 → 관측 모드 라벨(차단 임박 아님), 차단 없음
|
|
372
|
-
server_ok(0)
|
|
373
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 1}, flags={"creditShadowEnabled": True})
|
|
374
|
-
r = run_ups(h)
|
|
375
|
-
out = last_json(r.stdout)
|
|
376
|
-
check("ups: shadow 잔액0 → 차단 없음", out.get("continue") is True, r.stdout[:200])
|
|
377
|
-
check("ups: shadow → 관측 모드 라벨", "관측 모드" in ctx(out), str(out)[:300])
|
|
378
|
-
|
|
379
|
-
# gate + 서버 잔액부족 봉투(429) → 입력 차단(decision:block + 안내 문구)
|
|
380
|
-
Handler.consume_resp = (200, {"result": False, "status": 429, "message": "Insufficient credit"})
|
|
381
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 0}, flags={"creditGateEnabled": True})
|
|
382
|
-
r = run_ups(h)
|
|
383
|
-
out = last_json(r.stdout)
|
|
384
|
-
check("ups: gate 잔액0 → BLOCKED", out.get("decision") == "block" and bool(out.get("reason")), r.stdout[:200])
|
|
385
|
-
check("ups: gate 잔액0 → 잔액 0 유지", balance_of(h) == 0, str(balance_of(h)))
|
|
386
|
-
r = run_ups(h, prompt="/recharge")
|
|
387
|
-
check("ups: 차단 중에도 /recharge 통과", last_json(r.stdout).get("decision") != "block", r.stdout[:200])
|
|
388
|
-
|
|
389
|
-
# gate + 서버 잔액 2 → 잔액 부족 사전 경고
|
|
390
|
-
server_ok(2)
|
|
391
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 3}, flags={"creditGateEnabled": True})
|
|
392
|
-
r = run_ups(h)
|
|
393
|
-
out = last_json(r.stdout)
|
|
394
|
-
check("ups: gate 서버잔액2 → WARN", balance_of(h) == 2 and "2" in ctx(out), str(out)[:300])
|
|
395
|
-
check("ups: gate 서버잔액2 → 차단 없음", out.get("continue") is True)
|
|
396
|
-
|
|
397
|
-
# gate + 서버 잔액 넉넉 → 경고 없음
|
|
398
|
-
server_ok(40)
|
|
399
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 41}, flags={"creditGateEnabled": True})
|
|
400
|
-
r = run_ups(h)
|
|
401
|
-
out = last_json(r.stdout)
|
|
402
|
-
check("ups: gate 서버잔액40 → 경고 없음", "[CREDIT]" not in ctx(out) and "Credit balance" not in ctx(out), str(out)[:300])
|
|
403
|
-
|
|
404
|
-
# soft(+shadow) + 서버 잔액 0 → D-7 grace 안내 (graceStartedAt 부재 → 잔여 7일)
|
|
405
|
-
server_ok(0)
|
|
406
|
-
h = fresh_home(
|
|
407
|
-
config=CFG_KEY,
|
|
408
|
-
credit_state={"serviceId": "routinecode", "balance": 1},
|
|
409
|
-
flags={"creditShadowEnabled": True, "creditSoftGateEnabled": True},
|
|
410
|
-
)
|
|
411
|
-
r = run_ups(h)
|
|
412
|
-
out = last_json(r.stdout)
|
|
413
|
-
check("ups: soft → 차단 없음", out.get("continue") is True)
|
|
414
|
-
check("ups: soft 잔액0 → D-7 안내", "D-7" in ctx(out), str(out)[:300])
|
|
415
|
-
|
|
416
|
-
# soft, grace 만료(10일 경과) → 만료 문구, 여전히 차단 없음
|
|
417
|
-
old = (datetime.now(timezone.utc) - timedelta(days=10)).isoformat()
|
|
418
|
-
h = fresh_home(
|
|
419
|
-
config=CFG_KEY,
|
|
420
|
-
credit_state={"serviceId": "routinecode", "balance": 0, "graceStartedAt": old},
|
|
421
|
-
flags={"creditShadowEnabled": True, "creditSoftGateEnabled": True},
|
|
422
|
-
)
|
|
423
|
-
r = run_ups(h)
|
|
424
|
-
out = last_json(r.stdout)
|
|
425
|
-
check("ups: grace 만료 → 차단 없음(문구만 상승)", out.get("continue") is True, r.stdout[:200])
|
|
426
|
-
check("ups: grace 만료 → 경과 문구", "경과" in ctx(out), str(out)[:300])
|
|
427
|
-
|
|
428
|
-
# Pro 구독자: 서버가 면제(잔액 불변) → 로컬도 무감산·무경고
|
|
429
|
-
server_ok(5)
|
|
430
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 5}, flags={"creditShadowEnabled": True})
|
|
431
|
-
sub = {"planCode": "pro", "status": "active", "expiresAt": None}
|
|
432
|
-
json.dump(sub, open(os.path.join(h, ".routinecode", "subscription.json"), "w"))
|
|
433
|
-
r = run_ups(h)
|
|
434
|
-
check("ups: Pro 구독 → shadow여도 무감산", balance_of(h) == 5, str(balance_of(h)))
|
|
435
|
-
|
|
436
|
-
# ── 차감 대상: 사용자가 입력창에 친 프롬프트만 (내부 LLM 호출 무차감) ──
|
|
437
|
-
server_ok(10)
|
|
438
|
-
FLAGS = {"creditGateEnabled": True}
|
|
439
|
-
|
|
440
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 11}, flags=FLAGS)
|
|
441
|
-
_, n = consumed_by(lambda: run_ups(h, extra={"ROUTINECODE_SESSION_PID": str(os.getpid())}))
|
|
442
|
-
check("ups: 메인 claude(PID 일치) 입력 → 1회 차감", n == 1, f"consumes={n}")
|
|
443
|
-
|
|
444
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 11}, flags=FLAGS)
|
|
445
|
-
_, n = consumed_by(lambda: run_ups(h, extra={"ROUTINECODE_SESSION_PID": "999999"}))
|
|
446
|
-
check("ups: 내부 claude(PID 불일치) → 무차감", n == 0 and balance_of(h) == 11, f"consumes={n} bal={balance_of(h)}")
|
|
447
|
-
|
|
448
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 11}, flags=FLAGS)
|
|
449
|
-
_, n = consumed_by(lambda: run_ups(h, extra={"ROUTINECODE_RECORDER": "1"}))
|
|
450
|
-
check("ups: 헤드리스 recorder → 무차감", n == 0 and balance_of(h) == 11, f"consumes={n} bal={balance_of(h)}")
|
|
451
|
-
|
|
452
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 11}, flags=FLAGS)
|
|
453
|
-
_, n = consumed_by(lambda: run_ups(h, prompt="<task-notification>\n<task-id>x</task-id>"))
|
|
454
|
-
check("ups: 백그라운드 작업 알림 → 무차감", n == 0 and balance_of(h) == 11, f"consumes={n} bal={balance_of(h)}")
|
|
455
|
-
|
|
456
|
-
h = fresh_home(config=CFG_KEY, credit_state={"serviceId": "routinecode", "balance": 11}, flags=FLAGS)
|
|
457
|
-
env_plain = {"ROUTINECODE_SESSION": ""}
|
|
458
|
-
_, n = consumed_by(lambda: run_ups(h, extra=env_plain))
|
|
459
|
-
check("ups: 순수 claude 세션(마커 없음) → 무차감", n == 0, f"consumes={n}")
|
|
460
|
-
|
|
461
|
-
# recorder-runner 는 헤드리스 claude 에 세션 마커를 넘기지 않는다(정적 확인)
|
|
462
|
-
rr = open(os.path.join(HOOKS, "recorder-runner.sh")).read()
|
|
463
|
-
check("recorder-runner: 세션 마커 제거 후 실행", "env -u ROUTINECODE_SESSION -u ROUTINECODE_SESSION_PID" in rr)
|
|
464
|
-
|
|
465
|
-
server.shutdown()
|
|
466
|
-
|
|
467
|
-
print()
|
|
468
|
-
print(f"RESULT: {len(PASS)} passed, {len(FAIL)} failed")
|
|
469
|
-
for name, detail in FAIL:
|
|
470
|
-
print(f" FAILED: {name} :: {detail}")
|
|
471
|
-
sys.exit(0 if not FAIL else 1)
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""secret-guard dev-mode 회귀 테스트.
|
|
3
|
-
|
|
4
|
-
routinecode 소스 개발자는 CORE 소스보호(복제방지)에서 면제되어야 하되,
|
|
5
|
-
런타임 config(~/.routinecode/*.json)·시크릿(.env 등)·설치본은 계속 보호되어야 한다.
|
|
6
|
-
|
|
7
|
-
.env 등 일반 시크릿 파일은 하드블록하지 않고 값만 스크럽한다(c799d41 scrub-only).
|
|
8
|
-
런타임 config 는 명시 dev 모드(env=1 ∧ 가드가 full-source 체크아웃)에서만 참조를 허용한다(6cd3898).
|
|
9
|
-
|
|
10
|
-
완화 조건(둘 중 하나):
|
|
11
|
-
- ROUTINECODE_DEV=1 (명시 opt-in), 또는
|
|
12
|
-
- 타깃 경로가 실제 full-source 체크아웃(engine/ + .sources|mcp-*/src) 안일 때.
|
|
13
|
-
설치본(dist-only)에는 소스 마커가 없어 완화되지 않는다.
|
|
14
|
-
"""
|
|
15
|
-
import os
|
|
16
|
-
import sys
|
|
17
|
-
|
|
18
|
-
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
19
|
-
sys.path.insert(0, os.path.join(REPO, "hooks", "lib"))
|
|
20
|
-
import secret_filter as sf # noqa: E402
|
|
21
|
-
|
|
22
|
-
pol = sf.load_policy()
|
|
23
|
-
cp = lambda p: sf.check_path(p, pol)[0]
|
|
24
|
-
bc = lambda c: sf.check_bash_command(c, pol)[0]
|
|
25
|
-
|
|
26
|
-
hook = os.path.join(REPO, "hooks", "pre-edit-domain-gate.sh")
|
|
27
|
-
plugin = os.path.join(REPO, "plugin", "agents", "recorder.md")
|
|
28
|
-
installed = "/u/node_modules/@routinecrew/routinecode/hooks/" + "pre-x.sh"
|
|
29
|
-
home_cfg = os.path.expanduser("~/.routinecode/") + "config" + ".json"
|
|
30
|
-
env_secret = "/tmp/anyproj/.env"
|
|
31
|
-
|
|
32
|
-
results = {}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def check(name, cond):
|
|
36
|
-
results[name] = bool(cond)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# ── 타깃 기반(제로설정, env 없음) ──
|
|
40
|
-
os.environ.pop("ROUTINECODE_DEV", None)
|
|
41
|
-
check("zeroconf: dev 소스 hook Read 허용", cp(hook) is False)
|
|
42
|
-
check("zeroconf: dev 소스 plugin Read 허용", cp(plugin) is False)
|
|
43
|
-
check("zeroconf: dev 소스 hook cat 허용", bc("cat " + hook) is False)
|
|
44
|
-
check("zeroconf: 설치본 hook Read 차단", cp(installed) is True)
|
|
45
|
-
check("zeroconf: 설치본 hook cat 차단", bc("cat " + installed) is True)
|
|
46
|
-
check("zeroconf: 홈 config Read 차단", cp(home_cfg) is True)
|
|
47
|
-
check("zeroconf: .env 는 차단 대신 값 스크럽", cp(env_secret) is False)
|
|
48
|
-
|
|
49
|
-
# ── 명시 opt-in(ROUTINECODE_DEV=1): 소스보호만 완화, config/시크릿 유지 ──
|
|
50
|
-
os.environ["ROUTINECODE_DEV"] = "1"
|
|
51
|
-
check("env=1: 설치본 hook Read 허용", cp(installed) is False)
|
|
52
|
-
check("env=1(dev 체크아웃): 홈 config 참조 허용", cp(home_cfg) is False)
|
|
53
|
-
check("env=1: .env 는 차단 대신 값 스크럽", cp(env_secret) is False)
|
|
54
|
-
red, matches = sf.redact("token=rcw-" + "a" * 40)
|
|
55
|
-
check("env=1: 시크릿 redaction 유지", "REDACTED" in red and len(matches) >= 1)
|
|
56
|
-
os.environ.pop("ROUTINECODE_DEV", None)
|
|
57
|
-
|
|
58
|
-
ok = all(results.values())
|
|
59
|
-
for k, v in results.items():
|
|
60
|
-
print((" PASS " if v else " FAIL ") + k)
|
|
61
|
-
print(("dev-mode: %d/%d passed" % (sum(results.values()), len(results))))
|
|
62
|
-
sys.exit(0 if ok else 1)
|