@routinecrew/routinecode 2.31.77 → 2.31.86
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/README.md +2 -2
- package/bin/cli.sh +23 -0
- package/bin/prompt-vault.dat +1 -0
- package/bin/prompt-vault.js +51 -1
- package/bin/rc-board.js +58 -0
- package/bin/rc-config.js +756 -1
- package/bin/rc-credit-turn.js +2 -1
- package/bin/rc-grant.js +2 -1
- package/bin/rc-login.js +2 -0
- package/bin/rc-map.js +132 -0
- package/bin/rc-privacy.js +200 -0
- package/bin/rc-skills.js +31 -0
- package/bin/rc-team.js +2 -1
- package/bin/setup.js +4 -0
- package/hooks/cc-compat-watch.js +2 -1
- package/hooks/claim-questions.json +40 -0
- package/hooks/hooks-config.json +108 -1
- package/hooks/lib/agent_budget.py +122 -0
- package/hooks/lib/agent_telemetry.py +143 -0
- package/hooks/lib/attest_reader.py +15 -6
- package/hooks/lib/attribution_judge.py +109 -0
- package/hooks/lib/board-golden.json +268 -0
- package/hooks/lib/board.py +503 -0
- package/hooks/lib/board_sync.py +535 -0
- package/hooks/lib/cc-surface.json +1 -1
- package/hooks/lib/claim_structure.py +412 -0
- package/hooks/lib/completion_log.py +12 -5
- package/hooks/lib/config_bash_track.py +114 -28
- package/hooks/lib/config_guard.py +137 -5
- package/hooks/lib/edit_tracker.py +182 -0
- package/hooks/lib/error_line.py +94 -0
- package/hooks/lib/escalation_restore.py +66 -0
- package/hooks/lib/i18n.py +37 -15
- package/hooks/lib/knowledge_items.py +1407 -0
- package/hooks/lib/knowledge_scope.py +123 -0
- package/hooks/lib/known_solution.py +37 -9
- package/hooks/lib/log_compact.py +85 -0
- package/hooks/lib/metacog_signals.py +228 -0
- package/hooks/lib/orch_decision.py +690 -0
- package/hooks/lib/premise-golden.json +96 -0
- package/hooks/lib/presence.py +10 -3
- package/hooks/lib/privacy_log.py +35 -0
- package/hooks/lib/receipt.py +137 -14
- package/hooks/lib/review_gate.py +83 -0
- package/hooks/lib/routine_skill_eval.py +213 -0
- package/hooks/lib/secret_filter.py +2 -1
- package/hooks/lib/skill_drafts.py +188 -0
- package/hooks/lib/sync_manager.py +121 -26
- package/hooks/lib/usage_v2.py +680 -0
- package/hooks/lib/work_kind.py +198 -0
- package/hooks/lib/work_kind_events.py +361 -0
- package/hooks/pending-drainer.sh +28 -0
- package/hooks/post-agent-budget.sh +50 -0
- package/hooks/post-agent-return.sh +89 -3
- package/hooks/post-bash-failure.sh +39 -0
- package/hooks/post-bash-knowledge.sh +15 -34
- package/hooks/post-bash-verify.sh +33 -16
- package/hooks/post-build-check.sh +16 -18
- package/hooks/post-config-context.sh +13 -0
- package/hooks/post-delegation-nudge.sh +12 -1
- package/hooks/post-edit-track.sh +19 -28
- package/hooks/post-orch-decision.sh +35 -0
- package/hooks/post-read-config-context.sh +20 -0
- package/hooks/pre-account-guard.sh +1 -1
- package/hooks/pre-agent-spawn.mjs +2 -1
- package/hooks/pre-agent-spawn.sh +12 -1
- package/hooks/pre-bash-guard.sh +61 -3
- package/hooks/pre-bash-knowledge.sh +46 -0
- package/hooks/pre-credit-guard.sh +1 -1
- package/hooks/pre-edit-board.sh +44 -0
- package/hooks/pre-edit-check.sh +29 -5
- package/hooks/pre-edit-config-gate.sh +1 -1
- package/hooks/pre-edit-domain-gate.sh +23 -22
- package/hooks/pre-mark-complete.sh +32 -4
- package/hooks/pre-read-knowledge-inject.sh +34 -24
- package/hooks/pre-review-gate.sh +17 -0
- package/hooks/recorder-runner.sh +25 -2
- package/hooks/session-start-compact.sh +28 -0
- package/hooks/session-start.sh +167 -19
- package/hooks/skill-knowledge.sh +37 -0
- package/hooks/stop-claim-check.v3.sh +21 -3
- package/hooks/stop-usage-metrics.sh +138 -83
- package/hooks/subagent-stop-usage.sh +25 -0
- package/hooks/user-prompt-submit.sh +10 -4
- 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-guide.js +1 -0
- package/mcp-intelligence/dist/knowledge-handlers.js +1 -1
- package/mcp-intelligence/dist/knowledge-migrate.js +1 -0
- package/mcp-intelligence/dist/knowledge-record.js +1 -0
- package/mcp-intelligence/dist/knowledge-scope.js +1 -0
- package/mcp-intelligence/dist/mention-extractor.js +1 -1
- package/mcp-intelligence/dist/provenance.js +1 -1
- package/mcp-intelligence/dist/sanitize.generated.js +242 -0
- 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/sanitize.generated.js +242 -0
- package/mcp-log-watcher/dist/websocket-server.js +1 -1
- package/mcp-log-watcher/package.json +1 -1
- package/mcp-plan-manager/dist/__tests__/file-ops-knowledge-dir.test.js +1 -1
- 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/analysis-ledger.js +590 -0
- package/mcp-routinecode/dist/attestation.js +1 -1
- package/mcp-routinecode/dist/blast-radius.js +1 -1
- package/mcp-routinecode/dist/board.js +1 -0
- package/mcp-routinecode/dist/build-id.js +1 -0
- package/mcp-routinecode/dist/changeset.js +1 -1
- package/mcp-routinecode/dist/config-auth.js +1 -1
- package/mcp-routinecode/dist/config-map/applied.js +1 -0
- package/mcp-routinecode/dist/config-map/arch-graph.js +1 -1
- package/mcp-routinecode/dist/config-map/architect-store.js +1132 -1
- package/mcp-routinecode/dist/config-map/assign.js +1 -1
- package/mcp-routinecode/dist/config-map/audit-cli.js +1 -1
- package/mcp-routinecode/dist/config-map/audit.js +1 -1
- package/mcp-routinecode/dist/config-map/blocks.js +1 -1
- package/mcp-routinecode/dist/config-map/briefing.js +541 -1
- package/mcp-routinecode/dist/config-map/certify.js +10 -5
- package/mcp-routinecode/dist/config-map/const-use.js +1 -1
- package/mcp-routinecode/dist/config-map/context.js +219 -0
- package/mcp-routinecode/dist/config-map/convention-candidates.js +1 -0
- package/mcp-routinecode/dist/config-map/decisions.js +1 -1
- package/mcp-routinecode/dist/config-map/decls.js +1 -1
- package/mcp-routinecode/dist/config-map/drift.js +1 -1
- package/mcp-routinecode/dist/config-map/dup-safety.js +1 -1
- package/mcp-routinecode/dist/config-map/extract.js +1 -1
- package/mcp-routinecode/dist/config-map/field-contract.js +1 -1
- package/mcp-routinecode/dist/config-map/gate.js +796 -1
- package/mcp-routinecode/dist/config-map/hash.js +1 -1
- package/mcp-routinecode/dist/config-map/ident-norm.js +1 -1
- package/mcp-routinecode/dist/config-map/index-store.js +1051 -1
- package/mcp-routinecode/dist/config-map/light-eval.js +253 -1
- package/mcp-routinecode/dist/config-map/link.js +1 -1
- package/mcp-routinecode/dist/config-map/linked-repos.js +1 -1
- package/mcp-routinecode/dist/config-map/lookup.js +1 -1
- package/mcp-routinecode/dist/config-map/louvain.js +1 -1
- package/mcp-routinecode/dist/config-map/maintenance-cli.js +1 -1
- package/mcp-routinecode/dist/config-map/names.js +1 -1
- package/mcp-routinecode/dist/config-map/post-bash-eval.js +105 -0
- package/mcp-routinecode/dist/config-map/proposals.js +1 -1
- package/mcp-routinecode/dist/config-map/ratchet.js +148 -0
- package/mcp-routinecode/dist/config-map/recheck.js +148 -1
- package/mcp-routinecode/dist/config-map/repo-id.js +1 -1
- package/mcp-routinecode/dist/config-map/route-security.js +1 -1
- package/mcp-routinecode/dist/config-map/rule-import.js +1 -1
- package/mcp-routinecode/dist/config-map/scc.js +1 -1
- package/mcp-routinecode/dist/config-map/shape-eval.js +1 -1
- package/mcp-routinecode/dist/config-map/shape.js +1 -1
- package/mcp-routinecode/dist/config-map/snapshot.js +1 -1
- package/mcp-routinecode/dist/config-map/sole-impl.js +1 -1
- package/mcp-routinecode/dist/config-map/stable-id.js +1 -1
- package/mcp-routinecode/dist/config-map/store.js +1 -1
- package/mcp-routinecode/dist/config-map/swagger-check.js +1 -1
- package/mcp-routinecode/dist/config-map/task-eval.js +369 -1
- package/mcp-routinecode/dist/config-map/templates.js +1 -1
- package/mcp-routinecode/dist/contracts.generated.js +1 -1
- package/mcp-routinecode/dist/coverage.js +1 -1
- package/mcp-routinecode/dist/edit-tracker.js +1 -0
- 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/normalize-sig.js +1 -0
- package/mcp-routinecode/dist/observed-draft.js +1 -1
- package/mcp-routinecode/dist/observed-escalation.js +1 -0
- 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/sanitize.generated.js +242 -0
- package/mcp-routinecode/dist/session-registry.js +1 -0
- package/mcp-routinecode/dist/skill-pack/sync.js +629 -0
- package/mcp-routinecode/dist/skill-pack/validate.js +278 -0
- package/mcp-routinecode/dist/telemetry-analyzer.js +1 -1
- package/mcp-routinecode/dist/test-runner.js +1 -1
- package/mcp-routinecode/dist/verification.js +1 -1
- package/mcp-routinecode/dist/viral-loop.js +1 -1
- package/mcp-routinecode/package.json +1 -1
- package/package.json +3 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/agents/analyzer.md.sealed +1 -1
- package/plugin/agents/architect.md.sealed +1 -1
- package/plugin/agents/crawler.md.sealed +1 -1
- package/plugin/agents/explorer.md.sealed +1 -1
- package/plugin/agents/implementor.md.sealed +1 -1
- package/plugin/agents/looker.md.sealed +1 -1
- package/plugin/agents/planner.md.sealed +1 -1
- package/plugin/agents/recorder.md.sealed +1 -1
- package/plugin/agents/reviewer.md.sealed +1 -1
- package/plugin/agents/verifier.md.sealed +1 -1
- package/plugin/commands/analyze.md.sealed +1 -1
- package/plugin/commands/plan.md.sealed +1 -1
- package/plugin/commands/rc.md.sealed +1 -1
- package/plugin/commands/receipt.md.sealed +1 -1
- package/plugin/commands/recharge.md.sealed +1 -1
- package/plugin/commands/routines.md.sealed +1 -1
- package/plugin/commands/share.md.sealed +1 -1
- package/plugin/routinecode-prompt.md.sealed +1 -1
|
@@ -1 +1,1051 @@
|
|
|
1
|
-
const a22_0x2bcf1e=a22_0x2e6b;(function(_0x472372,_0xb04628){const _0xc3e369=a22_0x2e6b,_0x1ad124=_0x472372();while(!![]){try{const _0x1584ca=-parseInt(_0xc3e369(0x143,'J3g&'))/(-0x11e4+0x2*0x502+-0x7e1*-0x1)*(-parseInt(_0xc3e369(0x273,']y1E'))/(0x1b00+-0xd*-0x2dd+-0x4037))+-parseInt(_0xc3e369(0x2b6,'Lf1I'))/(0xb*-0x43+0x39*0x2f+-0x793)+-parseInt(_0xc3e369(0x2ce,'#0I0'))/(0x15a7*-0x1+-0x14fb+0x2aa6)*(parseInt(_0xc3e369(0x1b1,'ZLn2'))/(-0x2*0x1226+0x39*0x86+-0x67b*-0x1))+-parseInt(_0xc3e369(0x2dd,'or#Y'))/(0x1223+0xf9*0x11+-0x22a6)*(parseInt(_0xc3e369(0x214,'Po&X'))/(0xe3*0x22+-0x25aa+0x78b))+parseInt(_0xc3e369(0x26d,'9ng9'))/(-0x21c4+-0x132f+0x34fb)+-parseInt(_0xc3e369(0x1da,'$t%2'))/(-0xb75*0x1+0x2*-0x8eb+-0x4*-0x755)*(-parseInt(_0xc3e369(0x25d,'lDY)'))/(-0x26b2+0x2601+0xbb))+-parseInt(_0xc3e369(0x330,'OQ[*'))/(-0x2df*0x3+-0x338+0xbe0);if(_0x1584ca===_0xb04628)break;else _0x1ad124['push'](_0x1ad124['shift']());}catch(_0x4f532c){_0x1ad124['push'](_0x1ad124['shift']());}}}(a22_0x73c9,-0x1*-0xe1464+0x7b*-0x206d+0xacaf0));import*as a22_0x4b2235 from'fs';import*as a22_0x571380 from'path';import*as a22_0x267c27 from'crypto';import{matchGlob}from'./shape-eval.js';export function homeDir(){return process.env.HOME||process.env.USERPROFILE||'/';}export function configMapDir(){const _0x19cce4=a22_0x2e6b;return process.env.ROUTINECODE_CONFIG_MAP_DIR||a22_0x571380[_0x19cce4(0x263,'F9CT')](homeDir(),_0x19cce4(0x1c4,'or#Y'),_0x19cce4(0x1ca,'BcSP'),_0x19cce4(0x243,'F9CT'));}export function knowledgeDir(){const _0x4fb5e5=a22_0x2e6b;return process.env.ROUTINECODE_KNOWLEDGE_DIR||a22_0x571380[_0x4fb5e5(0x326,'3P*n')](homeDir(),_0x4fb5e5(0x33c,'$t%2'),_0x4fb5e5(0x1c0,'iXIT'));}export function realpathLoose(_0x1deb0a){const _0x555b77=a22_0x2e6b,_0x48bd6d=a22_0x571380[_0x555b77(0x378,'lDY)')](_0x1deb0a),_0x1fc136=[];let _0x9908f0=_0x48bd6d;for(let _0x5a54b5=-0x16d*0x11+-0x62b+0x1e68;_0x5a54b5<-0x1090+-0xa*0x11+-0x1*-0x117a;_0x5a54b5++){try{return a22_0x571380[_0x555b77(0x142,'$t%2')](a22_0x4b2235[_0x555b77(0x2e7,'lDY)')](_0x9908f0),..._0x1fc136[_0x555b77(0x1c3,'9ng9')]());}catch{}const _0x4a4eb4=a22_0x571380[_0x555b77(0x34f,'szdD')](_0x9908f0);if(_0x4a4eb4===_0x9908f0)break;_0x1fc136[_0x555b77(0x157,'nH7B')](a22_0x571380[_0x555b77(0x16b,'NHWr')](_0x9908f0)),_0x9908f0=_0x4a4eb4;}return _0x48bd6d;}export function findToplevel(_0x10788f){const _0x3b2e00=a22_0x2e6b;let _0x59721d=realpathLoose(_0x10788f);for(let _0x5d943b=-0xd*0x1e1+0xeba+0x9b3;_0x5d943b<0x1b9d+0x23e+0xb*-0x2b1;_0x5d943b++){if(a22_0x4b2235[_0x3b2e00(0x2e0,'Ncoa')](a22_0x571380[_0x3b2e00(0x1c5,'GvAu')](_0x59721d,_0x3b2e00(0x362,'4UZ%'))))return _0x59721d;const _0x4c3b0f=a22_0x571380[_0x3b2e00(0x2a3,'3P*n')](_0x59721d);if(_0x4c3b0f===_0x59721d)return null;_0x59721d=_0x4c3b0f;}return null;}export function mainWorktreeOf(_0x57b821){const _0xb9b219=a22_0x2e6b,_0x462fa6=a22_0x571380[_0xb9b219(0x188,'nH7B')](_0x57b821,_0xb9b219(0x338,'9ng9'));try{if(!a22_0x4b2235[_0xb9b219(0x314,'G0OZ')](_0x462fa6)[_0xb9b219(0x2ee,'DALD')]())return null;const _0x3d3681=/^gitdir:\s*(.+?)\s*$/m[_0xb9b219(0x31a,'#r&w')](a22_0x4b2235[_0xb9b219(0x33d,'Lf1I')](_0x462fa6,_0xb9b219(0x296,'OQ[*')));if(!_0x3d3681)return null;const _0x5723b2=a22_0x571380[_0xb9b219(0x23e,'lpfv')](_0x57b821,_0x3d3681[0x267+0x1*-0xeef+-0xc89*-0x1]);if(a22_0x571380[_0xb9b219(0x345,'or#Y')](a22_0x571380[_0xb9b219(0x1b0,'U[nV')](_0x5723b2))!==_0xb9b219(0x217,'OQ[*'))return null;const _0x86e49=a22_0x4b2235[_0xb9b219(0x155,'!ewi')](a22_0x571380[_0xb9b219(0x2ed,'hNT#')](_0x5723b2,_0xb9b219(0x1df,'szdD')),_0xb9b219(0x323,'a6gK'))[_0xb9b219(0x201,'F9CT')]();if(!_0x86e49)return null;const _0xadbad9=a22_0x571380[_0xb9b219(0x20d,'N3!A')](_0x5723b2,_0x86e49);if(a22_0x571380[_0xb9b219(0x2f9,'DALD')](_0xadbad9)!==_0xb9b219(0x38d,'U[nV'))return null;const _0x1816fb=a22_0x571380[_0xb9b219(0x174,'J3g&')](_0xadbad9);if(a22_0x4b2235[_0xb9b219(0x369,'Lf1I')](a22_0x571380[_0xb9b219(0x2c3,'9K[T')](_0x1816fb,_0xb9b219(0x2cc,'OQ[*')))!==a22_0x4b2235[_0xb9b219(0x37d,'DALD')](_0xadbad9))return null;if(!a22_0x4b2235[_0xb9b219(0x344,'#0I0')](_0xadbad9)[_0xb9b219(0x2d8,'OQ[*')]())return null;return a22_0x4b2235[_0xb9b219(0x276,'F9CT')](_0x1816fb);}catch{return null;}}export function mapTopOf(_0x5b2816){return mainWorktreeOf(_0x5b2816)??_0x5b2816;}export function repoKeyOf(_0x50ac75){const _0xc168d0=a22_0x2e6b;return a22_0x267c27[_0xc168d0(0x1e7,'7UnL')](_0xc168d0(0x15b,'#pqQ'))[_0xc168d0(0x307,'szdD')](_0x50ac75)[_0xc168d0(0x164,'GvAu')](_0xc168d0(0x219,'#pqQ'))[_0xc168d0(0x207,'GM2d')](-0x79*0x1+0x52f*0x1+-0x4b6,0x124e+-0x1*-0x11f3+-0x2431);}export function storeDirFor(_0x41cacb,_0x4b396b){const _0x5cc039=a22_0x2e6b,_0x2853cc=a22_0x571380[_0x5cc039(0x2b8,'mw!k')](configMapDir(),repoKeyOf(_0x41cacb));return _0x4b396b?a22_0x571380[_0x5cc039(0x212,'Lf1I')](_0x2853cc,_0x5cc039(0x329,'#pqQ')+a22_0x267c27[_0x5cc039(0x31c,'dK%p')](_0x5cc039(0x1e2,'Po&X'))[_0x5cc039(0x258,'GM2d')](_0x4b396b)[_0x5cc039(0x1fb,'ZLn2')](_0x5cc039(0x227,'#K9['))[_0x5cc039(0x12e,'Po&X')](0x98d*-0x2+-0x223f+0x79f*0x7,-0x2*0x113f+-0x2198+0x441e)):_0x2853cc;}export function locateMap(_0x2d1ff5){const _0x45dd37=a22_0x2e6b,_0x2435d4=realpathLoose(_0x2d1ff5);let _0x4560e2=_0x2435d4;try{if(!a22_0x4b2235[_0x45dd37(0x395,'dK%p')](_0x2435d4)[_0x45dd37(0x261,'nH7B')]())_0x4560e2=a22_0x571380[_0x45dd37(0x20f,'TwdR')](_0x2435d4);}catch{_0x4560e2=a22_0x571380[_0x45dd37(0x187,'IM[B')](_0x2435d4);}const _0x16e541=findToplevel(_0x4560e2);if(!_0x16e541)return null;const _0x14156c=mapTopOf(_0x16e541);for(let _0x4c4918=-0x2*0xeb+-0x1b6f*-0x1+-0x1999;_0x4c4918<-0x4e1+-0x62+-0x1*-0x583;_0x4c4918++){const _0x5bec72=a22_0x571380[_0x45dd37(0x2ad,'a#s$')](_0x16e541,_0x4560e2)[_0x45dd37(0x2ea,'yA4B')](a22_0x571380[_0x45dd37(0x29f,'TwdR')])[_0x45dd37(0x2f0,'N3!A')]('/');if(_0x5bec72[_0x45dd37(0x19a,'BcSP')]('..'))break;const _0xdfde10=storeDirFor(_0x14156c,_0x5bec72);if(a22_0x4b2235[_0x45dd37(0x139,'aPFR')](a22_0x571380[_0x45dd37(0x364,'a#s$')](_0xdfde10,_0x45dd37(0x35c,'N3!A'))))return{'toplevel':_0x16e541,'mapTop':_0x14156c,'root':_0x4560e2,'storeDir':_0xdfde10};if(_0x4560e2===_0x16e541)break;_0x4560e2=a22_0x571380[_0x45dd37(0x267,'lDY)')](_0x4560e2);}return null;}export function mapsForCwd(_0x119c36,_0x5d0fd1=0x59*0x1b+-0x2507+-0x1ba7*-0x1){const _0x266bf5=a22_0x2e6b,_0x2a77c5=[],_0x373355=locateMap(_0x119c36);if(_0x373355)_0x2a77c5[_0x266bf5(0x200,'Ncoa')](_0x373355);const _0x157b7c=realpathLoose(_0x119c36),_0x3a7689=findToplevel(_0x157b7c);if(!_0x3a7689)return _0x2a77c5;const _0x35b322=mapTopOf(_0x3a7689),_0x5d1a2d=a22_0x571380[_0x266bf5(0x216,'GM2d')](configMapDir(),repoKeyOf(_0x35b322));let _0x3316c1=[];try{_0x3316c1=a22_0x4b2235[_0x266bf5(0x38f,'TwdR')](_0x5d1a2d)[_0x266bf5(0x2bf,'l1sk')](_0x498252=>_0x498252[_0x266bf5(0x221,'U[nV')](_0x266bf5(0x2af,'3P*n')))[_0x266bf5(0x17f,'3P*n')]();}catch{return _0x2a77c5;}for(const _0x2c5381 of _0x3316c1){if(_0x2a77c5[_0x266bf5(0x36d,'mw!k')]>=_0x5d0fd1)break;const _0x4d727a=a22_0x571380[_0x266bf5(0x2aa,'OG8c')](_0x5d1a2d,_0x2c5381);if(_0x2a77c5[_0x266bf5(0x282,'Ncoa')](_0x17740a=>_0x17740a[_0x266bf5(0x24a,'Ncoa')]===_0x4d727a))continue;const _0x565d59=readJson(a22_0x571380[_0x266bf5(0x175,'aCdu')](_0x4d727a,_0x266bf5(0x279,'IM[B')));if(!_0x565d59?.[_0x266bf5(0x2fc,'DALD')]||!a22_0x4b2235[_0x266bf5(0x106,'GvAu')](a22_0x571380[_0x266bf5(0x2a1,'9ng9')](_0x4d727a,_0x266bf5(0x172,'yg@#'))))continue;const _0x1babee=a22_0x571380[_0x266bf5(0x1d6,'#r&w')](_0x35b322,_0x565d59[_0x266bf5(0x32a,'lDY)')]);if(_0x1babee[_0x266bf5(0x156,'N3!A')]('..')||a22_0x571380[_0x266bf5(0x254,'OG8c')](_0x1babee))continue;const _0x14aba9=_0x1babee?a22_0x571380[_0x266bf5(0x175,'aCdu')](_0x3a7689,_0x1babee):_0x3a7689,_0x411fab=a22_0x571380[_0x266bf5(0x232,'3P*n')](_0x157b7c,_0x14aba9);if(_0x411fab[_0x266bf5(0x2f7,'#r&w')]('..')||a22_0x571380[_0x266bf5(0x24c,'szdD')](_0x411fab))continue;_0x2a77c5[_0x266bf5(0x200,'Ncoa')]({'toplevel':_0x3a7689,'mapTop':_0x35b322,'root':_0x14aba9,'storeDir':_0x4d727a});}return _0x2a77c5;}export function readJson(_0x466770){const _0x7293c1=a22_0x2e6b;try{return JSON[_0x7293c1(0x1ba,'IM[B')](a22_0x4b2235[_0x7293c1(0x25a,'G0OZ')](_0x466770,_0x7293c1(0x2f6,'Sx%)')));}catch{return null;}}export function writeJsonAtomic(_0x546d72,_0x269432){const _0x58f6fe=a22_0x2e6b;a22_0x4b2235[_0x58f6fe(0x184,'mw!k')](a22_0x571380[_0x58f6fe(0x187,'IM[B')](_0x546d72),{'recursive':!![]});const _0x50face=_0x546d72+'.'+process[_0x58f6fe(0x1af,'aPFR')]+_0x58f6fe(0x385,'F9CT');a22_0x4b2235[_0x58f6fe(0x2ff,'$t%2')](_0x50face,JSON[_0x58f6fe(0x14b,'BcSP')](_0x269432)),a22_0x4b2235[_0x58f6fe(0x224,'IM[B')](_0x50face,_0x546d72);}export function loadIndex(_0x50619f){const _0x44dc7e=a22_0x2e6b,_0x349aa0=readJson(a22_0x571380[_0x44dc7e(0x1ec,'aPFR')](_0x50619f,_0x44dc7e(0x245,'Sx%)')));if(!_0x349aa0||typeof _0x349aa0!==_0x44dc7e(0x1d4,'ZLn2')||!_0x349aa0[_0x44dc7e(0x189,'BcSP')])return null;return _0x349aa0[_0x44dc7e(0x37c,'GM2d')]??={},_0x349aa0[_0x44dc7e(0x285,'lpfv')]??={},_0x349aa0[_0x44dc7e(0x1a4,'IM[B')]??={},_0x349aa0[_0x44dc7e(0x22f,'GM2d')]??={},_0x349aa0;}export function fileOfId(_0x5657d5){const _0x1a9a80=a22_0x2e6b,_0x193198=/^(?:sym|cmp|model|type):(.+)#[^#]*$/[_0x1a9a80(0x241,'#pqQ')](_0x5657d5);return _0x193198?_0x193198[-0x1b61+-0x92*0x3c+-0x2*-0x1ecd][_0x1a9a80(0x138,'$t%2')](/@\d+$/,''):null;}export class CiStore{[a22_0x2bcf1e(0x2de,'J3g&')];[a22_0x2bcf1e(0x208,'hNT#')]=null;[a22_0x2bcf1e(0x354,'9K[T')]=new Map();constructor(_0x2f4cb8){const _0x48ed6b=a22_0x2bcf1e;this[_0x48ed6b(0x13a,'4UZ%')]=_0x2f4cb8;}[a22_0x2bcf1e(0x272,'mw!k')](){const _0x435861=a22_0x2bcf1e;if(this[_0x435861(0x1bb,'TwdR')]===null)try{this[_0x435861(0x38c,'#pqQ')]=a22_0x4b2235[_0x435861(0x181,'szdD')](a22_0x571380[_0x435861(0x38e,'iXIT')](this[_0x435861(0x206,'Po&X')],_0x435861(0x229,'mw!k')),_0x435861(0x115,'aPFR'));}catch{this[_0x435861(0x294,'@ZIb')]='';}return this[_0x435861(0x281,'F9CT')];}[a22_0x2bcf1e(0x225,']y1E')](_0x2cfe0f){const _0x33b0d9=a22_0x2bcf1e;if(this[_0x33b0d9(0x394,'U[nV')][_0x33b0d9(0x343,'OG8c')](_0x2cfe0f))return this[_0x33b0d9(0x1ee,'N3!A')][_0x33b0d9(0x28c,'F9CT')](_0x2cfe0f);const _0x403681=this[_0x33b0d9(0x171,'#0I0')](),_0x210a84=_0x33b0d9(0x2a6,'Sx%)')+JSON[_0x33b0d9(0x32f,'a#s$')](_0x2cfe0f)+',',_0x51dc74=_0x403681[_0x33b0d9(0x2c2,']y1E')](_0x210a84);let _0x190a5e=null;if(_0x51dc74>=0x5a2+-0xd*-0x155+0x19*-0xeb){const _0x1365b0=_0x403681[_0x33b0d9(0x1ce,'or#Y')]('\x0a',_0x51dc74);try{_0x190a5e=JSON[_0x33b0d9(0x1f9,'GvAu')](_0x403681[_0x33b0d9(0x168,']y1E')](_0x51dc74,_0x1365b0<-0x1ed9+0x93*0x9+0x15a*0x13?undefined:_0x1365b0));}catch{_0x190a5e=null;}}return this[_0x33b0d9(0x1b4,'TwdR')][_0x33b0d9(0x2bc,'iXIT')](_0x2cfe0f,_0x190a5e),_0x190a5e;}[a22_0x2bcf1e(0x22d,'#r&w')](_0x471885,_0x39e0b6=0x1f*0xdd+-0x23c9+0x912){const _0x2f1c90=a22_0x2bcf1e,_0x53a7c0=this[_0x2f1c90(0x32e,'IM[B')](),_0x45cb25=_0x2f1c90(0x2b3,'3P*n')+JSON[_0x2f1c90(0x27a,'DALD')](_0x471885)+',',_0x1cfd97=[];let _0x2cc790=-0x1*-0x76e+-0x1*-0x20a5+-0x2813;while(_0x1cfd97[_0x2f1c90(0x11c,'ZLn2')]<_0x39e0b6){const _0x52a028=_0x53a7c0[_0x2f1c90(0x347,'U[nV')](_0x45cb25,_0x2cc790);if(_0x52a028<0x177+0x805+0x4be*-0x2)break;const _0x3aa4d4=_0x53a7c0[_0x2f1c90(0x24f,'7UnL')]('\x0a',_0x52a028)+(-0x1c6*-0x5+-0x15fc+-0xd1f*-0x1),_0x27cc0c=_0x53a7c0[_0x2f1c90(0x29c,'lDY)')]('\x0a',_0x52a028);try{_0x1cfd97[_0x2f1c90(0x302,'Lf1I')](JSON[_0x2f1c90(0x26f,'NHWr')](_0x53a7c0[_0x2f1c90(0x236,'N3!A')](_0x3aa4d4,_0x27cc0c<0x24af*-0x1+-0xec7+0x19bb*0x2?undefined:_0x27cc0c)));}catch{}_0x2cc790=_0x27cc0c<-0xb84+-0x183e+0x23c2*0x1?_0x53a7c0[_0x2f1c90(0x33a,'!ewi')]:_0x27cc0c;}return _0x1cfd97;}}export class AliveCheck{[a22_0x2bcf1e(0x1dc,']y1E')];[a22_0x2bcf1e(0x1b3,'3P*n')]=new Map();constructor(_0x21e09f){const _0x3c9a5e=a22_0x2bcf1e;this[_0x3c9a5e(0x1eb,'aCdu')]=_0x21e09f;}[a22_0x2bcf1e(0x2cb,'BcSP')](_0x312f99){const _0x50a892=a22_0x2bcf1e;if(!_0x312f99[_0x50a892(0x21e,'N3!A')])return![];let _0x1b148f=this[_0x50a892(0x146,'or#Y')][_0x50a892(0x1bf,'@ZIb')](_0x312f99[_0x50a892(0x12b,'GvAu')]);if(_0x1b148f===undefined){try{_0x1b148f=a22_0x4b2235[_0x50a892(0x29a,'or#Y')](a22_0x571380[_0x50a892(0x16d,'Ncoa')](this[_0x50a892(0x380,'or#Y')],_0x312f99[_0x50a892(0x13f,'Ncoa')]),_0x50a892(0x1e8,'Ncoa'));}catch{_0x1b148f=null;}this[_0x50a892(0x38b,'!ewi')][_0x50a892(0x27e,'lDY)')](_0x312f99[_0x50a892(0x303,'DALD')],_0x1b148f);}if(_0x1b148f===null)return![];return _0x312f99[_0x50a892(0x108,'nH7B')]===_0x50a892(0x110,'aPFR')?/export\s+default\b/[_0x50a892(0x269,'IM[B')](_0x1b148f):_0x1b148f[_0x50a892(0x192,'$t%2')](_0x312f99[_0x50a892(0x304,'$t%2')]);}}export const DEFAULT_ENTRYPOINTS=[a22_0x2bcf1e(0x34d,'9ng9'),a22_0x2bcf1e(0x34b,'OG8c'),a22_0x2bcf1e(0x2ba,'GvAu'),a22_0x2bcf1e(0x2d5,'szdD'),a22_0x2bcf1e(0x1f8,'9K[T'),a22_0x2bcf1e(0x14a,'iXIT'),a22_0x2bcf1e(0x284,'9ng9'),a22_0x2bcf1e(0x166,'yA4B'),a22_0x2bcf1e(0x339,'nH7B'),a22_0x2bcf1e(0x321,'yg@#'),a22_0x2bcf1e(0x350,'BcSP'),a22_0x2bcf1e(0x10d,'hNT#'),a22_0x2bcf1e(0x28d,'#r&w'),a22_0x2bcf1e(0x356,'3P*n'),a22_0x2bcf1e(0x382,'lDY)'),a22_0x2bcf1e(0x180,'3P*n'),a22_0x2bcf1e(0x2a8,'Po&X'),a22_0x2bcf1e(0x121,'9K[T'),a22_0x2bcf1e(0x370,'szdD'),a22_0x2bcf1e(0x226,'N3!A'),a22_0x2bcf1e(0x1ae,'szdD'),a22_0x2bcf1e(0x2f5,'N3!A'),a22_0x2bcf1e(0x179,'hNT#'),a22_0x2bcf1e(0x2e9,'or#Y'),a22_0x2bcf1e(0x2a4,'IM[B'),a22_0x2bcf1e(0x311,'or#Y')];export function effectiveEntrypoints(_0x5625c6){const _0x46d2d5=a22_0x2bcf1e,_0x40c1f8=Array[_0x46d2d5(0x231,'GvAu')](_0x5625c6?.[_0x46d2d5(0x353,'F9CT')])?_0x5625c6[_0x46d2d5(0x32b,'OQ[*')][_0x46d2d5(0x1b9,'mw!k')](_0x253635=>typeof _0x253635===_0x46d2d5(0x266,'GvAu')):null;if(!_0x40c1f8)return DEFAULT_ENTRYPOINTS;if(_0x5625c6?.[_0x46d2d5(0x31f,'Po&X')]===_0x46d2d5(0x23c,'7UnL'))return _0x40c1f8;return Array[_0x46d2d5(0x196,'nH7B')](new Set([...DEFAULT_ENTRYPOINTS,..._0x40c1f8]));}export const DEFAULT_PUBLIC_API=[a22_0x2bcf1e(0x2f3,'9K[T')];export const DEFAULT_LAYERS_LITE={'order':[a22_0x2bcf1e(0x1a7,'#r&w'),a22_0x2bcf1e(0x2f8,'nH7B'),a22_0x2bcf1e(0x11a,'a#s$'),a22_0x2bcf1e(0x10b,']y1E')],'defs':[{'name':a22_0x2bcf1e(0x167,'#K9['),'match':[a22_0x2bcf1e(0x20c,'9K[T'),a22_0x2bcf1e(0x18c,'yg@#'),a22_0x2bcf1e(0x29b,']y1E'),a22_0x2bcf1e(0x26c,'Lf1I'),a22_0x2bcf1e(0x11e,'yg@#')]},{'name':a22_0x2bcf1e(0x1d8,'F9CT'),'match':[a22_0x2bcf1e(0x277,'#0I0'),a22_0x2bcf1e(0x2da,'nH7B')]},{'name':a22_0x2bcf1e(0x11a,'a#s$'),'match':[a22_0x2bcf1e(0x293,'l1sk'),a22_0x2bcf1e(0x325,'hNT#')]},{'name':a22_0x2bcf1e(0x19e,'a#s$'),'match':[a22_0x2bcf1e(0x21d,'N3!A'),a22_0x2bcf1e(0x2c7,'OQ[*')]},{'name':a22_0x2bcf1e(0x170,'hNT#'),'match':[a22_0x2bcf1e(0x28a,'F9CT'),a22_0x2bcf1e(0x16e,'l1sk')]},{'name':a22_0x2bcf1e(0x18b,'4UZ%'),'match':[a22_0x2bcf1e(0x2dc,'#pqQ')]},{'name':a22_0x2bcf1e(0x335,'@ZIb'),'match':[a22_0x2bcf1e(0x22c,'J3g&')]},{'name':a22_0x2bcf1e(0x127,'dK%p'),'match':[a22_0x2bcf1e(0x26a,'hNT#')]},{'name':a22_0x2bcf1e(0x388,'N3!A'),'match':[a22_0x2bcf1e(0x185,'7UnL')]}]};export const DEFAULT_ROLES_LITE={'http-client':[a22_0x2bcf1e(0x2b5,'J3g&'),a22_0x2bcf1e(0x2be,'GM2d'),a22_0x2bcf1e(0x2a5,'#pqQ')],'llm-client':[a22_0x2bcf1e(0x275,'NHWr'),a22_0x2bcf1e(0x25e,'yg@#')]};export function seedLayerConstraintsLite(_0x54b19d=DEFAULT_LAYERS_LITE[a22_0x2bcf1e(0x361,'G0OZ')]){const _0x4d3680=a22_0x2bcf1e,_0x194e50=[];return _0x54b19d[_0x4d3680(0x33f,'@ZIb')]((_0x133148,_0x51512b)=>{const _0x58c86b=_0x4d3680;_0x54b19d[_0x58c86b(0x15a,'hNT#')]((_0x413401,_0x40f352)=>{const _0xcf383a=_0x58c86b;if(_0x40f352===_0x51512b||_0x40f352===_0x51512b+(-0x15ef+-0xd09+0x22f9*0x1))return;_0x194e50[_0xcf383a(0x1cc,'N3!A')]({'id':_0xcf383a(0x194,']y1E')+_0x133148+_0xcf383a(0x235,'G0OZ')+_0x413401,'target':{'layer':_0x133148},'rule':{'type':_0xcf383a(0x14f,'iXIT'),'to':{'layer':_0x413401}},'severity':_0xcf383a(0x119,'3P*n'),'enforce':_0xcf383a(0x1c2,'OQ[*'),'message':_0x40f352<_0x51512b?_0x133148+_0xcf383a(0x377,'DALD')+_0x413401+_0xcf383a(0x1a6,']y1E'):_0x133148+_0xcf383a(0x120,'BcSP')+_0x54b19d[_0x51512b+(0xfb*-0xa+-0x1*-0x1e95+0x2*-0xa63)]+_0xcf383a(0x247,'ZLn2')+_0x413401+_0xcf383a(0x198,'N3!A'),'why':_0xcf383a(0x29e,'hNT#'),'origin':_0xcf383a(0x1fd,'yA4B')});});}),_0x194e50;}export function loadBaselineLite(_0x29abcd,_0x4132b3={}){const _0x44ed46=a22_0x2bcf1e,_0x1461df=readJson(a22_0x571380[_0x44ed46(0x36c,'dK%p')](_0x29abcd,_0x44ed46(0x337,'BcSP')));if(_0x1461df&&typeof _0x1461df===_0x44ed46(0x154,'lpfv'))return{'canonical':_0x1461df[_0x44ed46(0x2ca,'szdD')]??[],'layers':_0x1461df[_0x44ed46(0x351,'ZmG#')],'roles':{...DEFAULT_ROLES_LITE,..._0x1461df[_0x44ed46(0x21c,'hNT#')]??{}},'constraints':withProposedConstraints(Array[_0x44ed46(0x30e,'#pqQ')](_0x1461df[_0x44ed46(0x161,'lDY)')])?applyRecordTrust(_0x1461df[_0x44ed46(0x16c,'4UZ%')],_0x29abcd,_0x4132b3,_0x1461df)[_0x44ed46(0x2cf,'J3g&')]:seedLayerConstraintsLite(),_0x29abcd,_0x1461df[_0x44ed46(0x1c6,'Lf1I')]),'entrypoints':effectiveEntrypoints(_0x1461df),'publicApi':Array[_0x44ed46(0x250,'N3!A')](_0x1461df[_0x44ed46(0x37a,'!ewi')])?_0x1461df[_0x44ed46(0x315,'GvAu')]:DEFAULT_PUBLIC_API,'source':_0x44ed46(0x1d9,'3P*n')};return{'canonical':[],'roles':{...DEFAULT_ROLES_LITE},'constraints':withProposedConstraints(seedLayerConstraintsLite(),_0x29abcd),'entrypoints':DEFAULT_ENTRYPOINTS,'publicApi':DEFAULT_PUBLIC_API,'source':_0x44ed46(0x383,'a#s$')};}export function withProposedConstraints(_0x3aad80,_0x57b3d4,_0x36cccf){const _0x357b5f=a22_0x2bcf1e,_0x558256=readJson(a22_0x571380[_0x357b5f(0x36c,'dK%p')](_0x57b3d4,_0x357b5f(0x191,'N3!A'),_0x357b5f(0x19d,'J3g&'))),_0x502e6b=Array[_0x357b5f(0x145,'TwdR')](_0x558256?.[_0x357b5f(0x19f,'nH7B')])?_0x558256[_0x357b5f(0x27b,'3P*n')]:[];if(!_0x502e6b[_0x357b5f(0x130,'a6gK')])return _0x3aad80;const _0x5d8f2d=new Set((Array[_0x357b5f(0x256,'Ncoa')](_0x36cccf)?_0x36cccf:[])[_0x357b5f(0x14c,'lpfv')](_0x134e5c=>_0x134e5c&&typeof _0x134e5c===_0x357b5f(0x286,'lDY)')?String(_0x134e5c[_0x357b5f(0x1ad,'$t%2')]??''):'')),_0x4e1553=new Set(_0x3aad80[_0x357b5f(0x2e6,'a#s$')](_0x3c55ce=>_0x3c55ce?.['id'])),_0x20b8c8=[];for(const _0x41e393 of _0x502e6b){if(!_0x41e393||typeof _0x41e393!==_0x357b5f(0x30a,'yA4B'))continue;const _0xf0ea3=_0x41e393;if(typeof _0xf0ea3['id']!==_0x357b5f(0x2ec,'szdD')||!_0xf0ea3[_0x357b5f(0x2ef,'yg@#')]||typeof _0xf0ea3[_0x357b5f(0x259,'N3!A')][_0x357b5f(0x24e,'9ng9')]!==_0x357b5f(0x1ef,'9ng9'))continue;if(_0x4e1553[_0x357b5f(0x125,'TwdR')](_0xf0ea3['id'])||_0x5d8f2d[_0x357b5f(0x18f,'ZLn2')](_0xf0ea3['id'])||_0x5d8f2d[_0x357b5f(0x30c,'@ZIb')](_0x357b5f(0x384,'GM2d')+_0xf0ea3['id']))continue;_0x4e1553[_0x357b5f(0x158,'GvAu')](_0xf0ea3['id']),_0x20b8c8[_0x357b5f(0x1ab,'ZmG#')]({..._0xf0ea3,'origin':_0x357b5f(0x1fd,'yA4B')});}return _0x20b8c8[_0x357b5f(0x22a,'xf^&')]?[..._0x3aad80,..._0x20b8c8]:_0x3aad80;}export function layerOfLite(_0x3f6cc3,_0x30059e){const _0x2c1da2=a22_0x2bcf1e,_0x505f7b=_0x30059e[_0x2c1da2(0x287,'Lf1I')]?.[_0x2c1da2(0x28e,'mw!k')]??DEFAULT_LAYERS_LITE[_0x2c1da2(0x19c,'J3g&')];return _0x505f7b[_0x2c1da2(0x365,'Ncoa')](_0x43d1c0=>matchGlob(_0x3f6cc3,_0x43d1c0[_0x2c1da2(0x1d3,'xf^&')]))?.[_0x2c1da2(0x26e,'#pqQ')];}export function readTracker(){const _0x25a570=a22_0x2bcf1e,_0x5c8b4b=readJson(a22_0x571380[_0x25a570(0x137,'lDY)')](knowledgeDir(),_0x25a570(0x32d,'szdD')));return{'files':Array[_0x25a570(0x215,'OQ[*')](_0x5c8b4b?.[_0x25a570(0x12c,'DALD')])?_0x5c8b4b[_0x25a570(0x260,'Ncoa')][_0x25a570(0x2d7,'yA4B')](_0x2eec11=>typeof _0x2eec11===_0x25a570(0x2c9,'7UnL')):[],'ts':_0x5c8b4b?.['ts']&&typeof _0x5c8b4b['ts']===_0x25a570(0x288,'#K9[')?_0x5c8b4b['ts']:{},'heads':_0x5c8b4b?.[_0x25a570(0x2a2,'ZmG#')]&&typeof _0x5c8b4b[_0x25a570(0x292,'or#Y')]===_0x25a570(0x2c4,'IM[B')?_0x5c8b4b[_0x25a570(0x262,'yA4B')]:{}};}export function interventionExempt(){return process.env.ROUTINECODE_ARCHITECT==='1'||process.env.ROUTINECODE_MAINTENANCE==='1'||process.env.ROUTINECODE_RECORDER==='1';}export function wiringStatePath(_0x298a89){const _0x1c31c8=a22_0x2bcf1e;return a22_0x571380[_0x1c31c8(0x2ed,'hNT#')](configMapDir(),_0x1c31c8(0x2e2,'Sx%)'),safeSeg(_0x298a89)+_0x1c31c8(0x204,'!ewi'));}export function taskSummaryPath(_0xec902c){const _0x4851fc=a22_0x2bcf1e;return a22_0x571380[_0x4851fc(0x142,'$t%2')](configMapDir(),_0x4851fc(0x148,'a#s$'),safeSeg(_0xec902c)+_0x4851fc(0x291,'Ncoa'));}export const REPO_META_KEYS=[a22_0x2bcf1e(0x1e9,'#pqQ'),a22_0x2bcf1e(0x15e,'aCdu'),a22_0x2bcf1e(0x349,'#0I0'),a22_0x2bcf1e(0x238,'yg@#')];export function readRepoMeta(_0x331c45){const _0x9cb71d=a22_0x2bcf1e;return readJson(a22_0x571380[_0x9cb71d(0x326,'3P*n')](_0x331c45,_0x9cb71d(0x374,'GM2d')))??{};}export function updateRepoMeta(_0x531927,_0x41b17e){const _0x3b3cc8=a22_0x2bcf1e,_0x5d8068=readJson(a22_0x571380[_0x3b3cc8(0x364,'a#s$')](_0x531927,_0x3b3cc8(0x1fa,'szdD')))??{},_0x21b14e={..._0x5d8068,..._0x41b17e};a22_0x4b2235[_0x3b3cc8(0x2eb,'yA4B')](_0x531927,{'recursive':!![]});const _0x1682da=a22_0x571380[_0x3b3cc8(0x153,'szdD')](_0x531927,_0x3b3cc8(0x279,'IM[B')),_0x109751=_0x1682da+'.'+process[_0x3b3cc8(0x352,'OG8c')]+_0x3b3cc8(0x140,'szdD');return a22_0x4b2235[_0x3b3cc8(0x1d2,']y1E')](_0x109751,JSON[_0x3b3cc8(0x396,'TwdR')](_0x21b14e,null,0x20ee+0x1*0x956+0x2*-0x1521)),a22_0x4b2235[_0x3b3cc8(0x313,'BcSP')](_0x109751,_0x1682da),_0x21b14e;}export function pendingPath(_0x5388b1){const _0x313fd4=a22_0x2bcf1e;return a22_0x571380[_0x313fd4(0x144,'BcSP')](configMapDir(),_0x313fd4(0x1d0,'xf^&'),safeSeg(_0x5388b1)+_0x313fd4(0x2e3,'NHWr'));}export function safeSeg(_0x5379e3){const _0x24609c=a22_0x2bcf1e;return String(_0x5379e3||_0x24609c(0x379,'3P*n'))[_0x24609c(0x1f6,'or#Y')](/[^A-Za-z0-9_.-]/g,'_')[_0x24609c(0x2f1,'IM[B')](0x20ac+-0x1*-0xc73+-0x2d1f,-0x168b+0x1195+-0x2*-0x2b7)||_0x24609c(0x150,'9ng9');}export function rcConfigPath(){const _0x2c33db=a22_0x2bcf1e;return process.env.ROUTINECODE_CONFIG_PATH||a22_0x571380[_0x2c33db(0x1b6,'Sx%)')](process.env.ROUTINECODE_DIR||a22_0x571380[_0x2c33db(0x306,'ZLn2')](homeDir(),_0x2c33db(0x141,'OQ[*')),_0x2c33db(0x1f4,'a6gK'));}export function readSyncConfig(_0x5e16b7=rcConfigPath()){const _0x76a3d=a22_0x2bcf1e,_0x421759=readJson(_0x5e16b7);if(!_0x421759||!_0x421759[_0x76a3d(0x177,'J3g&')]||!_0x421759[_0x76a3d(0x13b,'yg@#')]||!_0x421759[_0x76a3d(0x255,'U[nV')])return null;return{'serverUrl':String(_0x421759[_0x76a3d(0x117,'aPFR')])[_0x76a3d(0x34c,'dK%p')](/\/+$/,''),'apiKey':String(_0x421759[_0x76a3d(0x205,'a6gK')]),'userId':_0x421759[_0x76a3d(0x278,'hNT#')]??null,'tenantId':_0x421759[_0x76a3d(0x186,'J3g&')]??null};}const PENDING_LOCK_STALE_MS=-0xfb0*0x1+-0x1*0x21b5+-0x44ed*-0x1;function acquirePendingLock(_0xfef2b6){const _0x20e727=a22_0x2bcf1e,_0x33e745=_0xfef2b6+_0x20e727(0x251,'lDY)');for(let _0x43c0dc=0x1964+0x1d63+-0x1*0x36c7;_0x43c0dc<-0x2*-0x6df+0x4e7*0x1+0x1273*-0x1;_0x43c0dc++){try{return a22_0x4b2235[_0x20e727(0x290,'or#Y')](a22_0x4b2235[_0x20e727(0x348,'#0I0')](_0x33e745,'wx')),_0x33e745;}catch{try{if(Date[_0x20e727(0x222,'#pqQ')]()-a22_0x4b2235[_0x20e727(0x1b7,'#K9[')](_0x33e745)[_0x20e727(0x1b8,'dK%p')]>PENDING_LOCK_STALE_MS){a22_0x4b2235[_0x20e727(0x26b,'9ng9')](_0x33e745);continue;}}catch{}const _0x39c7ab=Date[_0x20e727(0x20a,'dK%p')]()+(-0x3df+0x2493+-0x20a0);while(Date[_0x20e727(0x1aa,'aPFR')]()<_0x39c7ab){}}}return null;}export function appendPendingSync(_0xc241ea,_0x52cd09,_0x4d7dab=a22_0x571380[a22_0x2bcf1e(0x175,'aCdu')](knowledgeDir(),a22_0x2bcf1e(0x14d,'N3!A'))){const _0x2ee810=a22_0x2bcf1e;try{a22_0x4b2235[_0x2ee810(0x36f,'9ng9')](a22_0x571380[_0x2ee810(0x197,'yg@#')](_0x4d7dab),{'recursive':!![]});}catch{return![];}const _0x48841b=acquirePendingLock(_0x4d7dab);if(!_0x48841b)return![];try{return a22_0x4b2235[_0x2ee810(0x2df,'!ewi')](_0x4d7dab,JSON[_0x2ee810(0x357,'mw!k')]({'endpoint':_0xc241ea,'data':_0x52cd09,'ts':new Date()[_0x2ee810(0x1de,'IM[B')](),'retries':0x0})+'\x0a'),!![];}catch{return![];}finally{try{a22_0x4b2235[_0x2ee810(0x178,'IM[B')](_0x48841b);}catch{}}}const RECORD_PUBKEYS_EMBED=a22_0x2bcf1e(0x122,'xf^&');function a22_0x73c9(){const _0x5d9c87=['lmoHsCk5','imoQWPVdRG','WO/dULhcLW','DCkWW4hcU8kAWOJcQSolzNSBWR0','AvCyW5q','WRRcUCk8W7yaW5W','AbvnW7pdPcW','hwFcLCkxxCkJ','WPPQC1FdTvm','WPRdLmkJpa','tmkbEW','W6bZgSkVWOldLW','W5Pcz8omW450W5m','vWddGanrWP0','W5XttmoBW59H','n0NdUqbQrmoIgmkMWQ3cRvZcS8kk','bhj1dCo9qa','D8kDkSo2m0ZcMCo6W5FcVq','nr92v3hdPZns','E1hdTCkrB8kYg8oWW44','xs0PuSk+','BHFcPa1LvW','WQ/cVg9/W6dcLW','WOFdSLdcHLdcMa','WQD9pdq','nr9LsKZdUtrxuq','mCkVW7NcJmkfc1RcK8kFW7a','WPuymdVcJSo3','WQRcLI4qWQe','uc/dUJtcTmkqW7Sue8o4FJBcG0ZdSG','qa/cQftdMSo3W5dcQG','guBdQfFdMSoaW5hcOYZcK8oYWO3cRG','W4vuvmoxW5PS','uCoeWRXKWPa','uSoVWQiVWQFdPG','hCo/WOtcPSkdfSkCbJa6WOO5chO','Cq5wW7q','W5pdNIJcNeddTCopgGNcUhZcQa0of3eS','W4xdNIpcGa','W4bssCooW5K4','q8o5pCkW','x8ozWO3cUSk3W4SNWPJcHJCT','BGtdTCoIWRq','WQRcRCkXW6nzW43cKW/cI8k1fZ7cLCkZWRtdRSko','W40UwSk7','W4zpW7mqmCoZW6BcUXW','cCkeW47dU8o3WOH5WOxcGISqWROv','WQqBiSojW5a3','WRzGkIm','t8okWO85jCoI','W5zuW68noSo6W7VcLqtcKve','rCkqyq','WPZdImk0oG','z8kzn8oYmKdcPmoMWPFcTmk1W5Wy','W7FcGsSn','ut/dN8kFtSkHWQXtWQBdV1zzWO3cOSoXW4e','fSktqwm/WOe','W5Pxl8kjWRpdQSkEyfNdQCoEemkrzmofd8kd','W4/dQvpcH0hcG8oqWQz8fCouia','lSoXw8k1mSkqW5JdJ8kcBSoMcq','W5i1sCk2WO/cVW','qSkpEGqyW4xcKa','imkYW7dcImkc','WO8FbdVcJSo5DCkI','eSoWW5lcR8oTiG','W4ddSvS','t8okWPWKgmo8mCoL','FWlcPqfLuCoUhW','W4aIt8k2WO7cTG','FxJcIIhcUSohWRC','u8ooWPG+gmo8mCoL','wmoBWOKXiSoPemo2qSojWRm','gb0wi8kZW7u','WOlcUGCec0WvBYmsqG','imk4W6ZcGCkqdxC','W7pdJg1tW7TiW4xcV2Dpka','WPXMFvFdRMJdNW','WQVcOmkQW7KvW5tcHa','l8osA8oKo0ZcRSoWWPBdTmoS','xqJdLrjgWPW','W5JdUuW','vv7dOsGkW54zbmk1imon','huBdQfbP','WR4klCoEW7ON','muSqWRdcPc8tfh8','CIVdMdvcWR1hsCkd','wmk0WPNcPmolhxFcUSkt','yJddHcHjWRrAz8kBWPZcVW','WQZcKIruW60','xZC2xW','WRGgi8oEW6f9WQJdHSkNWRO','cmo3W6hcTmoXjf8','WRD2pcu','v8oeWQGGW4BdUG','jmoIWOtdRSkCWOG','krLZrLa','qCoeu8oS','W7hcMLdcLKLY','W59uW6Gx','WOpdHCkysG','s8kcyIqAW5i','W4iUvCkSWPxcQSoixmoCCGfg','WPxdOKZcLW','lSoXw8k9bmkyW4ddGSkcBSoMcq','dWGdFG','W4RdNJZcGa','omkYW7xcGW','BtRdHdTyWRi','AGVcRW','WRtcJsyqWQDVW5NcONa','W6xdO8o3W7yeW4NdJKtdGSoXctZdMSk+WQlcRCkmWROTW5VdO8koW6RdMSoBimoadSkhmSovWPCNWQTtxLJdHSkboZBdUSkkWOZdJblcVmkNdxNdR1iPW71LAmo7WOLSWR8gWRpcLmo7vgBcGSkyWQncWOaDpcldQIpdK8o1l8oubYzYomosW6/cVGfOsSkDjMhdISkLn8oaW7JdPmkLWRpdGW/dGSoeWQTRrYLRW4iKWQRcPmoCWPtcGsBcSmkBxgWrW4VdSCk7W5NdI8kSaSkgWRFdQbrcCHlcJSopW4KQWOpcK30','eSoYW6XO','nmoMWOFdPmoJW5G','imk4W6ZcGSk4cG','W7dcMKRcKbnWcMLY','W4CZvmkY','W4/dJIJcKvhdOG','zUUiL8ox7igk7j6UWPZRO4/SN5tSLRmu','q8oZiCkRFCoaW7G','BG9uW7tdPtXt','cSkdtwGIWORcStX8','CfSEW4RcVa1Nsa','W7/cKfRcIhv7cM4','nmoMWPBdP8oAW53cS8oive0gWQC','C3pcMG','umkfEZu','BWZcUra','w8oBWOK','g8k8FCk3DmoeW6TIrCo0hmk2WPBcKspcQSks','W4zEW6qD','W77cKfdcGKLOgg9YfSkv','hKtdUcO','t8oeWPZcUG','iSoMWPtdOSozW5xcQmooDbOBWQ3cT07dSbhdQSkYbKeqEa','WRihkSolW7y9WQFdM8k8','amo0W4TFg8o2W6lcGCo5BSoZ','rJxdVc/cO8kh','dSktv3a4','W4DuxSok','oNhcHZa','c8oRW4NcQa','AGddUmoZWRv6W5hcOmkHW6P5','qqNcT0VdTSob','WOb7EfxdSW','WOz8A1VdUea','eMBcVSktAq','D3FcJsZcPW','iCkPW73cMCkIf3ZcKq','AXhdQ8o+WR90W4RcLCkH','x8osWPW5jSo2','W797da','BLZdVSkoCSkIcCo5W4LG','WOFdQvpcNW','fxtcNCkx','WQJcQw9XW6VcHa','uCosWOdcUW','bSo+W7jJj8omW6lcNmoIEq','W71HkCk6WPxdGSkX','hCo/WOtcT8kpcSofrxK','WQfQnZq6WPe','fNtcGa','mmkXbW8Kc1W','vmoVWQvJ','cxtcH8kTu8k/WQ5xWO0','W5LEW68Ek8o8','W6ZdRYGPWRldKmosBxvuq8ocW70','iCkGb0nP','AqrpW7xdGY8','j8kXeXG0fx0JpW','W7tcJh/cG097aa','BqHqW7BdQZ9ud2i','W4zEW7mpnSo3W6O','u8o+WRm0WPVdSq','B10FW53cRtC','W59qx8oBW45M','guBdQfBdKmoqW4hcOYZdJSkMW5pdT8o8WPFcOWS','WQinmW','jEUjRgq','va3cPffIW7hcOvBcV8kAoG3dTmkCEhS','gqtdGSohWOPTW71aWOLUW6mUA8kIg8oaW5hcNmkOWP3cUc05W74PW459jSo/W4zfrsGFW5SxW57dJ8kTACkPrYnhmrLuW6m0WRBdHM7cUILZW5CawCk0W4NcOCksWOm','v8o/pSkWDmoe','qSo/kmkH','CatdQG','W7jGb8kL','oSkYW7pcHG','zfpdUCkyDmkekCoLW5vkta','W7zZg8kTW5hcLW','WPldR13cHKdcMq','Bu3dU8ky','imoQWPVdRSoz','lSoMWO8','rI3dPYxcQa','bmoYW4xcQmo3nGJcVSksWPNdQr8','smovWRqUW5ZdTq','W4bEvmok','W5hdJJBcMW','rIJdTcm','tCodWPS7W5RdVmku','mSk9drO0fq','gfdcJa','w8o5o8kQ','WPpdVKZcNLtcICoB','mCkScb0LfhSOpwq','hmoxvCoQndLOWQS','qaNcTvldMSoxW6dcTdi','kvpcQ8kNWRH0W43cMmktW5e','z3pcMG','bSo0W65P','WOpdHCkAsW','W6hcVCk1W6C','fmofWPBcVCk6W5iMWPtcIYW6WOO','WOVdTfxcNa','WQ0IuCkQWQ/dU8kzs3q','B8kxlCo5','CrBdMmoLWQnYW5O','AqBcRHb4','WRfPmdq+','W4fAW7isCSoNW7RcSaJcG0VdQ2Lk','qXZdGbi','s8kUWO/cO8kXiaNdVSol','DSkmnSo+me7cO8oLW4a','WOSnmG','WQenkCoFW7a9WQxcMmk7WQ3dVCoZW41MW494ie0','rJhdOI/cUq','b8oRW5lcPmoQiqVcSmkeWOBdOH3cKMa8pSks','WQZcIcKxWRPlW44','xdCNxCkOeYW','x0FdUZ8bW7SfcmkPhCoA','WQxcPSkXW7K','WOKokdFcG8oK','cmkttManWOdcNcLgW6TCWQK','WQiCjSojW60GWPxdNmk8WRW','c2dcG8kA','AKddSW','l8oGw8kJamkkW6pdG8kLFW','uCk6W5NcKmkhb8kc','W4bzr8kp','vGJdTrhcISkuWOW','cCoLW5m','WR/cTg5OW6NcGSkDsMjmsq','W6NcJvFcNa','yvKcW5/cTtzSqrJcULhdLJa','uSo5pmk3zCoeW7XUwCkUfa','W5e0smk3','CZZcHZ9jWQHAq8ktWO3dUSkYhSod','B03dSmkyDCkL','WOGnlZC','W58InKhdTvxdKfPYW4bZtG','WP3dImkZoHO','b8o3W6TVmq','iCkKbq8LaG','WRxcGYWEWQfu','gb0wi8oRWQddP8kR','dmomvmoRjq9GWRa3W7XE','WO/dG8kFqa','WOVcKwRcNLVdTmkhebBdTJhdSq','W67cMK3cGLr1f094','wSk6W4/cSmkk','umorWPW0','wGlcO0hdH8klW5/cTthcJG','xutdVdCwW6mf','W7b7gSkMWOBdJSkT','WRhcSNr2','W7ZdU8oSWQzeW7ZcHrJcRCkFpa','W6DRbSkRWQldJCkPr2RdHCo0','W5qVv8k2WO/cS8o6tmoCzq','xSk7W5JcOCkueCkhcJ0RWPHIsZ99u1OsySoYWPtdV8kU','W43dMJZcLKBdOW','WPBdJ8kzxSoOA8oEeq','WQJcTgD9','gexcK8oJ','umoyWPdcPG','Aa5nW64','muSqW7FdQYjttNFcSN5AWQhdLmo/','WR3cRmk5W7mYW5dcJqVcU8kNhc8','WPpcJ3FdHalcPSkTnGdcVfBcNq','rYm2Emk6hGJcQmkYWO3dJIuSAG','BdtdJJvEWOLxqCkz','c8kXW6WOWQddTGxdGwODsSkrW7G5bu1ZWQZdQNO','W6b3bSkPWONdL8kbqq','W4uOsCkXWOdcTCom','exRcMCkC','A8kzkCoY','WRRcIImqWRHp','c8oxvq','guBdQa7cKCoxW5RcSYRcHCkUWONdV8kKWO7dVbWiW7q','FGZdTCoJWRrH','g8oru8o1','A1Kc','xSoEWOVcPSkVW5yT','WRaAjmotW7aNWQFdLSk8','WOJdTv/cNKdcJSoBWRa','tJe8wSkGfsZcQmk0WP7dOdiHr8kogHG','b8o+W6DOEq','dmoLW5a','hwFcN8kF','vWxcTuRdNSoiW5a','W7hSLRHN7kkQ6RwL7zsp64IM','W6D9gSk8','DSkmjCoLkLRcNCoQW43cTG','nCoVWP7dQmop','W7b3dSk7','W7D9bSk7WPpdKCkPtgJdLmoJEmkOwmoJk8k1lSo6W47dNc7cJ8ktW6m','W4DEW7ewlmo9W7VcSHFcMW','ghRcNSkbu8k0WR9BWRZdOKO','F3/cGca','WOWdkZW','dNVcM8kCsmkXWRa','duFcL8oN','W5mKxCkS','p8k8W6JcJSkz','voYvI8kI7j2u7kcG7zE97kwwW5pSL5RRIPtRIBa','WRbQlcm+','aqxcPwiqW5qmg8kvoa','hmoxw8oSja4','oSk7fG','qrZdNX8','FG/cTW1MqW','WORdVKu','WQlcOmk8W7myW5ZcLG/cMSk7xdFdJ8kQW6VdQ8ktWQy','jmk9bq','Ch/cNcRcO8oLWRq','ma07W6lcKZTtuq','nSo2WPxdGmopW4u','BWrhW67dUq','EWtdUSo/WRq','BqbtW7pdRHLya38','rs0Swq','WPZdK8kNoIX2WRTt','p8kPW7xcGmkui2e','zZBdHIHjWQG','W5eGsCkSWOq','BaddOCoJ','iSkOW6/cHq','W5pdLcNcLKC','CIVdMdvcWR0','q8kfFa','cSoQW4/cSCoVielcS8ke','CqlcRWf5','wCoyWPtcUmkIW548WPq','WQVcGZqCWQDpW4u','mXhcUrf/wCoTh8kKWRhcRby','yuVdVSkt','oCoSwCk0bmknW53dHCk/za','AqrpW7BdQYHy','Cmkwl8o5mv7cPa','wCoqWPS/oCoMoG','BSkwk8oGmKZcRSoKW5W','fCo2W4NcQW','WQeDnmot','cLxdOLu','Da3cSGfZF8oL','WOudlchcLmoIymkUtCowzq','g1dcLSoUWQbSW60','dLxdPeXJW6hcVv7dTa','a8oPW6T4mCoJW7/cN8o1u8oTjCkr','bLtcJmoPWQe','BfOBW5/cUIS','wSoxWPe1','WRbGntyVWOZcK8oa','DqlcPq','u1/dUY4bW4eAaCk+jG','FqHtW78','W5dcRq7dGLZcJCoqWQHulW','WOz8Ef/dPG','bSo0W614','xGVdHHjxWPS','W5uUCSkmWQ7cI8oDr8oBAc8','WQZcPSk1W7OBW5FcHqFcMG','WQfQnYqVWPFcHmomdmk3WPq','duldVv1+W7ZcSfC','rINdR3C','hmkeqgK','W6D6cCo6W5lcLq','Ea5rW67dRYvjkg3cTwu','oCoIx8k/amkkW6tdI8kLFW','qSoPWQy6WQBdSgldG3yy','WPddMmkqa8k1','W4fuvSorW7vX','kW5KuepdUtG','WQNcSNjS','pSk7caa','WO0joYe','WRijjmotW7W','WQRcKJaqWRTB','cCkcWRpcKmkeW58zWOq','W5qYxSkTWQJcVa','uCkNW4tcUa','W4zsW6y','r8oFWRqVW4hdUSodrSoEW74I','W5hdMJFcGfe','BWBcPGHQu8oM','eSkRW7e6W6hcPrRcLZvgcSonWQq+xqW3WRpdSgpcUKJdVCoY','va3cPgDtW6hcOv3dPCkseshdT8oCiq','E0xdPCkoyW','WQlcRmkSW7zAW5pcKGhcHG','z1ewW5/cQIS','W4nEW7mqoCoT','WOv6DKldUvtdNe4','uYJdOJlcQmks','W5iXv8k2WPu','WPxdMCkfrG','reldVdC','FHhcSWv/vColg8k0WRy','EW/cTWn4','vmkCxgSL','rCoaWRmcW43dPa','rJxdOttcQmkKW70p','W67cK1FcKLG','q8kWW5pcOq','WPldVKG','pmkYW6S','E3tcHchcOCo8','va3cPbiIW6FcQ1VdPCkeyaxcRmkfj2WUFW','WQmnnmouW7uLWQC','dW8anmomWQu','FaZdQ8o5WRb+W4y','AGddV8oK','WRJcVhf0','nSo7u8k/','sCorWQO','axdcVxxdTmozW44NfCoJAdW','u8oeWRJcUSk8W5OX','W7FcKfFcNW','tCoyWOVcO8k6W4KTWPtcMW','h3dcLSkb','W5TuxG','dSotsSoQpGTKWR0','W6DXb8k4WOldSCkTsq','rCk6W4FcSmkv','W7TcAmkrWRCHWQFdHCkNWQFdUSoKWOX+W4u5nvuQkCocW5Xi','WRCbk8oE','FrnqW7C','tmomWPiGjmo2pSoQF8oK','z2lcJZBcTSo7WOzkW4xcGa','W51Euq','BHvzWRFcSG','W5mKvCk+WOZcVCo6tmoCzq','e8o+W7y','W7TcAmolW7G0WQFdHSoNW77cUq','WOFdGSk+','fX0v','yJBdMxjgWQLbqCkw','b1dcLSoTWR1Q','v8kpEJu','WR44r8k7WPxdGmoNrhBdICk/FmoY','WQTRhZ43WOa','WRxcHZSCWQC','W6/cKflcLg5ZhG','AbdcSXzcva','yLFdLSkpDmkWiW','AqrtW7VdVIjlbq','WRpcUgu','W5ldKJ/cLG','AWv4vW8','WQielSoyW7W','umkbEIyCW5lcIW','qatcPLBdMSob','jSk4W6/cMq','qSo6o8kNDa','jqD2sK/dRq','u8o+WRm3WRpdTK8','Ct7dMc9j','WPqjmt3cJmoMza','uSo6m8kTFmof','W5VdPfPhs1G','W5zjq8oD','WRbGktGsWOe','u1/dUZWAW4LBamk6ja','uItdUG','rIWHuSk1xJlcQCkYWPm','gq4aj8oXWQtdMSk7k8oVomk2W77cSsq','i+ULHfhQS4RSSiL/','DWFdS8oYWRjN','z10sW5pcVtPMzui','WPBdMmkzxmoOFCosdW','vmk5W4RcVmklfW','WQBcUSkzW7uhW5BcJrVcNmk7','WOz8A1VdUeddKeX/','WQ3cNZiC','tCo6WRaVWPVdU07dH30/xa','WRGBbSojW6SYWRS','h8o6pCkNEG','WR8Dk8ox','WQvGlq','W4hdO2LmvLajFZrz','DwBcHW/cP8oX','WOZdN8k3xmo/wmoc','DGbp','W6JcJ1RcKeL/','WQmDk8oE','na52r2tdTZfuE8oWpCk9','xYm3rmkO','cCkFsa','aSkKzSo1iCoZW7LXCSkBkq','xqNcSatdSmovW5dcQb/cQq','bGddOcG8W4KDiW','WOpdHCkAs8o+','eMBcTmkBvCkJWR1gWR3dPea','WP1TEfBdPq','wL/dVdq','v8oFWQG9','s8ocWRmUW4hdSW','EfddPCkuAmk2','vCo/imkQCmoBW7G','WOOnoZFcKSoJ','W5uKsmkR','hCo/WOtcPSkub8ofbZWWWPjLdxO5','WQZcIc4qWRTxW7pcTx0c','DSk+fCo7wCklW5VdN8kLCSkMesahs8ktW4RdLa','W67dLhDiW6ipWPBcPwuuBx8t','W51qs8oB','cH0xnCoG','DanvW7/dQt8','jmk8W7dcHmkv','BtddIZG','rCkUWRi0n8oFW6ZcHCoEBa','chdcG8kbtSkPWRa','fbKszSoeWQ/dVSkMo8oSiCk8W5y','qLxdTdydW48cbCkilCoqjq','fSkuW5j6zCoMmmoOqSoYWRldOCklxYa8W5BcLI44iSkDWPC','qSkMW47cP8kVaa','W4WKt8k+W4/cSSoAwSoC','nCo3WOxdOSoeW5VcRSogFG','Ea5rW6NdVJLCcwlcSN4','cxdcGmkDBSkI','W6/cML/cLxTZfwnpg8obW64','qSoZjG','wcddVG','BZ7dHZK','rfxdRs4','WPBdG8kBsW','j8kZW7FcG8kEgxW','W7pdJg0kWRzoW4NcVgCslq9Z','WPueiYlcHCoyymk0sW','xSo0omkHCSoc','mmo1q8k0bSkk','WOddHCkSkXX7','WOZdI8kNjXj8','gHRcUNbDW4mzcCk+omkqpx/dHdDmW7Cc','p8k8W7xcG8kfc3ZcK8kcW7VcNG','v1xdOq','W6GVDN11WOBcISolbmkQWOaZDa','ztRdJc8','W4nermo1W5LS','FG/cUrDUy8o6fmkK','W4VdHSkfqCoJ','DqBcTWb4','WOVcKwRdMrRdO8khdHpcShJcVG0Feg1UoYxdRW','umkfCdu','W53dO01C','t8odWP/dPCo2','iCkGb1y','rmkHW5NcVmkia8kdcsO','CsRdMtq','BWBcTWbnwCoVh8kuWQFcPHa','xSkXWQ0MESoxW7NcHSoKzCoMzCkjymkokrJdUmoI','wmo4nSkHACo5W7S','W5XiW4allCo1W7y','DmkzW6RcGmkIiCoeaJD/66oX7j2I7jAwCoQ3J+YuGafoy8kXWOVdUmk2nEkgNcpdNSkWW6tdRCozW4ZcIJRcM8kyfUkgImkXWQrsW4pcR8kCWPlcRSoW4OEXbsBdSfhcHCk8pmkaW45YlMe','AWddQq','bCoHW4pcR8oNielcLCkv','WRpcIsSx','wqZdJrnh','FWHnW7tdQYzy','WOTRfmk2WO/cVSoBvmkDlgi','W5HicmoDW45WW4TMW6K','vgaSu8oVsG','W7VcJvhcNa','h2VcOsFcVCkqWROgcCo/irhcN1u','WONdJSkQoHP9','W4ldV0fa','W4ddLYK','m8oMu8k2hCkx','W4DEW60yk8o9W7NcUa','qbJcTu3dKCoc','AajqW6RdR2y','AWNdSmo0WRq','qGRdGWDrWR3dPCoY','c8ogwCoXnrHLWPGT','oqDwW7BdR2Kh','rItdUG','W7vQaCkNWPtcJCkRv2pdGCoKmW','BSkGcmoMqSopW7VdOmk0CSofla','xmkqdCkRAe4WWQ0ZW6bJAGe','AZddGZi','vmo1WQG1WR3dOKq','iq7cUmkjy8kIlSoZWOGPaG','AmkLcCoItCoaW67dSmk5EmoTlq','eSoHW5q','zJRdNG','W7pcMKNdKxXIegLV','W4FdKINcH1hdOG','Cs3dHsXdWQLlsW','u8omWPq3iSoR','hCo1W6zPlmoQW7a','feJdOLy','W44JuCk6WOlcRa','j8k9bG','dmomvmoRjq9GWRa3W7W','emkDW5BcUSkRW4SNWOlcGtCXWP0QiZS6WRZdIa','v8kuEIGxW4e','uSoVWReYWRZdSG','WQZcQmk2W7GAW5dcGG/cHa','zmkulCoHoW','fmoqWPdcVa','t8o2W4/cS8o3leJcSCkcWPNdOXy','d8knW4TGE8kXmSoTv8opWQ7dTa','W7D9bSk7WPpdKCkPtgJdLmoJ','rCoaWQOSW4BdUCkRrCobW7qFWOqXhq','r8kpzICqW4hdLCo3W5RdUHiZchNcIG','BHjAW6JdGY8','WPqzlJC','AeVdUCkoCSkJo8oPW4L3','W6xdO8o3W6mrW4RcLuhdGSo0','iSoQWPddRSozW4G','WPnHDuBdS1u','u8oeWR3cOCk8W54RWOxcHZeN','W4BdNJe','ut/dN8krsmkOWQPaWR3dULvsWOZdVSo0W4hcGW','sYC3','WPKBcCkuWPjXW559WQldPqWmW4XLbYq','k1pcOXzev8oOna','W6DMb8k6WOldP8kHvW','g8kgx2eLWO3cTIv5W7DHWRmPW7G','WOddLmkFxCo5sSoObamI','W7lcNvtcLf5U','wcS3xSkJf3xcQCkPWPZdNZi','vbywkCoR','W5iKtW','fKBdUfa','W5HAW7e','q8oZm8kOyCoxW6LVzmkJcCkH','rGlcReRdKmosW5S','BHhcTuTIxSoWdSk1WQVcPrBdT8ouW4y1fmoXW7K0W6DnmcRdNuxcJq','WOz4DvVdOG','WPHJFvVdPhtdGerL','WRZcVCkQW74AW54','xCk6W4lcUW','l8oWWRhdOSogW5K','qrNcQ0e','WRShlSov','W5iTuSk8WOq','CWZdVq','va3cPfTJW7JcTehdV8keiaRcQ8ozFM9Ykcy','nCo3WOxdOSoeW5S','WQiAjmkuW7q6WQBdKCkKWRhdPmoXWPfPWPjSoLj1B8oBW5i','wJyJgSo1','WRfXocuVWPBcSSomfSkR','ghRcNSkgvCkPWRjEWRFdPa','jmoIWOtdRSoeW53cQSof','u8oUWQ8+','W6DMgSkHWONdHa','nmoSWPJdVW','rmkWW5JcPSkpc8keha','WQ7cUCkOW6uBW4/cHaO','WPBdQvxcHLdcRmoxWQ96kCojk8k3','Cv0bW5xcKdS','WQrPodaOWRxcHmorcG'];a22_0x73c9=function(){return _0x5d9c87;};return a22_0x73c9();}let recordPubKeysOverride=null;export function setRecordPubKeyForTests(_0x44ad55){recordPubKeysOverride=_0x44ad55;}function validB64Key(_0x30bd63){const _0x993611=a22_0x2bcf1e;return _0x30bd63[_0x993611(0x113,'a#s$')]>=-0x2*-0xbb3+-0x7*0x6a+-0xba*0x1c&&/^[A-Za-z0-9+/]+={0,2}$/[_0x993611(0x269,'IM[B')](_0x30bd63);}const KID_RE=/^[A-Za-z0-9_.-]{1,32}$/,ringCache=new Map();export function parseKeyring(_0x1f43a1){const _0x155d0e=a22_0x2bcf1e,_0x4fbfa0=ringCache[_0x155d0e(0x253,'#r&w')](_0x1f43a1);if(_0x4fbfa0)return _0x4fbfa0;const _0x2cf5c8=new Map();let _0x5bee62=!![];for(const _0x332e61 of String(_0x1f43a1||'')[_0x155d0e(0x31e,'9ng9')](',')[_0x155d0e(0x228,'NHWr')](_0x5c9e5c=>_0x5c9e5c[_0x155d0e(0x1cb,'iXIT')]())[_0x155d0e(0x1fe,'Po&X')](Boolean)){const _0x3cdd09=_0x332e61[_0x155d0e(0x34e,'yA4B')](':'),_0x13f60b=_0x3cdd09>0x16a*-0x4+-0x6*0x29+0x69e?_0x332e61[_0x155d0e(0x12e,'Po&X')](-0x18*0x12e+-0x2043+-0x3*-0x1431,_0x3cdd09):'',_0x57213a=_0x3cdd09>0xf18+0x631*0x5+-0x2e0d?_0x332e61[_0x155d0e(0x147,'#r&w')](_0x3cdd09+(0x1277*-0x2+0x477+0x2078)):'';if(!KID_RE[_0x155d0e(0x37f,'@ZIb')](_0x13f60b)||!validB64Key(_0x57213a)||_0x2cf5c8[_0x155d0e(0x15d,'iXIT')](_0x13f60b)){_0x5bee62=![];break;}_0x2cf5c8[_0x155d0e(0x136,'xf^&')](_0x13f60b,_0x57213a);}const _0x1c6740=_0x5bee62?_0x2cf5c8:new Map();return ringCache[_0x155d0e(0x13d,'U[nV')](_0x1f43a1,_0x1c6740),_0x1c6740;}export function recordPubKeys(){const _0x979da5=a22_0x2bcf1e,_0xe09645=recordPubKeysOverride??RECORD_PUBKEYS_EMBED;return parseKeyring(_0xe09645)[_0x979da5(0x124,'lDY)')]?_0xe09645:'';}export function canonicalClaims(_0x533083){const _0x496588=a22_0x2bcf1e;if(!_0x533083||typeof _0x533083!==_0x496588(0x20b,'U[nV')||Array[_0x496588(0x10c,'J3g&')](_0x533083))return null;const _0x3b6cc3=_0x533083;for(const _0x4537f2 of Object[_0x496588(0x36b,'l1sk')](_0x3b6cc3)){const _0x18c66b=_0x3b6cc3[_0x4537f2];if(_0x18c66b===null||typeof _0x18c66b===_0x496588(0x2fb,'J3g&')||typeof _0x18c66b===_0x496588(0x376,'l1sk')&&Number[_0x496588(0x341,'lpfv')](_0x18c66b))continue;return null;}return JSON[_0x496588(0x24d,'yA4B')](_0x3b6cc3,Object[_0x496588(0x1ed,'lpfv')](_0x3b6cc3)[_0x496588(0x336,'#K9[')]());}function a22_0x2e6b(_0x142d3c,_0x4525ce){_0x142d3c=_0x142d3c-(0x1435+-0x1866+0x536);const _0x1179ad=a22_0x73c9();let _0x6f0879=_0x1179ad[_0x142d3c];if(a22_0x2e6b['hPloMm']===undefined){var _0x5b7e3a=function(_0x345c05){const _0x58d628='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1fbf30='',_0x5b8722='';for(let _0x958b73=0x1*0xd0+0x121f+-0x12ef,_0x4eadd6,_0x538e15,_0x1bf77d=-0x62b+0x211c+-0x1af1;_0x538e15=_0x345c05['charAt'](_0x1bf77d++);~_0x538e15&&(_0x4eadd6=_0x958b73%(-0x1090+-0xa*0x11+-0x1*-0x113e)?_0x4eadd6*(-0xd*0x1e1+0xeba+0x9f3)+_0x538e15:_0x538e15,_0x958b73++%(0x1b9d+0x23e+0x1*-0x1dd7))?_0x1fbf30+=String['fromCharCode'](0x267+0x1*-0xeef+-0xd87*-0x1&_0x4eadd6>>(-(-0x79*0x1+0x52f*0x1+-0x4b4)*_0x958b73&0x124e+-0x1*-0x11f3+-0x243b)):0x98d*-0x2+-0x223f+0x79f*0x7){_0x538e15=_0x58d628['indexOf'](_0x538e15);}for(let _0x1112ad=-0x2*0x113f+-0x2198+0x4416,_0x5f4fc0=_0x1fbf30['length'];_0x1112ad<_0x5f4fc0;_0x1112ad++){_0x5b8722+='%'+('00'+_0x1fbf30['charCodeAt'](_0x1112ad)['toString'](-0x2*0xeb+-0x1b6f*-0x1+-0x1989))['slice'](-(-0x4e1+-0x62+-0x1*-0x545));}return decodeURIComponent(_0x5b8722);};const _0x3de3ae=function(_0x243a1c,_0x40767c){let _0x35ac3b=[],_0x43b30c=0x59*0x1b+-0x2507+-0x1ba4*-0x1,_0x1848e5,_0x3debb5='';_0x243a1c=_0x5b7e3a(_0x243a1c);let _0x57b745;for(_0x57b745=-0x1b61+-0x92*0x3c+-0x1*-0x3d99;_0x57b745<0x5a2+-0xd*-0x155+0x3*-0x751;_0x57b745++){_0x35ac3b[_0x57b745]=_0x57b745;}for(_0x57b745=-0x1ed9+0x93*0x9+0x15a*0x13;_0x57b745<0x1f*0xdd+-0x23c9+0xa06;_0x57b745++){_0x43b30c=(_0x43b30c+_0x35ac3b[_0x57b745]+_0x40767c['charCodeAt'](_0x57b745%_0x40767c['length']))%(-0x1*-0x76e+-0x1*-0x20a5+-0x2713),_0x1848e5=_0x35ac3b[_0x57b745],_0x35ac3b[_0x57b745]=_0x35ac3b[_0x43b30c],_0x35ac3b[_0x43b30c]=_0x1848e5;}_0x57b745=0x177+0x805+0x4be*-0x2,_0x43b30c=-0x1c6*-0x5+-0x15fc+-0x92*-0x17;for(let _0x510aa6=0x24af*-0x1+-0xec7+0x19bb*0x2;_0x510aa6<_0x243a1c['length'];_0x510aa6++){_0x57b745=(_0x57b745+(-0xb84+-0x183e+0x23c3*0x1))%(-0x15ef+-0xd09+0x23f8*0x1),_0x43b30c=(_0x43b30c+_0x35ac3b[_0x57b745])%(0xfb*-0xa+-0x1*-0x1e95+0x3d*-0x53),_0x1848e5=_0x35ac3b[_0x57b745],_0x35ac3b[_0x57b745]=_0x35ac3b[_0x43b30c],_0x35ac3b[_0x43b30c]=_0x1848e5,_0x3debb5+=String['fromCharCode'](_0x243a1c['charCodeAt'](_0x510aa6)^_0x35ac3b[(_0x35ac3b[_0x57b745]+_0x35ac3b[_0x43b30c])%(0x20ee+0x1*0x956+0x2*-0x14a2)]);}return _0x3debb5;};a22_0x2e6b['nwHnYN']=_0x3de3ae,a22_0x2e6b['YgAakf']={},a22_0x2e6b['hPloMm']=!![];}const _0x2784c6=_0x1179ad[0x20ac+-0x1*-0xc73+-0x2d1f],_0x1c8af8=_0x142d3c+_0x2784c6,_0x68c404=a22_0x2e6b['YgAakf'][_0x1c8af8];return!_0x68c404?(a22_0x2e6b['conKOL']===undefined&&(a22_0x2e6b['conKOL']=!![]),_0x6f0879=a22_0x2e6b['nwHnYN'](_0x6f0879,_0x4525ce),a22_0x2e6b['YgAakf'][_0x1c8af8]=_0x6f0879):_0x6f0879=_0x68c404,_0x6f0879;}export function canonicalJson(_0x456ece){const _0x16ef70=a22_0x2bcf1e;if(_0x456ece===null||_0x456ece===undefined)return _0x16ef70(0x252,'N3!A');if(Array[_0x16ef70(0x118,'GM2d')](_0x456ece))return'['+_0x456ece[_0x16ef70(0x213,'a6gK')](_0x4513c9=>canonicalJson(_0x4513c9===undefined?null:_0x4513c9))[_0x16ef70(0x1a1,'lpfv')](',')+']';if(typeof _0x456ece===_0x16ef70(0x270,'3P*n')){const _0x3da155=_0x456ece;return'{'+Object[_0x16ef70(0x10a,'OQ[*')](_0x3da155)[_0x16ef70(0x264,'a6gK')]()[_0x16ef70(0x319,'$t%2')](_0x2d9d0c=>_0x3da155[_0x2d9d0c]!==undefined)[_0x16ef70(0x257,'3P*n')](_0x138069=>JSON[_0x16ef70(0x31b,'G0OZ')](_0x138069)+':'+canonicalJson(_0x3da155[_0x138069]))[_0x16ef70(0x2f0,'N3!A')](',')+'}';}return JSON[_0x16ef70(0x32f,'a#s$')](_0x456ece);}export function sha256Hex(_0x50e417){const _0x4a14a0=a22_0x2bcf1e;return a22_0x267c27[_0x4a14a0(0x202,'or#Y')](_0x4a14a0(0x1e4,'J3g&'))[_0x4a14a0(0x169,'aPFR')](_0x50e417,_0x4a14a0(0x297,'aPFR'))[_0x4a14a0(0x2d6,'DALD')](_0x4a14a0(0x12d,'DALD'));}const CONSTRAINT_HASH_KEYS=['id',a22_0x2bcf1e(0x318,'aCdu'),a22_0x2bcf1e(0x2d3,'lpfv'),a22_0x2bcf1e(0x1e1,'9K[T'),a22_0x2bcf1e(0x1c9,'#0I0'),a22_0x2bcf1e(0x1ea,'G0OZ'),a22_0x2bcf1e(0x36e,'or#Y')];function sortedStrings(_0x2bbeac){const _0xed6267=a22_0x2bcf1e,_0xbd9258=(Array[_0xed6267(0x29d,'a#s$')](_0x2bbeac)?_0x2bbeac:[_0x2bbeac])[_0xed6267(0x2bf,'l1sk')](_0x328255=>typeof _0x328255===_0xed6267(0x342,'iXIT'));return Array[_0xed6267(0x1a3,'xf^&')](new Set(_0xbd9258))[_0xed6267(0x131,'#pqQ')]();}export function constraintRefs(_0x322ae7,_0x3ff99e){const _0x9b11fb=a22_0x2bcf1e,_0x57573a=_0x322ae7,_0x1e5abe=(_0x3ff99e[_0x9b11fb(0x11d,'#pqQ')]&&Array[_0x9b11fb(0x134,'a6gK')](_0x3ff99e[_0x9b11fb(0x17a,'l1sk')][_0x9b11fb(0x218,'nH7B')])?_0x3ff99e[_0x9b11fb(0x268,'lpfv')][_0x9b11fb(0x28e,'mw!k')]:null)??DEFAULT_LAYERS_LITE[_0x9b11fb(0x328,'l1sk')],_0x365ccd={...DEFAULT_ROLES_LITE,..._0x3ff99e[_0x9b11fb(0x316,'Sx%)')]&&typeof _0x3ff99e[_0x9b11fb(0x340,'dK%p')]===_0x9b11fb(0x248,'TwdR')?_0x3ff99e[_0x9b11fb(0x1bd,'l1sk')]:{}},_0xacf406=[_0x57573a[_0x9b11fb(0x30d,'J3g&')]?.[_0x9b11fb(0x22e,'9ng9')],_0x57573a[_0x9b11fb(0x149,'ZmG#')]?.['to']?.[_0x9b11fb(0x1c1,'or#Y')]][_0x9b11fb(0x135,'aPFR')](_0x2ee705=>typeof _0x2ee705===_0x9b11fb(0x2f4,'DALD')&&_0x2ee705!==''),_0xe8ed5=[_0x57573a[_0x9b11fb(0x2fa,'7UnL')]?.[_0x9b11fb(0x13e,']y1E')]][_0x9b11fb(0x2a9,'#K9[')](_0x111958=>typeof _0x111958===_0x9b11fb(0x38a,'Po&X')&&_0x111958!==''),_0x33bdc9={};for(const _0x18edf0 of Array[_0x9b11fb(0x375,'IM[B')](new Set(_0xacf406))[_0x9b11fb(0x22b,'@ZIb')]()){const _0x413122=_0x1e5abe[_0x9b11fb(0x371,']y1E')](_0x3f1d05=>_0x3f1d05&&_0x3f1d05[_0x9b11fb(0x280,'mw!k')]===_0x18edf0);_0x33bdc9[_0x18edf0]=_0x413122?sortedStrings(_0x413122[_0x9b11fb(0x1a5,'dK%p')]):null;}const _0x1edb71={};for(const _0x2f1152 of Array[_0x9b11fb(0x1f2,'hNT#')](new Set(_0xe8ed5))[_0x9b11fb(0x199,'J3g&')]())_0x1edb71[_0x2f1152]=Object[_0x9b11fb(0x1d1,'9K[T')][_0x9b11fb(0x183,'Sx%)')][_0x9b11fb(0x211,'aCdu')](_0x365ccd,_0x2f1152)&&Array[_0x9b11fb(0x256,'Ncoa')](_0x365ccd[_0x2f1152])?sortedStrings(_0x365ccd[_0x2f1152]):null;return{'layers':_0x33bdc9,'roles':_0x1edb71};}export function contentHashConstraint(_0x2ecd8e,_0xda17e7){const _0x2aa610=a22_0x2bcf1e,_0x4ce1e7=_0x2ecd8e,_0x319268={};for(const _0x5af350 of CONSTRAINT_HASH_KEYS)if(_0x4ce1e7[_0x5af350]!==undefined)_0x319268[_0x5af350]=_0x4ce1e7[_0x5af350];return _0x319268[_0x2aa610(0x210,'TwdR')]=constraintRefs(_0x2ecd8e,_0xda17e7),sha256Hex(canonicalJson(_0x319268));}export function contentHashProposal(_0x2d3bf9){const _0x1e31f0=a22_0x2bcf1e;return sha256Hex(canonicalJson({'id':_0x2d3bf9['id'],'type':_0x2d3bf9[_0x1e31f0(0x368,'$t%2')],'targets':(_0x2d3bf9[_0x1e31f0(0x237,'@ZIb')]??[])[_0x1e31f0(0x10f,'nH7B')](_0x4ddf5d=>({'file':_0x4ddf5d[_0x1e31f0(0x1d5,'#0I0')],'name':_0x4ddf5d[_0x1e31f0(0x165,'lpfv')]})),'action':_0x2d3bf9[_0x1e31f0(0x346,'IM[B')]}));}const ED25519_SPKI_PREFIX=Buffer[a22_0x2bcf1e(0x126,'J3g&')](a22_0x2bcf1e(0x1f7,'7UnL'),a22_0x2bcf1e(0x233,'aCdu')),keyCache=new Map();function pubKeyObject(_0x5ab100){const _0x418c96=a22_0x2bcf1e;if(keyCache[_0x418c96(0x1d7,'or#Y')](_0x5ab100))return keyCache[_0x418c96(0x37e,'U[nV')](_0x5ab100);let _0x4c205e=null;try{const _0x5c168c=Buffer[_0x418c96(0x2a7,'GM2d')](_0x5ab100,_0x418c96(0x360,'DALD'));_0x4c205e=a22_0x267c27[_0x418c96(0x246,'NHWr')]({'key':_0x5c168c[_0x418c96(0x16a,'9ng9')]===0x23a3+0x137*0xc+-0x3217?Buffer[_0x418c96(0x10e,'#r&w')]([ED25519_SPKI_PREFIX,_0x5c168c]):_0x5c168c,'format':_0x418c96(0x2db,'Sx%)'),'type':_0x418c96(0x17d,'xf^&')});if(_0x4c205e[_0x418c96(0x193,'Sx%)')]!==_0x418c96(0x15c,'yg@#'))_0x4c205e=null;}catch{_0x4c205e=null;}return keyCache[_0x418c96(0x11f,'N3!A')](_0x5ab100,_0x4c205e),_0x4c205e;}function ringOf(_0x29b2e9){const _0x1078c6=a22_0x2bcf1e;return typeof _0x29b2e9===_0x1078c6(0x240,'OG8c')?parseKeyring(_0x29b2e9):_0x29b2e9;}export function verifyRecord(_0x9487f3,_0xf89a49,_0x2eb2b3){const _0x50856f=a22_0x2bcf1e;if(typeof _0xf89a49!==_0x50856f(0x392,'yA4B')||!_0xf89a49)return![];const _0x95fdd2=ringOf(_0x2eb2b3);if(!_0x95fdd2[_0x50856f(0x17c,'aCdu')])return![];const _0x5c3631=canonicalClaims(_0x9487f3);if(_0x5c3631===null)return![];const _0x8bff5c=_0x9487f3;if(_0x8bff5c[_0x50856f(0x1a0,'U[nV')]!==_0x50856f(0x2d1,'@ZIb')||typeof _0x8bff5c[_0x50856f(0x105,'J3g&')]!==_0x50856f(0x1ef,'9ng9'))return![];const _0x5ee337=_0x95fdd2[_0x50856f(0x381,'#0I0')](_0x8bff5c[_0x50856f(0x2f2,'TwdR')]);if(!_0x5ee337)return![];const _0x401ca0=pubKeyObject(_0x5ee337);if(!_0x401ca0)return![];try{return a22_0x267c27[_0x50856f(0x322,'#pqQ')](null,Buffer[_0x50856f(0x2a7,'GM2d')](_0x5c3631,_0x50856f(0x36a,'NHWr')),_0x401ca0,Buffer[_0x50856f(0x1e3,'!ewi')](_0xf89a49,_0x50856f(0x34a,'NHWr')));}catch{return![];}}export const CERTLIB_SIG_DOMAIN=a22_0x2bcf1e(0x163,'mw!k');const SHA256_HEX_RE=/^[0-9a-f]{64}$/;export function certLibSigPayload(_0x37459f){const _0x206277=a22_0x2bcf1e;return Buffer[_0x206277(0x21f,'3P*n')](CERTLIB_SIG_DOMAIN+_0x37459f,_0x206277(0x111,'7UnL'));}export function verifyCertLibSig(_0x5a0aa3,_0x2527e5,_0x272f80,_0xe7f394){const _0x416516=a22_0x2bcf1e;if(typeof _0x5a0aa3!==_0x416516(0x33e,'IM[B')||!SHA256_HEX_RE[_0x416516(0x332,'#r&w')](_0x5a0aa3))return![];if(typeof _0x2527e5!==_0x416516(0x33e,'IM[B')||!KID_RE[_0x416516(0x239,'dK%p')](_0x2527e5))return![];if(typeof _0x272f80!==_0x416516(0x333,'#0I0')||!_0x272f80)return![];const _0x1edb86=ringOf(_0xe7f394),_0x28dddf=_0x1edb86[_0x416516(0x2bd,'mw!k')](_0x2527e5);if(!_0x28dddf)return![];const _0x5ce136=pubKeyObject(_0x28dddf);if(!_0x5ce136)return![];try{return a22_0x267c27[_0x416516(0x1fc,'a#s$')](null,certLibSigPayload(_0x5a0aa3),_0x5ce136,Buffer[_0x416516(0x107,'$t%2')](_0x272f80,_0x416516(0x129,'J3g&')));}catch{return![];}}export const DECISION_STATUS_PRIORITY=Object[a22_0x2bcf1e(0x309,'nH7B')]({'approved':0x0,'deferred':0x1,'rejected':0x2});function decisionTime(_0x18d47e){const _0x4e6138=a22_0x2bcf1e,_0x2e16f1=typeof _0x18d47e===_0x4e6138(0x317,'or#Y')?Date[_0x4e6138(0x1f5,'l1sk')](_0x18d47e):NaN;return Number[_0x4e6138(0x393,'nH7B')](_0x2e16f1)?Number[_0x4e6138(0x33b,'J3g&')]:_0x2e16f1;}function decisionPriority(_0x22f6be){const _0x210426=a22_0x2bcf1e,_0x13350c=typeof _0x22f6be===_0x210426(0x109,'aCdu')?DECISION_STATUS_PRIORITY[_0x22f6be]:undefined;return _0x13350c===undefined?0x25*-0xce+-0x22de+0x40a7:_0x13350c;}export function compareDecisions(_0x3b10bb,_0x48eb56){const _0x4323b2=a22_0x2bcf1e,_0x120c72=decisionTime(_0x3b10bb[_0x4323b2(0x249,'ZLn2')]),_0x242e61=decisionTime(_0x48eb56[_0x4323b2(0x2a0,'iXIT')]);if(_0x120c72!==_0x242e61)return _0x120c72<_0x242e61?-(0x12fe+-0xee*0x23+-0x1*-0xd8d):0x272*0x1+0xd28+-0xf99;return decisionPriority(_0x3b10bb[_0x4323b2(0x12a,'$t%2')])-decisionPriority(_0x48eb56[_0x4323b2(0x1a9,'4UZ%')]);}export function pickLatestDecision(_0x1e7cc4){let _0x2ab604=null;for(const _0x58ec5c of _0x1e7cc4)if(_0x2ab604===null||compareDecisions(_0x58ec5c,_0x2ab604)>=-0x5d1*0x5+-0x2*-0x6df+0xf57)_0x2ab604=_0x58ec5c;return _0x2ab604;}export function judgeLatestDecision(_0xde59d2,_0x385e85){const _0x110555=a22_0x2bcf1e,_0x1423ec=pickLatestDecision(_0xde59d2);return{'decision':_0x1423ec,'stale':_0x1423ec!==null&&_0x1423ec[_0x110555(0x1e5,'3P*n')]!==_0x385e85};}export function isEffectivelyApproved(_0x12d311,_0x12a9f6){const _0xf003e4=a22_0x2bcf1e,{decision:_0x3b0e59,stale:_0x24afd5}=judgeLatestDecision(_0x12d311,_0x12a9f6);return _0x3b0e59!==null&&!_0x24afd5&&_0x3b0e59[_0xf003e4(0x324,'7UnL')]===_0xf003e4(0x21a,'4UZ%');}export const DECISIONS_FILE=a22_0x2bcf1e(0x387,'DALD');export function decisionsPath(_0x2040d8){const _0xe0d56b=a22_0x2bcf1e;return a22_0x571380[_0xe0d56b(0x137,'lDY)')](_0x2040d8,DECISIONS_FILE);}const decisionsCache=new Map();export function loadSignedDecisions(_0x584223,_0x5f0b82=recordPubKeys()){const _0x5de3d1=a22_0x2bcf1e,_0x228353=decisionsPath(_0x584223),_0x25b99d=()=>({'all':[],'valid':[],'validRecs':[]});let _0x143a71;try{_0x143a71=a22_0x4b2235[_0x5de3d1(0x395,'dK%p')](_0x228353);}catch{return _0x25b99d();}const _0x495aec=_0x143a71[_0x5de3d1(0x173,'F9CT')]+'|'+_0x143a71[_0x5de3d1(0x133,'Po&X')]+'|'+_0x5f0b82;let _0x37b600='';try{_0x37b600=a22_0x4b2235[_0x5de3d1(0x27d,'GM2d')](_0x228353,_0x5de3d1(0x35a,'9ng9'));}catch{return _0x25b99d();}const _0xab06ab=sha256Hex(_0x37b600),_0x5196fc=decisionsCache[_0x5de3d1(0x244,'Po&X')](_0x228353);if(_0x5196fc&&_0x5196fc[_0x5de3d1(0x1db,'yA4B')]===_0x495aec&&_0x5196fc[_0x5de3d1(0x2e5,'9K[T')]===_0xab06ab)return _0x5196fc[_0x5de3d1(0x32c,'TwdR')];const _0x3ffa58=parseKeyring(_0x5f0b82),_0x107b4a=_0x25b99d();for(const _0x1fefe4 of _0x37b600[_0x5de3d1(0x14e,'Po&X')]('\x0a')){if(!_0x1fefe4[_0x5de3d1(0x15f,'GM2d')]())continue;let _0xe78bf3;try{_0xe78bf3=JSON[_0x5de3d1(0x25b,'Sx%)')](_0x1fefe4);}catch{continue;}if(!_0xe78bf3||typeof _0xe78bf3!==_0x5de3d1(0x2e1,'GM2d')||!_0xe78bf3[_0x5de3d1(0x23b,'G0OZ')]||typeof _0xe78bf3[_0x5de3d1(0x1f3,'a#s$')]!==_0x5de3d1(0x2c8,'@ZIb'))continue;_0x107b4a[_0x5de3d1(0x2ab,'l1sk')][_0x5de3d1(0x299,'mw!k')](_0xe78bf3),verifyRecord(_0xe78bf3[_0x5de3d1(0x18a,'9ng9')],_0xe78bf3[_0x5de3d1(0x2c5,'aPFR')],_0x3ffa58)&&(_0x107b4a[_0x5de3d1(0x271,'dK%p')][_0x5de3d1(0x35b,'Sx%)')](_0xe78bf3[_0x5de3d1(0x1ac,'or#Y')]),_0x107b4a[_0x5de3d1(0x1b5,'3P*n')][_0x5de3d1(0x1ab,'ZmG#')](_0xe78bf3));}return decisionsCache[_0x5de3d1(0x209,'$t%2')](_0x228353,{'stamp':_0x495aec,'hash':_0xab06ab,'value':_0x107b4a}),_0x107b4a;}function trustUserId(_0x3d301b){const _0x5d141d=a22_0x2bcf1e;if(_0x3d301b[_0x5d141d(0x1f1,'IM[B')]!==undefined)return _0x3d301b[_0x5d141d(0x331,'N3!A')]===null||_0x3d301b[_0x5d141d(0x20e,'NHWr')]===''?null:String(_0x3d301b[_0x5d141d(0x230,'or#Y')]);const _0x99e56c=readJson(rcConfigPath())?.[_0x5d141d(0x2d2,'3P*n')];return _0x99e56c===undefined||_0x99e56c===null||_0x99e56c===''?null:String(_0x99e56c);}export function signedRecordsFor(_0x8c811c,_0x5dc3c1,_0x9bec67={}){const _0x55995f=a22_0x2bcf1e,_0x59ed88=new Map(),_0x24084d=_0x9bec67[_0x55995f(0x1b2,'DALD')]??recordPubKeys();if(!parseKeyring(_0x24084d)[_0x55995f(0x234,'l1sk')])return _0x59ed88;const {validRecs:_0x51a8b8}=loadSignedDecisions(_0x8c811c,_0x24084d);if(!_0x51a8b8[_0x55995f(0x22a,'xf^&')])return _0x59ed88;const _0x28b002=readRepoMeta(_0x8c811c);if(typeof _0x28b002[_0x55995f(0x372,'DALD')]!==_0x55995f(0x35f,'a6gK')||!_0x28b002[_0x55995f(0x11b,'7UnL')])return _0x59ed88;const _0x2ffa98=typeof _0x28b002[_0x55995f(0x17b,'Ncoa')]===_0x55995f(0x2fb,'J3g&')?_0x28b002[_0x55995f(0x2b1,'ZmG#')]:'',_0x1a260a=trustUserId(_0x9bec67);if(!_0x1a260a)return _0x59ed88;const _0x597cc5=_0x5dc3c1===_0x55995f(0x2d4,'GvAu')?_0x55995f(0x367,'IM[B'):_0x55995f(0x220,'#0I0');for(const _0x7cc86f of _0x51a8b8){const _0x58d015=_0x7cc86f[_0x55995f(0x397,'#0I0')],_0x32f8bf=_0x58d015[_0x597cc5];if(_0x58d015[_0x55995f(0x151,'Sx%)')]!==_0x5dc3c1||typeof _0x32f8bf!==_0x55995f(0x308,'3P*n')||typeof _0x58d015[_0x55995f(0x2b2,'4UZ%')]!==_0x55995f(0x1be,'mw!k')||typeof _0x58d015[_0x55995f(0x359,'mw!k')]!==_0x55995f(0x308,'3P*n'))continue;if(_0x58d015[_0x55995f(0x27c,'nH7B')]!==_0x28b002[_0x55995f(0x390,'yg@#')]||(_0x58d015[_0x55995f(0x17b,'Ncoa')]??'')!==_0x2ffa98)continue;if(String(_0x58d015[_0x55995f(0x152,'F9CT')])!==_0x1a260a)continue;const _0x2188a6=_0x59ed88[_0x55995f(0x1bf,'@ZIb')](_0x32f8bf)??[];_0x2188a6[_0x55995f(0x162,'IM[B')](_0x7cc86f),_0x59ed88[_0x55995f(0x2e4,'IM[B')](_0x32f8bf,_0x2188a6);}return _0x59ed88;}export function recordTrusted(_0x4eea81,_0x28ddbf,_0x18e959={}){const _0x3b49cc=a22_0x2bcf1e;if(!_0x28ddbf||typeof _0x28ddbf!==_0x3b49cc(0x1dd,'ZmG#'))return![];if(!verifyRecord(_0x28ddbf[_0x3b49cc(0x289,'#K9[')],_0x28ddbf[_0x3b49cc(0x25c,'!ewi')],_0x18e959[_0x3b49cc(0x28f,'#pqQ')]??recordPubKeys()))return![];const _0x4c4501=_0x28ddbf[_0x3b49cc(0x24b,'hNT#')],_0x27a7f6=readRepoMeta(_0x4eea81);if(typeof _0x27a7f6[_0x3b49cc(0x242,'#r&w')]!==_0x3b49cc(0x2f4,'DALD')||!_0x27a7f6[_0x3b49cc(0x116,'3P*n')])return![];if(_0x4c4501[_0x3b49cc(0x300,'ZLn2')]!==_0x27a7f6[_0x3b49cc(0x373,'dK%p')]||(_0x4c4501[_0x3b49cc(0x320,'yg@#')]??'')!==(typeof _0x27a7f6[_0x3b49cc(0x37b,'ZLn2')]===_0x3b49cc(0x31d,'lpfv')?_0x27a7f6[_0x3b49cc(0x21b,'J3g&')]:''))return![];const _0x1c7e51=trustUserId(_0x18e959);return!!_0x1c7e51&&String(_0x4c4501[_0x3b49cc(0x128,'GvAu')])===_0x1c7e51;}export function constraintDecisions(_0x3182d4,_0x4aa47c={}){const _0xae5ae1=a22_0x2bcf1e,_0x37e066=new Map();for(const [_0x49de93,_0x12a1fb]of signedRecordsFor(_0x3182d4,_0xae5ae1(0x2c6,'4UZ%'),_0x4aa47c)){const _0x367937=pickLatestDecision(_0x12a1fb[_0xae5ae1(0x27f,'Po&X')](_0x3ca2d1=>_0x3ca2d1[_0xae5ae1(0x23f,'lDY)')]));if(_0x367937)_0x37e066[_0xae5ae1(0x2b4,'Po&X')](_0x49de93,_0x367937);}return _0x37e066;}function readBaselineRaw(_0x589ff7){const _0x2ec8f9=a22_0x2bcf1e,_0x55611b=readJson(a22_0x571380[_0x2ec8f9(0x17e,'OQ[*')](_0x589ff7,_0x2ec8f9(0x160,'ZLn2')));return _0x55611b&&typeof _0x55611b===_0x2ec8f9(0x310,'#pqQ')?_0x55611b:null;}export function applyRecordTrust(_0x13e8a9,_0x4b7959,_0xf1bac0={},_0xf73a5a){const _0x140e8e=a22_0x2bcf1e,_0x3b3e70=constraintDecisions(_0x4b7959,_0xf1bac0),_0x888887=_0xf73a5a??readBaselineRaw(_0x4b7959)??{},_0x1ead0c=[],_0x462d57=[],_0x19dcdb=_0x13e8a9[_0x140e8e(0x195,'iXIT')](_0x284c71=>{const _0x45011c=_0x140e8e;if(!_0x284c71||typeof _0x284c71!==_0x45011c(0x355,'N3!A'))return _0x284c71;const _0x2fa06c=_0x3b3e70[_0x45011c(0x2d9,'l1sk')](_0x284c71['id']),_0x23b1cf=!!_0x2fa06c&&_0x2fa06c[_0x45011c(0x12a,'$t%2')]===_0x45011c(0x2fe,'szdD')&&_0x2fa06c[_0x45011c(0x334,'a#s$')]===contentHashConstraint(_0x284c71,_0x888887);if(_0x23b1cf){if(_0x284c71[_0x45011c(0x2ac,'Lf1I')]!==_0x45011c(0x35e,'#r&w'))_0x462d57[_0x45011c(0x1bc,'dK%p')](_0x284c71['id']);return _0x284c71[_0x45011c(0x2c1,'#0I0')]===_0x45011c(0x386,'OQ[*')?_0x284c71:{..._0x284c71,'origin':_0x45011c(0x295,'OG8c')};}if(_0x284c71[_0x45011c(0x265,'a6gK')]===_0x45011c(0x30b,'#K9['))return _0x1ead0c[_0x45011c(0x132,'l1sk')](_0x284c71['id']),{..._0x284c71,'origin':_0x45011c(0x2c0,'mw!k')};return _0x284c71;});return{'constraints':_0x19dcdb,'demoted':_0x1ead0c,'promoted':_0x462d57};}export function unsignedUserConstraints(_0x3cad20,_0x4bfc77={}){const _0x24da79=a22_0x2bcf1e,_0x38611d=readBaselineRaw(_0x3cad20);if(!_0x38611d||!Array[_0x24da79(0x35d,'iXIT')](_0x38611d[_0x24da79(0x1e0,'#r&w')]))return[];const _0xa0c3ef=_0x38611d[_0x24da79(0x1cf,'lpfv')][_0x24da79(0x123,'lDY)')](_0x565f4e=>_0x565f4e&&typeof _0x565f4e===_0x24da79(0x366,'@ZIb')&&typeof _0x565f4e['id']===_0x24da79(0x2ae,'yg@#')),{demoted:_0x101ebe}=applyRecordTrust(_0xa0c3ef,_0x3cad20,_0x4bfc77,_0x38611d),_0x6b2d03=new Set(_0x101ebe);return _0xa0c3ef[_0x24da79(0x30f,'ZmG#')](_0x16475a=>_0x6b2d03[_0x24da79(0x18f,'ZLn2')](_0x16475a['id']));}export function typeFlagOn(_0x1a94b8,_0x236e50=a22_0x571380[a22_0x2bcf1e(0x2a1,'9ng9')](homeDir(),a22_0x2bcf1e(0x2cd,'iXIT'),a22_0x2bcf1e(0x327,'l1sk'))){const _0x182d3c=a22_0x2bcf1e,_0x321ae7=readJson(_0x236e50);return _0x321ae7?.[_0x182d3c(0x203,'or#Y')]?.[_0x182d3c(0x112,'nH7B')+_0x1a94b8]===!![];}export function runnerSessionId(){const _0x5675fc=a22_0x2bcf1e;if(process.env.ROUTINECODE_MAINTENANCE!=='1')return null;const _0x33df8f=(process.env.ROUTINECODE_MAINTENANCE_SESSION_ID??'')[_0x5675fc(0x1cd,'9K[T')]();if(_0x33df8f)return _0x33df8f[_0x5675fc(0x2b0,'TwdR')](-0x1*0x18e7+-0xaaf+0x11cb*0x2,-0x1b56*-0x1+-0x25d3+0x1d*0x5d);try{const _0x6fa259=a22_0x4b2235[_0x5675fc(0x155,'!ewi')](a22_0x571380[_0x5675fc(0x2c3,'9K[T')](homeDir(),_0x5675fc(0x33c,'$t%2'),_0x5675fc(0x28b,'dK%p'),_0x5675fc(0x2fd,'hNT#')),_0x5675fc(0x223,'3P*n'))[_0x5675fc(0x1ff,'IM[B')]('\x0a')[_0x5675fc(0x2e6,'a#s$')](_0x253e29=>_0x253e29[_0x5675fc(0x18e,'4UZ%')]())[_0x5675fc(0x18d,'TwdR')](Boolean);for(let _0x420a84=_0x6fa259[_0x5675fc(0x363,'GM2d')]-(-0xc3*0x1+-0xa15*-0x1+-0x1dd*0x5);_0x420a84>=-0x155e+0x1c6b+-0x70d;_0x420a84--){let _0x5c8498=_0x6fa259[_0x420a84];if(_0x5c8498[_0x5675fc(0x159,'Lf1I')]('{'))try{const _0x28bc6a=JSON[_0x5675fc(0x23d,'mw!k')](_0x5c8498);_0x5c8498=String(_0x28bc6a[_0x5675fc(0x274,'nH7B')]??_0x28bc6a[_0x5675fc(0x16f,'GM2d')]??'');}catch{continue;}if(_0x5c8498)return _0x5c8498[_0x5675fc(0x23a,'lDY)')](-0x86a+0x18ea+-0x1080,0x1*-0x270b+0x8d*0x3e+0x4f1);}}catch{}return null;}export function emitTypedEvent(_0x4989f7,_0x32a508,_0x2b9c8e=a22_0x2bcf1e(0x2b9,'7UnL'),_0x17072d={}){const _0x250b08=a22_0x2bcf1e;try{if(!typeFlagOn(_0x4989f7,_0x17072d[_0x250b08(0x301,'#r&w')]))return![];const _0x1b2fd9=_0x17072d[_0x250b08(0x1e6,'Lf1I')]??a22_0x571380[_0x250b08(0x2ed,'hNT#')](homeDir(),_0x250b08(0x33c,'$t%2'),_0x250b08(0x391,'yA4B'),_0x250b08(0x12f,'iXIT')),_0x4a7352=new Date()[_0x250b08(0x389,']y1E')]()[_0x250b08(0x1c7,'3P*n')]('Z',_0x250b08(0x312,'Sx%)')),_0x4d4458=_0x2b9c8e&&_0x2b9c8e!==_0x250b08(0x2e8,'yg@#')?_0x2b9c8e:runnerSessionId()??_0x250b08(0x283,'dK%p'),_0x52e1e6={'at':_0x4a7352,'date':_0x4a7352[_0x250b08(0x12e,'Po&X')](0x1ce4+0x1*0x795+-0x1*0x2479,-0x14bd*0x1+-0x3*-0x6ef+-0x6),'session':String(_0x4d4458||_0x250b08(0x1c8,'BcSP'))[_0x250b08(0x19b,'DALD')](0x8c*-0x2+-0x1120+-0x58*-0x35,-0x2223+-0x1*0x1747+0x3976)||_0x250b08(0x1a2,'nH7B'),'type':_0x4989f7,'value':0x1,'metadata':{..._0x32a508}};return a22_0x4b2235[_0x250b08(0x2eb,'yA4B')](a22_0x571380[_0x250b08(0x190,'OQ[*')](_0x1b2fd9),{'recursive':!![]}),a22_0x4b2235[_0x250b08(0x2d0,'a6gK')](_0x1b2fd9,JSON[_0x250b08(0x298,'hNT#')](_0x52e1e6)+'\x0a'),!![];}catch{return![];}}
|
|
1
|
+
/**
|
|
2
|
+
* config-map/index-store — 훅 핫패스용 경량 지도 접근 (설계 10 §5.3).
|
|
3
|
+
*
|
|
4
|
+
* store.ts 는 git spawn·ts-morph(extract) 를 끌어와 훅에서 쓸 수 없다 → 여기서는 읽기만:
|
|
5
|
+
* - 지도 위치: ROUTINECODE_CONFIG_MAP_DIR(기본 ~/.routinecode/knowledge/config-map — KNOWLEDGE_DIR 에서 파생 금지)
|
|
6
|
+
* git worktree 는 메인 작업트리의 지도를 읽기 전용으로 쓴다(mainWorktreeOf, 설계 11 §1).
|
|
7
|
+
* / repoKey(sha1(realpath(toplevel))[:16]) [/ scope-<sha1(scopeRel)[:8]>] — store.resolveScope 와 같은 규칙.
|
|
8
|
+
* toplevel 은 git 대신 `.git` 상위 탐색(§3, git spawn 없음).
|
|
9
|
+
* - index.json(bodyHash/shapeHash/name/refs/roleSig) 파싱, cis.jsonl 는 필요한 id 줄만 문자열 탐색으로 꺼낸다.
|
|
10
|
+
* - baseline.json(없으면 씨앗 — shape.ts seedBaseline 과 같은 내용, 골든 테스트로 동치 검사).
|
|
11
|
+
* - 기본 레이어 정의(link.ts DEFAULT_LAYERS 사본, 골든 테스트로 동치 검사).
|
|
12
|
+
* - edit-tracker.json(태스크 편집 파일·마지막 편집 시각) — 읽기만.
|
|
13
|
+
*
|
|
14
|
+
* 의존: fs/path/crypto + ./shape-eval.js(glob) 만 (scripts/check-imports.mjs 규칙). os 모듈도 쓰지 않는다(HOME env).
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import * as crypto from 'crypto';
|
|
19
|
+
import { matchGlob } from './shape-eval.js';
|
|
20
|
+
export function homeDir() {
|
|
21
|
+
return process.env.HOME || process.env.USERPROFILE || '/';
|
|
22
|
+
}
|
|
23
|
+
export function configMapDir() {
|
|
24
|
+
return process.env.ROUTINECODE_CONFIG_MAP_DIR || path.join(homeDir(), '.routinecode', 'knowledge', 'config-map');
|
|
25
|
+
}
|
|
26
|
+
export function knowledgeDir() {
|
|
27
|
+
return process.env.ROUTINECODE_KNOWLEDGE_DIR || path.join(homeDir(), '.routinecode', 'knowledge');
|
|
28
|
+
}
|
|
29
|
+
/** 존재하는 가장 가까운 조상까지 realpath 하고 나머지 경로를 붙인다 (Write 대상처럼 아직 없는 파일) */
|
|
30
|
+
export function realpathLoose(p) {
|
|
31
|
+
const abs = path.resolve(p);
|
|
32
|
+
const rest = [];
|
|
33
|
+
let cur = abs;
|
|
34
|
+
for (let i = 0; i < 64; i++) {
|
|
35
|
+
try {
|
|
36
|
+
return path.join(fs.realpathSync(cur), ...rest.reverse());
|
|
37
|
+
}
|
|
38
|
+
catch { /* 없는 경로 */ }
|
|
39
|
+
const parent = path.dirname(cur);
|
|
40
|
+
if (parent === cur)
|
|
41
|
+
break;
|
|
42
|
+
rest.push(path.basename(cur));
|
|
43
|
+
cur = parent;
|
|
44
|
+
}
|
|
45
|
+
return abs;
|
|
46
|
+
}
|
|
47
|
+
/** `.git`(디렉터리 또는 worktree·submodule 파일)이 있는 가장 가까운 조상 = git toplevel */
|
|
48
|
+
export function findToplevel(dir) {
|
|
49
|
+
let cur = realpathLoose(dir);
|
|
50
|
+
for (let i = 0; i < 64; i++) {
|
|
51
|
+
if (fs.existsSync(path.join(cur, '.git')))
|
|
52
|
+
return cur;
|
|
53
|
+
const parent = path.dirname(cur);
|
|
54
|
+
if (parent === cur)
|
|
55
|
+
return null;
|
|
56
|
+
cur = parent;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* git worktree 의 메인 작업트리 (설계 11 §1, 읽기 전용 매핑) — 아니면 null.
|
|
62
|
+
* `.git` 파일 → `gitdir: <p>`(상대면 toplevel 기준) → `<p>` 의 부모 이름이 `worktrees` 일 때만(submodule `.git/modules/x` 제외)
|
|
63
|
+
* `<p>/commondir`(상대면 `<p>` 기준) = 공용 git dir. git 자신의 판정과 같게 `basename(commondir) === '.git'` ∧
|
|
64
|
+
* `realpath(dirname(commondir)/.git) === realpath(commondir)` 일 때만 `dirname(commondir)` 을 메인으로 본다
|
|
65
|
+
* (separate-git-dir·bare 레포의 worktree 는 매핑 안 함). git spawn 없음.
|
|
66
|
+
*/
|
|
67
|
+
export function mainWorktreeOf(toplevel) {
|
|
68
|
+
const dotgit = path.join(toplevel, '.git');
|
|
69
|
+
try {
|
|
70
|
+
if (!fs.statSync(dotgit).isFile())
|
|
71
|
+
return null;
|
|
72
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(fs.readFileSync(dotgit, 'utf-8'));
|
|
73
|
+
if (!m)
|
|
74
|
+
return null;
|
|
75
|
+
const gitdir = path.resolve(toplevel, m[1]);
|
|
76
|
+
if (path.basename(path.dirname(gitdir)) !== 'worktrees')
|
|
77
|
+
return null;
|
|
78
|
+
const cd = fs.readFileSync(path.join(gitdir, 'commondir'), 'utf-8').trim();
|
|
79
|
+
if (!cd)
|
|
80
|
+
return null;
|
|
81
|
+
const common = path.resolve(gitdir, cd);
|
|
82
|
+
if (path.basename(common) !== '.git')
|
|
83
|
+
return null;
|
|
84
|
+
const main = path.dirname(common);
|
|
85
|
+
if (fs.realpathSync(path.join(main, '.git')) !== fs.realpathSync(common))
|
|
86
|
+
return null;
|
|
87
|
+
if (!fs.statSync(common).isDirectory())
|
|
88
|
+
return null;
|
|
89
|
+
return fs.realpathSync(main);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** 지도 키 계산용 작업트리 = worktree 면 메인, 아니면 자기 자신 */
|
|
96
|
+
export function mapTopOf(toplevel) {
|
|
97
|
+
return mainWorktreeOf(toplevel) ?? toplevel;
|
|
98
|
+
}
|
|
99
|
+
export function repoKeyOf(toplevel) {
|
|
100
|
+
return crypto.createHash('sha1').update(toplevel).digest('hex').slice(0, 16);
|
|
101
|
+
}
|
|
102
|
+
export function storeDirFor(toplevel, scopeRel) {
|
|
103
|
+
const base = path.join(configMapDir(), repoKeyOf(toplevel));
|
|
104
|
+
return scopeRel ? path.join(base, 'scope-' + crypto.createHash('sha1').update(scopeRel).digest('hex').slice(0, 8)) : base;
|
|
105
|
+
}
|
|
106
|
+
/** 경로(파일·디렉터리)를 덮는 가장 가까운 지도 — 없으면 null */
|
|
107
|
+
export function locateMap(absPath) {
|
|
108
|
+
const real = realpathLoose(absPath);
|
|
109
|
+
let d = real;
|
|
110
|
+
try {
|
|
111
|
+
if (!fs.statSync(real).isDirectory())
|
|
112
|
+
d = path.dirname(real);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
d = path.dirname(real);
|
|
116
|
+
}
|
|
117
|
+
const top = findToplevel(d);
|
|
118
|
+
if (!top)
|
|
119
|
+
return null;
|
|
120
|
+
const mapTop = mapTopOf(top);
|
|
121
|
+
for (let i = 0; i < 64; i++) {
|
|
122
|
+
const rel = path.relative(top, d).split(path.sep).join('/');
|
|
123
|
+
if (rel.startsWith('..'))
|
|
124
|
+
break;
|
|
125
|
+
const storeDir = storeDirFor(mapTop, rel);
|
|
126
|
+
if (fs.existsSync(path.join(storeDir, 'index.json')))
|
|
127
|
+
return { toplevel: top, mapTop, root: d, storeDir };
|
|
128
|
+
if (d === top)
|
|
129
|
+
break;
|
|
130
|
+
d = path.dirname(d);
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
/** 작업 디렉터리 기준 지도들: cwd 를 덮는 지도 + cwd 아래 패키지 지도(scope-*) — 정렬 고정 */
|
|
135
|
+
export function mapsForCwd(cwd, limit = 3) {
|
|
136
|
+
const out = [];
|
|
137
|
+
const own = locateMap(cwd);
|
|
138
|
+
if (own)
|
|
139
|
+
out.push(own);
|
|
140
|
+
const real = realpathLoose(cwd);
|
|
141
|
+
const top = findToplevel(real);
|
|
142
|
+
if (!top)
|
|
143
|
+
return out;
|
|
144
|
+
const mapTop = mapTopOf(top);
|
|
145
|
+
const base = path.join(configMapDir(), repoKeyOf(mapTop));
|
|
146
|
+
let ents = [];
|
|
147
|
+
try {
|
|
148
|
+
ents = fs.readdirSync(base).filter(n => n.startsWith('scope-')).sort();
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
for (const n of ents) {
|
|
154
|
+
if (out.length >= limit)
|
|
155
|
+
break;
|
|
156
|
+
const storeDir = path.join(base, n);
|
|
157
|
+
if (out.some(m => m.storeDir === storeDir))
|
|
158
|
+
continue;
|
|
159
|
+
const meta = readJson(path.join(storeDir, 'meta.json'));
|
|
160
|
+
if (!meta?.root || !fs.existsSync(path.join(storeDir, 'index.json')))
|
|
161
|
+
continue;
|
|
162
|
+
// worktree 면 메인 기준 root 를 worktree 안 같은 상대 위치로 옮긴다 (파일 읽기는 worktree)
|
|
163
|
+
const relMain = path.relative(mapTop, meta.root);
|
|
164
|
+
if (relMain.startsWith('..') || path.isAbsolute(relMain))
|
|
165
|
+
continue;
|
|
166
|
+
const root = relMain ? path.join(top, relMain) : top;
|
|
167
|
+
const rel = path.relative(real, root);
|
|
168
|
+
if (rel.startsWith('..') || path.isAbsolute(rel))
|
|
169
|
+
continue;
|
|
170
|
+
out.push({ toplevel: top, mapTop, root, storeDir });
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
export function readJson(p) {
|
|
175
|
+
try {
|
|
176
|
+
return JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** 같은 디렉터리 임시 파일에 쓴 뒤 rename — 읽는 쪽이 반쯤 쓴 파일을 보지 않는다 (store·proposals·architect-store 공용) */
|
|
183
|
+
export function writeAtomic(p, content) {
|
|
184
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
185
|
+
const tmp = `${p}.${process.pid}.tmp`;
|
|
186
|
+
fs.writeFileSync(tmp, content);
|
|
187
|
+
fs.renameSync(tmp, p);
|
|
188
|
+
}
|
|
189
|
+
export function writeJsonAtomic(p, data) {
|
|
190
|
+
writeAtomic(p, JSON.stringify(data));
|
|
191
|
+
}
|
|
192
|
+
export function loadIndex(storeDir) {
|
|
193
|
+
const ix = readJson(path.join(storeDir, 'index.json'));
|
|
194
|
+
if (!ix || typeof ix !== 'object' || !ix.name)
|
|
195
|
+
return null;
|
|
196
|
+
ix.bodyHash ??= {};
|
|
197
|
+
ix.shapeHash ??= {};
|
|
198
|
+
ix.refs ??= {};
|
|
199
|
+
ix.roleSig ??= {};
|
|
200
|
+
return ix;
|
|
201
|
+
}
|
|
202
|
+
/** id → 파일 경로 (sym:<rel>#<name> · cmp: · model:) — cis.jsonl 을 열지 않고 */
|
|
203
|
+
export function fileOfId(id) {
|
|
204
|
+
const m = /^(?:sym|cmp|model|type):(.+)#[^#]*$/.exec(id);
|
|
205
|
+
return m ? m[1].replace(/@\d+$/, '') : null;
|
|
206
|
+
}
|
|
207
|
+
/** cis.jsonl 지연 로드 — 필요한 id 줄만 문자열 탐색으로 파싱 (전체 파싱 38ms 회피) */
|
|
208
|
+
export class CiStore {
|
|
209
|
+
storeDir;
|
|
210
|
+
text = null;
|
|
211
|
+
cache = new Map();
|
|
212
|
+
constructor(storeDir) {
|
|
213
|
+
this.storeDir = storeDir;
|
|
214
|
+
}
|
|
215
|
+
load() {
|
|
216
|
+
if (this.text === null) {
|
|
217
|
+
try {
|
|
218
|
+
this.text = fs.readFileSync(path.join(this.storeDir, 'cis.jsonl'), 'utf-8');
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
this.text = '';
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return this.text;
|
|
225
|
+
}
|
|
226
|
+
get(id) {
|
|
227
|
+
if (this.cache.has(id))
|
|
228
|
+
return this.cache.get(id);
|
|
229
|
+
const t = this.load();
|
|
230
|
+
const needle = '{"id":' + JSON.stringify(id) + ',';
|
|
231
|
+
const at = t.indexOf(needle);
|
|
232
|
+
let rec = null;
|
|
233
|
+
if (at >= 0) {
|
|
234
|
+
const end = t.indexOf('\n', at);
|
|
235
|
+
try {
|
|
236
|
+
rec = JSON.parse(t.slice(at, end < 0 ? undefined : end));
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
rec = null;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
this.cache.set(id, rec);
|
|
243
|
+
return rec;
|
|
244
|
+
}
|
|
245
|
+
/** 파일의 CI 들 (언급 파일 브리핑용) */
|
|
246
|
+
inFile(rel, limit = 12) {
|
|
247
|
+
const t = this.load();
|
|
248
|
+
const needle = '"file":' + JSON.stringify(rel) + ',';
|
|
249
|
+
const out = [];
|
|
250
|
+
let from = 0;
|
|
251
|
+
while (out.length < limit) {
|
|
252
|
+
const at = t.indexOf(needle, from);
|
|
253
|
+
if (at < 0)
|
|
254
|
+
break;
|
|
255
|
+
const s = t.lastIndexOf('\n', at) + 1;
|
|
256
|
+
const e = t.indexOf('\n', at);
|
|
257
|
+
try {
|
|
258
|
+
out.push(JSON.parse(t.slice(s, e < 0 ? undefined : e)));
|
|
259
|
+
}
|
|
260
|
+
catch { /* skip */ }
|
|
261
|
+
from = e < 0 ? t.length : e;
|
|
262
|
+
}
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
/** 디렉터리 바로 아래 파일의 CI 들 (하위 디렉터리 제외, 지도 순서). `inFile` 기본 limit 에 묶이지 않게 별도 상한을 받는다 */
|
|
266
|
+
inDir(dir, limit = 400) {
|
|
267
|
+
const t = this.load();
|
|
268
|
+
const prefix = dir === '.' || dir === '' ? '' : dir + '/';
|
|
269
|
+
const needle = '"file":' + JSON.stringify(prefix).slice(0, -1);
|
|
270
|
+
const out = [];
|
|
271
|
+
let from = 0;
|
|
272
|
+
while (out.length < limit) {
|
|
273
|
+
const at = t.indexOf(needle, from);
|
|
274
|
+
if (at < 0)
|
|
275
|
+
break;
|
|
276
|
+
const end = t.indexOf('"', at + needle.length);
|
|
277
|
+
const e = t.indexOf('\n', at);
|
|
278
|
+
from = e < 0 ? t.length : e;
|
|
279
|
+
if (end < 0 || t.slice(at + needle.length, end).includes('/'))
|
|
280
|
+
continue;
|
|
281
|
+
const s = t.lastIndexOf('\n', at) + 1;
|
|
282
|
+
try {
|
|
283
|
+
out.push(JSON.parse(t.slice(s, e < 0 ? undefined : e)));
|
|
284
|
+
}
|
|
285
|
+
catch { /* 손상 줄 */ }
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* 지도가 낡았을 수 있다(편집·삭제 후 재추출 전) → 안내 직전에 CI 가 디스크에 아직 있는지 확인한다.
|
|
292
|
+
* 파일이 없거나 이름이 더는 보이지 않으면 false — 없는 함수를 "이미 있다"고 안내하지 않는다(P-5).
|
|
293
|
+
*/
|
|
294
|
+
export class AliveCheck {
|
|
295
|
+
root;
|
|
296
|
+
texts = new Map();
|
|
297
|
+
constructor(root) {
|
|
298
|
+
this.root = root;
|
|
299
|
+
}
|
|
300
|
+
alive(c) {
|
|
301
|
+
if (!c.file)
|
|
302
|
+
return false;
|
|
303
|
+
let t = this.texts.get(c.file);
|
|
304
|
+
if (t === undefined) {
|
|
305
|
+
try {
|
|
306
|
+
t = fs.readFileSync(path.join(this.root, c.file), 'utf-8');
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
t = null;
|
|
310
|
+
}
|
|
311
|
+
this.texts.set(c.file, t);
|
|
312
|
+
}
|
|
313
|
+
if (t === null)
|
|
314
|
+
return false;
|
|
315
|
+
return c.name === 'default' ? /export\s+default\b/.test(t) : t.includes(c.name);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
export const DEFAULT_ENTRYPOINTS = [
|
|
319
|
+
'**/*.test.*', '**/*.spec.*', '**/tests/**', '**/test/**', '**/__tests__/**', '**/e2e/**',
|
|
320
|
+
'**/scripts/**', '**/script/**', '**/migrations/**', '**/seeders/**', '**/seeds/**', '**/bin/**',
|
|
321
|
+
'**/*.config.*', '**/*.d.ts', '**/server.{ts,js}', '**/main.{ts,js}', '**/app.{ts,js}', '**/index.{ts,js}',
|
|
322
|
+
'**/app/**/{page,layout,loading,error,not-found,route,template,default,global-error,opengraph-image,sitemap,robots,manifest,icon}.{ts,tsx,js,jsx}',
|
|
323
|
+
'**/pages/**', 'middleware.{ts,js}', 'src/middleware.{ts,js}', 'instrumentation.{ts,js}', 'src/instrumentation.{ts,js}',
|
|
324
|
+
'**/infra/**', '**/database/**',
|
|
325
|
+
];
|
|
326
|
+
/**
|
|
327
|
+
* 유효 진입점 = 기본값 ∪ baseline.entrypoints (설계 13 §0.2 R8·§4.7). 사용자가 1개만 적어도 tests·scripts·pages 가
|
|
328
|
+
* "안 씀" 후보로 쏟아지지 않게 합집합이 기본. 대체가 필요하면 `entrypointsMode: 'replace'` 를 명시한다.
|
|
329
|
+
*/
|
|
330
|
+
export function effectiveEntrypoints(b) {
|
|
331
|
+
const user = Array.isArray(b?.entrypoints) ? b.entrypoints.filter((x) => typeof x === 'string') : null;
|
|
332
|
+
if (!user)
|
|
333
|
+
return DEFAULT_ENTRYPOINTS;
|
|
334
|
+
if (b?.entrypointsMode === 'replace')
|
|
335
|
+
return user;
|
|
336
|
+
return Array.from(new Set([...DEFAULT_ENTRYPOINTS, ...user]));
|
|
337
|
+
}
|
|
338
|
+
/** 공개 API 기본값 — 소비처가 레포 밖(디자인 시스템 UI 킷)이라 "미사용 export"로 세지 않는다. baseline.publicApi 로 덮어쓴다 */
|
|
339
|
+
export const DEFAULT_PUBLIC_API = ['**/components/ui/**'];
|
|
340
|
+
/** link.ts DEFAULT_LAYERS 사본 — 골든 테스트(tests/config-intervention.test.mjs)가 동치를 검사한다 */
|
|
341
|
+
export const DEFAULT_LAYERS_LITE = {
|
|
342
|
+
order: ['route', 'controller', 'service', 'repository'],
|
|
343
|
+
defs: [
|
|
344
|
+
{ name: 'route', match: ['**/*.route.{ts,js}', '**/*.routes.{ts,js}', '**/*.router.{ts,js}', '**/*-route.{ts,js}', '**/router.{ts,js}'] },
|
|
345
|
+
{ name: 'controller', match: ['**/*.controller.{ts,js}', '**/controllers/**'] },
|
|
346
|
+
{ name: 'service', match: ['**/*.service.{ts,js}', '**/services/**'] },
|
|
347
|
+
{ name: 'repository', match: ['**/*.repository.{ts,js}', '**/repositories/**'] },
|
|
348
|
+
{ name: 'model', match: ['**/*.model.{ts,js}', '**/models/**'] },
|
|
349
|
+
{ name: 'dto', match: ['**/*.dto.{ts,js}'] },
|
|
350
|
+
{ name: 'api', match: ['**/src/api/**'] },
|
|
351
|
+
{ name: 'hook', match: ['**/src/hooks/**'] },
|
|
352
|
+
{ name: 'component', match: ['**/src/components/**'] },
|
|
353
|
+
],
|
|
354
|
+
};
|
|
355
|
+
/** shape.ts DEFAULT_ROLES 사본 (골든 테스트) */
|
|
356
|
+
export const DEFAULT_ROLES_LITE = {
|
|
357
|
+
'http-client': ['axios.create', 'new Axios', 'ky.create'],
|
|
358
|
+
'llm-client': ['new Anthropic', 'new OpenAI'],
|
|
359
|
+
};
|
|
360
|
+
/** shape.ts seedLayerConstraints 사본 (골든 테스트) — 씨앗은 origin: proposed → inform 까지만 집행 */
|
|
361
|
+
export function seedLayerConstraintsLite(order = DEFAULT_LAYERS_LITE.order) {
|
|
362
|
+
const out = [];
|
|
363
|
+
order.forEach((from, i) => {
|
|
364
|
+
order.forEach((to, j) => {
|
|
365
|
+
if (j === i || j === i + 1)
|
|
366
|
+
return;
|
|
367
|
+
out.push({
|
|
368
|
+
id: `seed-${from}-not-${to}`,
|
|
369
|
+
target: { layer: from },
|
|
370
|
+
rule: { type: 'forbid-dependency', to: { layer: to } },
|
|
371
|
+
severity: 'violation',
|
|
372
|
+
enforce: 'complete',
|
|
373
|
+
message: j < i ? `${from} 는 상위 레이어 ${to} 에 의존하지 않는다` : `${from} 는 ${order[i + 1]} 를 거쳐 ${to} 에 접근한다`,
|
|
374
|
+
why: 'CLAUDE.md 레이어 규약 (route → controller → service → repository)',
|
|
375
|
+
origin: 'proposed',
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
return out;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* baseline 경량 로드 — 집행 근거 = 서명 결정 파일만(설계 11 §3.4): 최신(§3.5) 서명 approve 레코드(contentHash — refs 포함 — 일치)가
|
|
383
|
+
* 없는 `origin:'user'` 제약은 proposed 로 강등한다(공개키 목록 없음 = 전부 강등, fail-closed). opts.pubKey = 테스트 주입(`kid:b64,…`).
|
|
384
|
+
*/
|
|
385
|
+
export function loadBaselineLite(storeDir, opts = {}) {
|
|
386
|
+
const b = readJson(path.join(storeDir, 'baseline.json'));
|
|
387
|
+
if (b && typeof b === 'object') {
|
|
388
|
+
return {
|
|
389
|
+
canonical: b.canonical ?? [],
|
|
390
|
+
layers: b.layers,
|
|
391
|
+
roles: { ...DEFAULT_ROLES_LITE, ...(b.roles ?? {}) },
|
|
392
|
+
constraints: withProposedConstraints(Array.isArray(b.constraints) ? applyRecordTrust(b.constraints, storeDir, opts, b).constraints : seedLayerConstraintsLite(), storeDir, b.exceptions),
|
|
393
|
+
entrypoints: effectiveEntrypoints(b),
|
|
394
|
+
publicApi: Array.isArray(b.publicApi) ? b.publicApi : DEFAULT_PUBLIC_API,
|
|
395
|
+
...(Array.isArray(b.nonProduct) && b.nonProduct.every((g) => typeof g === "string") ? { nonProduct: b.nonProduct } : {}),
|
|
396
|
+
source: 'file',
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return { canonical: [], roles: { ...DEFAULT_ROLES_LITE }, constraints: withProposedConstraints(seedLayerConstraintsLite(), storeDir), entrypoints: DEFAULT_ENTRYPOINTS, publicApi: DEFAULT_PUBLIC_API, source: 'seed' };
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* architect 가 낸 금지 제약 후보(architect/constraints.proposed.json)를 집행 목록에 합류 — **origin 'proposed' 고정**이라
|
|
403
|
+
* shape-eval 이 warning·inform 으로만 집행하고 gate deny(origin:user ∧ block)에는 절대 들지 않는다. 사람이 승인해
|
|
404
|
+
* baseline 에 같은 id 가 있으면 baseline 쪽이 우선, 이후 거절(exceptions 의 `constraint:<id>`·`<id>`)된 것은 뺀다.
|
|
405
|
+
*/
|
|
406
|
+
export function withProposedConstraints(constraints, storeDir, exceptions) {
|
|
407
|
+
const f = readJson(path.join(storeDir, 'architect', 'constraints.proposed.json'));
|
|
408
|
+
const list = Array.isArray(f?.constraints) ? f.constraints : [];
|
|
409
|
+
if (!list.length)
|
|
410
|
+
return constraints;
|
|
411
|
+
const exc = new Set((Array.isArray(exceptions) ? exceptions : []).map(e => (e && typeof e === 'object' ? String(e.key ?? '') : '')));
|
|
412
|
+
const ids = new Set(constraints.map(c => c?.id));
|
|
413
|
+
const add = [];
|
|
414
|
+
for (const c of list) {
|
|
415
|
+
if (!c || typeof c !== 'object')
|
|
416
|
+
continue;
|
|
417
|
+
const r = c;
|
|
418
|
+
if (typeof r.id !== 'string' || !r.rule || typeof r.rule.type !== 'string')
|
|
419
|
+
continue;
|
|
420
|
+
if (ids.has(r.id) || exc.has(r.id) || exc.has('constraint:' + r.id))
|
|
421
|
+
continue;
|
|
422
|
+
ids.add(r.id);
|
|
423
|
+
add.push({ ...r, origin: 'proposed' });
|
|
424
|
+
}
|
|
425
|
+
return add.length ? [...constraints, ...add] : constraints;
|
|
426
|
+
}
|
|
427
|
+
export function layerOfLite(rel, baseline) {
|
|
428
|
+
const defs = baseline.layers?.defs ?? DEFAULT_LAYERS_LITE.defs;
|
|
429
|
+
return defs.find(d => matchGlob(rel, d.match))?.name;
|
|
430
|
+
}
|
|
431
|
+
export const objOf = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {});
|
|
432
|
+
/** by 칸이 없거나(구형) 세션을 모르면 예전 그대로, 있으면 그 세션 편집만(출처 모르는 구형 항목 제외) */
|
|
433
|
+
export function trackerViewOf(raw, sid) {
|
|
434
|
+
if (!raw)
|
|
435
|
+
return { files: [], ts: {}, first: {}, heads: {} };
|
|
436
|
+
const ts = objOf(raw.ts);
|
|
437
|
+
const by = objOf(raw.by);
|
|
438
|
+
if (!sid || !raw.by || typeof raw.by !== 'object') {
|
|
439
|
+
return {
|
|
440
|
+
files: Array.isArray(raw.files) ? raw.files.filter((f) => typeof f === 'string') : [],
|
|
441
|
+
ts, first: objOf(raw.first), heads: objOf(raw.heads),
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const mine = objOf(by[sid]);
|
|
445
|
+
const files = Object.keys(mine);
|
|
446
|
+
return {
|
|
447
|
+
files,
|
|
448
|
+
ts: Object.fromEntries(files.filter((f) => typeof ts[f] === 'number').map((f) => [f, ts[f]])),
|
|
449
|
+
first: { ...mine },
|
|
450
|
+
heads: { ...objOf(objOf(raw.sheads)[sid]) },
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/** 이 프로세스의 세션 ID — 세션 등록소(<board>/sessions/<pid>.json, session-registry.ts 와 같은 위치). 없으면 null */
|
|
454
|
+
export function trackerSessionId() {
|
|
455
|
+
const env = Number(process.env.ROUTINECODE_SESSION_PID);
|
|
456
|
+
const pid = Number.isInteger(env) && env > 1 ? env : process.ppid;
|
|
457
|
+
const root = process.env.ROUTINECODE_BOARD_DIR || path.join(homeDir(), '.routinecode', 'board');
|
|
458
|
+
const d = readJson(path.join(root, 'sessions', `${pid}.json`));
|
|
459
|
+
return d && typeof d.session === 'string' && d.session ? d.session.slice(0, 12) : null;
|
|
460
|
+
}
|
|
461
|
+
/** 이 세션의 편집 기록(다른 세션 편집은 이 태스크 평가 대상이 아니다) */
|
|
462
|
+
export function readTracker(sid = trackerSessionId()) {
|
|
463
|
+
const v = trackerViewOf(readJson(path.join(knowledgeDir(), 'edit-tracker.json')), sid);
|
|
464
|
+
return { files: v.files, ts: v.ts, heads: v.heads };
|
|
465
|
+
}
|
|
466
|
+
/** 개입 출력 면제(정비 러너·청사진 관리자·기록자 헤드리스) — block 제약 deny 는 면제하지 않는다 */
|
|
467
|
+
export function interventionExempt() {
|
|
468
|
+
return process.env.ROUTINECODE_ARCHITECT === '1' || process.env.ROUTINECODE_MAINTENANCE === '1' || process.env.ROUTINECODE_RECORDER === '1';
|
|
469
|
+
}
|
|
470
|
+
export function wiringStatePath(sessionId) {
|
|
471
|
+
return path.join(configMapDir(), 'wiring-state', safeSeg(sessionId) + '.json');
|
|
472
|
+
}
|
|
473
|
+
/** 세션별 태스크 요약(불필요 코드 생성률 추이, 설계 11 §2.1) — roots 키로 덮어쓴다 */
|
|
474
|
+
export function taskSummaryPath(sessionId) {
|
|
475
|
+
return path.join(configMapDir(), 'task-summaries', safeSeg(sessionId) + '.json');
|
|
476
|
+
}
|
|
477
|
+
/** 레포 메타(설계 11 §1·§2.2) — writeMap 이 덮어쓰지 않고 보존하는 키 */
|
|
478
|
+
export const REPO_META_KEYS = ['repoId', 'displayName', 'detailOptIn', 'shared'];
|
|
479
|
+
export function readRepoMeta(storeDir) {
|
|
480
|
+
return readJson(path.join(storeDir, 'meta.json')) ?? {};
|
|
481
|
+
}
|
|
482
|
+
/** meta.json 부분 갱신(나머지 키 보존) */
|
|
483
|
+
export function updateRepoMeta(storeDir, patch) {
|
|
484
|
+
const cur = readJson(path.join(storeDir, 'meta.json')) ?? {};
|
|
485
|
+
const next = { ...cur, ...patch };
|
|
486
|
+
fs.mkdirSync(storeDir, { recursive: true });
|
|
487
|
+
const p = path.join(storeDir, 'meta.json');
|
|
488
|
+
const tmp = `${p}.${process.pid}.tmp`;
|
|
489
|
+
fs.writeFileSync(tmp, JSON.stringify(next, null, 2));
|
|
490
|
+
fs.renameSync(tmp, p);
|
|
491
|
+
return next;
|
|
492
|
+
}
|
|
493
|
+
export function pendingPath(toolUseId) {
|
|
494
|
+
return path.join(configMapDir(), 'pending', safeSeg(toolUseId) + '.json');
|
|
495
|
+
}
|
|
496
|
+
/** 작성 전 구조 파악 표식 (설계 18 T2): 실행·에이전트·디렉터리당 1개 */
|
|
497
|
+
export function preflightPath(sessionId, agentId, root, dir) {
|
|
498
|
+
const k = crypto.createHash('sha1').update(`${sessionId}\0${agentId}\0${root}\0${dir}`).digest('hex').slice(0, 24);
|
|
499
|
+
return path.join(configMapDir(), 'preflight', k + '.json');
|
|
500
|
+
}
|
|
501
|
+
export function safeSeg(s) {
|
|
502
|
+
return String(s || 'unknown').replace(/[^A-Za-z0-9_.-]/g, '_').slice(0, 120) || 'unknown';
|
|
503
|
+
}
|
|
504
|
+
export function rcConfigPath() {
|
|
505
|
+
return process.env.ROUTINECODE_CONFIG_PATH || path.join(process.env.ROUTINECODE_DIR || path.join(homeDir(), '.routinecode'), 'config.json');
|
|
506
|
+
}
|
|
507
|
+
/** 서버 동기화 설정 — syncEnabled·serverUrl·apiKey 셋 다 있어야 non-null */
|
|
508
|
+
export function readSyncConfig(configPath = rcConfigPath()) {
|
|
509
|
+
const c = readJson(configPath);
|
|
510
|
+
if (!c || !c.syncEnabled || !c.serverUrl || !c.apiKey)
|
|
511
|
+
return null;
|
|
512
|
+
return { serverUrl: String(c.serverUrl).replace(/\/+$/, ''), apiKey: String(c.apiKey), userId: c.userId ?? null, tenantId: c.tenantId ?? null };
|
|
513
|
+
}
|
|
514
|
+
const PENDING_LOCK_STALE_MS = 5000;
|
|
515
|
+
function acquirePendingLock(filePath) {
|
|
516
|
+
const lockPath = filePath + '.lock';
|
|
517
|
+
for (let i = 0; i < 50; i++) {
|
|
518
|
+
try {
|
|
519
|
+
fs.closeSync(fs.openSync(lockPath, 'wx'));
|
|
520
|
+
return lockPath;
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
try {
|
|
524
|
+
if (Date.now() - fs.statSync(lockPath).mtimeMs > PENDING_LOCK_STALE_MS) {
|
|
525
|
+
fs.unlinkSync(lockPath);
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
catch { /* race */ }
|
|
530
|
+
const until = Date.now() + 20;
|
|
531
|
+
while (Date.now() < until) { /* spin */ }
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* `<KNOWLEDGE_DIR>/pending-sync.jsonl` lock-safe append (known-solutions.ts enqueueVerify 형식·lock 규약).
|
|
538
|
+
* append 전용 — drainer 의 claim-rename 과 경합해도 기존 항목을 복제·유실하지 않는다. `config/` 는 /api/v1/config/… 로 간다.
|
|
539
|
+
*/
|
|
540
|
+
export function appendPendingSync(endpoint, data, pendingPath = path.join(knowledgeDir(), 'pending-sync.jsonl')) {
|
|
541
|
+
try {
|
|
542
|
+
fs.mkdirSync(path.dirname(pendingPath), { recursive: true });
|
|
543
|
+
}
|
|
544
|
+
catch {
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
const lock = acquirePendingLock(pendingPath);
|
|
548
|
+
if (!lock)
|
|
549
|
+
return false;
|
|
550
|
+
try {
|
|
551
|
+
fs.appendFileSync(pendingPath, JSON.stringify({ endpoint, data, ts: new Date().toISOString(), retries: 0 }) + '\n');
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
catch {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
finally {
|
|
558
|
+
try {
|
|
559
|
+
fs.unlinkSync(lock);
|
|
560
|
+
}
|
|
561
|
+
catch { /* released */ }
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
// ── 서명 결정 레코드 검증 (설계 11 §3.3·§3.4·§3.5 계약 v2, P2-b) ─────────────────────────
|
|
565
|
+
// 레코드 전용 ed25519 공개키 **목록**(Grant 키와 별개 — Grant 키로 임의 claims 를 서명하면 Grant 위조 오라클).
|
|
566
|
+
// 배포 시 scripts/embed-pubkey.js 가 아래 문자열 리터럴(placeholder)을 env RECORD_ED25519_PUBLIC_KEYS 실값
|
|
567
|
+
// (`kid:b64,kid:b64` — 현재 키 + 교체 유예 중인 이전 키, §3.5 키 교체)으로, env 가 없으면 빈 문자열로 치환한다.
|
|
568
|
+
// 임베드 안 한 소스 빌드에선 placeholder(형식 아님) → 빈 목록 → 전부 proposed(fail-closed).
|
|
569
|
+
// 검증은 claims.kid 로 키를 고른다 — kid 없음·목록에 없는 kid = 거부.
|
|
570
|
+
// env 덮어쓰기(process.env.… ??) 형태는 쓰지 않는다 — 셸 rc 로 키를 바꿔 끼울 수 있게 되므로.
|
|
571
|
+
const RECORD_PUBKEYS_EMBED = "r1:MCowBQYDK2VwAyEAnGeoFEBt7YKUormYU4rE6NINbqLmNMHXZFB+3cMaC4M=";
|
|
572
|
+
let recordPubKeysOverride = null;
|
|
573
|
+
/** 테스트 전용(같은 프로세스 안에서만 유효 — 훅 프로세스·셸에서 바꿀 수 없다). 인자 = 키 목록(`kid:b64,…`). null 이면 임베드 목록으로 복귀 */
|
|
574
|
+
export function setRecordPubKeyForTests(k) {
|
|
575
|
+
recordPubKeysOverride = k;
|
|
576
|
+
}
|
|
577
|
+
function validB64Key(k) {
|
|
578
|
+
return k.length >= 40 && /^[A-Za-z0-9+/]+={0,2}$/.test(k);
|
|
579
|
+
}
|
|
580
|
+
const KID_RE = /^[A-Za-z0-9_.-]{1,32}$/;
|
|
581
|
+
const ringCache = new Map();
|
|
582
|
+
/**
|
|
583
|
+
* 키 목록 파싱 `kid:b64,kid:b64` → kid → 공개키(spki DER 또는 raw 32B, base64).
|
|
584
|
+
* 형식이 하나라도 틀리거나 같은 kid 가 두 번 나오면 **빈 목록**(fail-closed — 어느 키를 믿을지 모호하면 아무것도 믿지 않는다).
|
|
585
|
+
*/
|
|
586
|
+
export function parseKeyring(spec) {
|
|
587
|
+
const hit = ringCache.get(spec);
|
|
588
|
+
if (hit)
|
|
589
|
+
return hit;
|
|
590
|
+
const out = new Map();
|
|
591
|
+
let ok = true;
|
|
592
|
+
for (const part of String(spec || '').split(',').map(s => s.trim()).filter(Boolean)) {
|
|
593
|
+
const i = part.indexOf(':');
|
|
594
|
+
const kid = i > 0 ? part.slice(0, i) : '';
|
|
595
|
+
const key = i > 0 ? part.slice(i + 1) : '';
|
|
596
|
+
if (!KID_RE.test(kid) || !validB64Key(key) || out.has(kid)) {
|
|
597
|
+
ok = false;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
out.set(kid, key);
|
|
601
|
+
}
|
|
602
|
+
const ring = ok ? out : new Map();
|
|
603
|
+
ringCache.set(spec, ring);
|
|
604
|
+
return ring;
|
|
605
|
+
}
|
|
606
|
+
/** 임베드된 레코드 공개키 목록 원문 — 형식이 아니면 '' (= 검증 불가 = 전부 거부) */
|
|
607
|
+
export function recordPubKeys() {
|
|
608
|
+
const k = recordPubKeysOverride ?? RECORD_PUBKEYS_EMBED;
|
|
609
|
+
return parseKeyring(k).size ? k : '';
|
|
610
|
+
}
|
|
611
|
+
/** 서명 대상 = 키 정렬 JSON.stringify — 평평한 객체(문자열·숫자·null)만. 아니면 null(중첩·불리언·배열 거부) */
|
|
612
|
+
export function canonicalClaims(claims) {
|
|
613
|
+
if (!claims || typeof claims !== 'object' || Array.isArray(claims))
|
|
614
|
+
return null;
|
|
615
|
+
const o = claims;
|
|
616
|
+
for (const k of Object.keys(o)) {
|
|
617
|
+
const v = o[k];
|
|
618
|
+
if (v === null || typeof v === 'string' || (typeof v === 'number' && Number.isFinite(v)))
|
|
619
|
+
continue;
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
return JSON.stringify(o, Object.keys(o).sort());
|
|
623
|
+
}
|
|
624
|
+
/** 재귀 키 정렬 JSON (contentHash 직렬화 — 서버와 같은 함수). 배열 순서 유지, undefined 값 키는 생략 */
|
|
625
|
+
export function canonicalJson(v) {
|
|
626
|
+
if (v === null || v === undefined)
|
|
627
|
+
return 'null';
|
|
628
|
+
if (Array.isArray(v))
|
|
629
|
+
return '[' + v.map(x => canonicalJson(x === undefined ? null : x)).join(',') + ']';
|
|
630
|
+
if (typeof v === 'object') {
|
|
631
|
+
const o = v;
|
|
632
|
+
return '{' + Object.keys(o).sort().filter(k => o[k] !== undefined).map(k => JSON.stringify(k) + ':' + canonicalJson(o[k])).join(',') + '}';
|
|
633
|
+
}
|
|
634
|
+
return JSON.stringify(v);
|
|
635
|
+
}
|
|
636
|
+
export function sha256Hex(s) {
|
|
637
|
+
return crypto.createHash('sha256').update(s, 'utf8').digest('hex');
|
|
638
|
+
}
|
|
639
|
+
const CONSTRAINT_HASH_KEYS = ['id', 'target', 'rule', 'severity', 'enforce', 'message', 'why'];
|
|
640
|
+
function sortedStrings(v) {
|
|
641
|
+
const xs = (Array.isArray(v) ? v : [v]).filter((x) => typeof x === 'string');
|
|
642
|
+
return Array.from(new Set(xs)).sort();
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* 제약이 참조하는 baseline 정의(계약 v2 §3.5 `refs`): target.layer·rule.to.layer → layers.defs[name].match,
|
|
646
|
+
* rule.role → roles[role]. 평문 layers/roles 를 바꾸면 해시가 바뀌어 서명 승인이 무효(강등)가 된다(§3.4).
|
|
647
|
+
*/
|
|
648
|
+
export function constraintRefs(c, base) {
|
|
649
|
+
const o = c;
|
|
650
|
+
const defs = (base.layers && Array.isArray(base.layers.defs) ? base.layers.defs : null) ?? DEFAULT_LAYERS_LITE.defs;
|
|
651
|
+
const roles = { ...DEFAULT_ROLES_LITE, ...(base.roles && typeof base.roles === 'object' ? base.roles : {}) };
|
|
652
|
+
const layerNames = [o.target?.layer, o.rule?.to?.layer].filter((x) => typeof x === 'string' && x !== '');
|
|
653
|
+
const roleNames = [o.rule?.role].filter((x) => typeof x === 'string' && x !== '');
|
|
654
|
+
const layers = {};
|
|
655
|
+
for (const n of Array.from(new Set(layerNames)).sort()) {
|
|
656
|
+
const d = defs.find(x => x && x.name === n);
|
|
657
|
+
layers[n] = d ? sortedStrings(d.match) : null;
|
|
658
|
+
}
|
|
659
|
+
const rs = {};
|
|
660
|
+
for (const n of Array.from(new Set(roleNames)).sort())
|
|
661
|
+
rs[n] = Object.prototype.hasOwnProperty.call(roles, n) && Array.isArray(roles[n]) ? sortedStrings(roles[n]) : null;
|
|
662
|
+
return { layers, roles: rs };
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* 제약 contentHash(계약 v2) — `{id,target,rule,severity,enforce,message,why, refs}` 재귀 키 정렬 JSON 의 sha256.
|
|
666
|
+
* origin·상태 제외(승인 전후 불변). base = 그 제약이 들어 있는(들어갈) baseline.json 원본.
|
|
667
|
+
*/
|
|
668
|
+
export function contentHashConstraint(c, base) {
|
|
669
|
+
const o = c;
|
|
670
|
+
const pick = {};
|
|
671
|
+
for (const k of CONSTRAINT_HASH_KEYS)
|
|
672
|
+
if (o[k] !== undefined)
|
|
673
|
+
pick[k] = o[k];
|
|
674
|
+
pick.refs = constraintRefs(c, base);
|
|
675
|
+
return sha256Hex(canonicalJson(pick));
|
|
676
|
+
}
|
|
677
|
+
/** 제안 contentHash — id·type·targets([{file,name}])·action 만. 상태·origin·evidence·confidence·line 제외 */
|
|
678
|
+
export function contentHashProposal(p) {
|
|
679
|
+
return sha256Hex(canonicalJson({ id: p.id, type: p.type, targets: (p.targets ?? []).map(t => ({ file: t.file, name: t.name })), action: p.action }));
|
|
680
|
+
}
|
|
681
|
+
// ed25519 SPKI DER 접두(raw 32B 공개키 → spki)
|
|
682
|
+
const ED25519_SPKI_PREFIX = Buffer.from('302a300506032b6570032100', 'hex');
|
|
683
|
+
const keyCache = new Map();
|
|
684
|
+
function pubKeyObject(pubKeyB64) {
|
|
685
|
+
if (keyCache.has(pubKeyB64))
|
|
686
|
+
return keyCache.get(pubKeyB64);
|
|
687
|
+
let k = null;
|
|
688
|
+
try {
|
|
689
|
+
const der = Buffer.from(pubKeyB64, 'base64');
|
|
690
|
+
k = crypto.createPublicKey({ key: der.length === 32 ? Buffer.concat([ED25519_SPKI_PREFIX, der]) : der, format: 'der', type: 'spki' });
|
|
691
|
+
if (k.asymmetricKeyType !== 'ed25519')
|
|
692
|
+
k = null;
|
|
693
|
+
}
|
|
694
|
+
catch {
|
|
695
|
+
k = null;
|
|
696
|
+
}
|
|
697
|
+
keyCache.set(pubKeyB64, k);
|
|
698
|
+
return k;
|
|
699
|
+
}
|
|
700
|
+
function ringOf(keys) {
|
|
701
|
+
return typeof keys === 'string' ? parseKeyring(keys) : keys;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* 레코드 서명 검증 — 키 목록(`kid:b64,…` 또는 파싱된 Keyring)에서 claims.kid 의 키로 검증.
|
|
705
|
+
* 키 목록 없음·kid 없음·목록에 없는 kid·형식 오류·평평하지 않은 claims·kind 불일치 = false (fail-closed)
|
|
706
|
+
*/
|
|
707
|
+
export function verifyRecord(claims, sig, keys) {
|
|
708
|
+
if (typeof sig !== 'string' || !sig)
|
|
709
|
+
return false;
|
|
710
|
+
const ring = ringOf(keys);
|
|
711
|
+
if (!ring.size)
|
|
712
|
+
return false;
|
|
713
|
+
const can = canonicalClaims(claims);
|
|
714
|
+
if (can === null)
|
|
715
|
+
return false;
|
|
716
|
+
const c = claims;
|
|
717
|
+
if (c.kind !== 'config-approval' || typeof c.kid !== 'string')
|
|
718
|
+
return false;
|
|
719
|
+
const b64 = ring.get(c.kid);
|
|
720
|
+
if (!b64)
|
|
721
|
+
return false;
|
|
722
|
+
const key = pubKeyObject(b64);
|
|
723
|
+
if (!key)
|
|
724
|
+
return false;
|
|
725
|
+
try {
|
|
726
|
+
return crypto.verify(null, Buffer.from(can, 'utf8'), key, Buffer.from(sig, 'base64'));
|
|
727
|
+
}
|
|
728
|
+
catch {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
// ── 증명서 lib 번들 서명 검증 (설계 14 §11.1 — growth G2) ─────────────────────────────────
|
|
733
|
+
// 같은 레코드 키 목록으로 검증하되 서명 대상은 도메인 분리 페이로드 "rc-certlib-v1\n"+sha256(64 소문자 hex).
|
|
734
|
+
// 결정 레코드 서명 대상(canonicalClaims = '{' 로 시작하는 JSON)과 바이트가 겹칠 수 없어, 한쪽 서명이 다른 쪽으로 통과하지 않는다.
|
|
735
|
+
export const CERTLIB_SIG_DOMAIN = 'rc-certlib-v1\n';
|
|
736
|
+
const SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
737
|
+
/** 번들 다이제스트 서명 대상 바이트 — growth record-signing.service.certLibSigPayload 와 바이트 동일 */
|
|
738
|
+
export function certLibSigPayload(sha256) {
|
|
739
|
+
return Buffer.from(CERTLIB_SIG_DOMAIN + sha256, 'utf8');
|
|
740
|
+
}
|
|
741
|
+
/** 번들 다이제스트 서명 검증 — 키 목록 없음·kid 없음·목록에 없는 kid·형식 오류 = false (fail-closed) */
|
|
742
|
+
export function verifyCertLibSig(sha256, kid, sig, keys) {
|
|
743
|
+
if (typeof sha256 !== 'string' || !SHA256_HEX_RE.test(sha256))
|
|
744
|
+
return false;
|
|
745
|
+
if (typeof kid !== 'string' || !KID_RE.test(kid))
|
|
746
|
+
return false;
|
|
747
|
+
if (typeof sig !== 'string' || !sig)
|
|
748
|
+
return false;
|
|
749
|
+
const ring = ringOf(keys);
|
|
750
|
+
const b64 = ring.get(kid);
|
|
751
|
+
if (!b64)
|
|
752
|
+
return false;
|
|
753
|
+
const key = pubKeyObject(b64);
|
|
754
|
+
if (!key)
|
|
755
|
+
return false;
|
|
756
|
+
try {
|
|
757
|
+
return crypto.verify(null, certLibSigPayload(sha256), key, Buffer.from(sig, 'base64'));
|
|
758
|
+
}
|
|
759
|
+
catch {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
// ── 디자인 스킬 팩 서명 검증 (설계 23 §3·§5.1 — growth sign-skillpack) ─────────────────────────
|
|
764
|
+
// 같은 레코드 키 목록, 서명 대상은 도메인 분리 페이로드 "rc-skillpack-v1\n"+sha256. cert-lib·결정 레코드 서명과 서로 통과하지 않는다.
|
|
765
|
+
export const SKILLPACK_SIG_DOMAIN = 'rc-skillpack-v1\n';
|
|
766
|
+
/** 팩 다이제스트 서명 대상 바이트 — growth record-signing.service.signSkillPack·knowledge skill-pack.signer 와 바이트 동일 */
|
|
767
|
+
export function skillPackSigPayload(sha256) {
|
|
768
|
+
return Buffer.from(SKILLPACK_SIG_DOMAIN + sha256, 'utf8');
|
|
769
|
+
}
|
|
770
|
+
/** 팩 다이제스트 서명 검증 — verifyCertLibSig 와 같은 형태, 키 목록 없음·kid 없음·목록에 없는 kid·형식 오류 = false (fail-closed) */
|
|
771
|
+
export function verifySkillPackSig(sha256, kid, sig, keys) {
|
|
772
|
+
if (typeof sha256 !== 'string' || !SHA256_HEX_RE.test(sha256))
|
|
773
|
+
return false;
|
|
774
|
+
if (typeof kid !== 'string' || !KID_RE.test(kid))
|
|
775
|
+
return false;
|
|
776
|
+
if (typeof sig !== 'string' || !sig)
|
|
777
|
+
return false;
|
|
778
|
+
const ring = ringOf(keys);
|
|
779
|
+
const b64 = ring.get(kid);
|
|
780
|
+
if (!b64)
|
|
781
|
+
return false;
|
|
782
|
+
const key = pubKeyObject(b64);
|
|
783
|
+
if (!key)
|
|
784
|
+
return false;
|
|
785
|
+
try {
|
|
786
|
+
return crypto.verify(null, skillPackSigPayload(sha256), key, Buffer.from(sig, 'base64'));
|
|
787
|
+
}
|
|
788
|
+
catch {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
// ── 최신 판정 규칙 (계약 v2 §3.5 — 서버 K7 `latest-decision.ts` 와 같은 함수, 골든 벡터 공유) ─────────
|
|
793
|
+
// 같은 subject id 레코드를 (decidedAt 오름차순, 상태 우선순위 approved < deferred < rejected) 로 정렬해 마지막 1건.
|
|
794
|
+
// 같은 ms 동률이면 더 보수적인(권한을 낮추는) 상태가 이긴다. 두 키까지 같으면 입력 순서상 뒤의 것(안정 정렬).
|
|
795
|
+
// 최신 레코드의 contentHash ≠ 현재 대상 해시면 stale = 무효(승인으로 보지 않음).
|
|
796
|
+
export const DECISION_STATUS_PRIORITY = Object.freeze({ approved: 0, deferred: 1, rejected: 2 });
|
|
797
|
+
/** decidedAt → epoch ms. 파싱 불가면 -Infinity(가장 오래된 것 — 최신이 될 수 없음) */
|
|
798
|
+
function decisionTime(decidedAt) {
|
|
799
|
+
const t = typeof decidedAt === 'string' ? Date.parse(decidedAt) : NaN;
|
|
800
|
+
return Number.isNaN(t) ? Number.NEGATIVE_INFINITY : t;
|
|
801
|
+
}
|
|
802
|
+
/** 알 수 없는 상태는 가장 보수적(rejected 보다 위) — 이상 레코드가 승인을 이기지 못하게 */
|
|
803
|
+
function decisionPriority(status) {
|
|
804
|
+
const p = typeof status === 'string' ? DECISION_STATUS_PRIORITY[status] : undefined;
|
|
805
|
+
return p === undefined ? 3 : p;
|
|
806
|
+
}
|
|
807
|
+
/** (decidedAt, 상태 우선순위) 비교 — 같으면 0 */
|
|
808
|
+
export function compareDecisions(a, b) {
|
|
809
|
+
const ta = decisionTime(a.decidedAt);
|
|
810
|
+
const tb = decisionTime(b.decidedAt);
|
|
811
|
+
if (ta !== tb)
|
|
812
|
+
return ta < tb ? -1 : 1;
|
|
813
|
+
return decisionPriority(a.status) - decisionPriority(b.status);
|
|
814
|
+
}
|
|
815
|
+
/** 같은 subject id 레코드 중 최신 1건(없으면 null) — 완전 동률이면 뒤의 것 */
|
|
816
|
+
export function pickLatestDecision(records) {
|
|
817
|
+
let best = null;
|
|
818
|
+
for (const r of records)
|
|
819
|
+
if (best === null || compareDecisions(r, best) >= 0)
|
|
820
|
+
best = r;
|
|
821
|
+
return best;
|
|
822
|
+
}
|
|
823
|
+
/** 최신 판정 + stale(최신 결정의 contentHash ≠ 현재 해시 — 결정 없으면 false) */
|
|
824
|
+
export function judgeLatestDecision(records, currentContentHash) {
|
|
825
|
+
const decision = pickLatestDecision(records);
|
|
826
|
+
return { decision, stale: decision !== null && decision.contentHash !== currentContentHash };
|
|
827
|
+
}
|
|
828
|
+
/** 유효 승인 = 최신이 approved ∧ stale 아님 */
|
|
829
|
+
export function isEffectivelyApproved(records, currentContentHash) {
|
|
830
|
+
const { decision, stale } = judgeLatestDecision(records, currentContentHash);
|
|
831
|
+
return decision !== null && !stale && decision.status === 'approved';
|
|
832
|
+
}
|
|
833
|
+
export const DECISIONS_FILE = 'decisions.signed.jsonl';
|
|
834
|
+
export function decisionsPath(storeDir) {
|
|
835
|
+
return path.join(storeDir, DECISIONS_FILE);
|
|
836
|
+
}
|
|
837
|
+
// 프로세스 내 캐시: (경로, mtime, 크기, 내용 해시, 키 목록) — MCP 서버처럼 오래 사는 프로세스에서 재검증 생략.
|
|
838
|
+
// 디스크 캐시는 두지 않는다(캐시 파일을 위조하면 서명 검증을 건너뛸 수 있다 — 검증 비용은 레코드당 수십 µs).
|
|
839
|
+
const decisionsCache = new Map();
|
|
840
|
+
/** `<storeDir>/decisions.signed.jsonl` 로드·검증 — 손상 줄 무시. keys = 키 목록(`kid:b64,…`) */
|
|
841
|
+
export function loadSignedDecisions(storeDir, keys = recordPubKeys()) {
|
|
842
|
+
const p = decisionsPath(storeDir);
|
|
843
|
+
const empty = () => ({ all: [], valid: [], validRecs: [] });
|
|
844
|
+
let st;
|
|
845
|
+
try {
|
|
846
|
+
st = fs.statSync(p);
|
|
847
|
+
}
|
|
848
|
+
catch {
|
|
849
|
+
return empty();
|
|
850
|
+
}
|
|
851
|
+
const stamp = `${st.mtimeMs}|${st.size}|${keys}`;
|
|
852
|
+
let text = '';
|
|
853
|
+
try {
|
|
854
|
+
text = fs.readFileSync(p, 'utf-8');
|
|
855
|
+
}
|
|
856
|
+
catch {
|
|
857
|
+
return empty();
|
|
858
|
+
}
|
|
859
|
+
const hash = sha256Hex(text);
|
|
860
|
+
const hit = decisionsCache.get(p);
|
|
861
|
+
if (hit && hit.stamp === stamp && hit.hash === hash)
|
|
862
|
+
return hit.value;
|
|
863
|
+
const ring = parseKeyring(keys);
|
|
864
|
+
const value = empty();
|
|
865
|
+
for (const ln of text.split('\n')) {
|
|
866
|
+
if (!ln.trim())
|
|
867
|
+
continue;
|
|
868
|
+
let r;
|
|
869
|
+
try {
|
|
870
|
+
r = JSON.parse(ln);
|
|
871
|
+
}
|
|
872
|
+
catch {
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
if (!r || typeof r !== 'object' || !r.claims || typeof r.sig !== 'string')
|
|
876
|
+
continue;
|
|
877
|
+
value.all.push(r);
|
|
878
|
+
if (verifyRecord(r.claims, r.sig, ring)) {
|
|
879
|
+
value.valid.push(r.claims);
|
|
880
|
+
value.validRecs.push(r);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
decisionsCache.set(p, { stamp, hash, value });
|
|
884
|
+
return value;
|
|
885
|
+
}
|
|
886
|
+
function trustUserId(opts) {
|
|
887
|
+
if (opts.userId !== undefined)
|
|
888
|
+
return opts.userId === null || opts.userId === '' ? null : String(opts.userId);
|
|
889
|
+
const u = readJson(rcConfigPath())?.userId;
|
|
890
|
+
return u === undefined || u === null || u === '' ? null : String(u);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* 이 지도(storeDir)에 속한 서명 검증 레코드 — 유효 = 서명(kid) 검증 ∧ subject 일치 ∧ repoId·scopeRel 이 meta.json 과 일치
|
|
894
|
+
* (다른 레포 레코드 재사용 방지) ∧ 소유자 일치. subject id → 레코드들(파일 순서).
|
|
895
|
+
*/
|
|
896
|
+
export function signedRecordsFor(storeDir, subject, opts = {}) {
|
|
897
|
+
const out = new Map();
|
|
898
|
+
const keys = opts.pubKey ?? recordPubKeys();
|
|
899
|
+
if (!parseKeyring(keys).size)
|
|
900
|
+
return out;
|
|
901
|
+
const { validRecs } = loadSignedDecisions(storeDir, keys);
|
|
902
|
+
if (!validRecs.length)
|
|
903
|
+
return out;
|
|
904
|
+
const meta = readRepoMeta(storeDir);
|
|
905
|
+
if (typeof meta.repoId !== 'string' || !meta.repoId)
|
|
906
|
+
return out;
|
|
907
|
+
const scopeRel = typeof meta.scopeRel === 'string' ? meta.scopeRel : '';
|
|
908
|
+
const uid = trustUserId(opts);
|
|
909
|
+
if (!uid)
|
|
910
|
+
return out;
|
|
911
|
+
const idKey = subject === 'constraint' ? 'constraintId' : 'proposalId';
|
|
912
|
+
for (const r of validRecs) {
|
|
913
|
+
const c = r.claims;
|
|
914
|
+
const id = c[idKey];
|
|
915
|
+
if (c.subject !== subject || typeof id !== 'string' || typeof c.decidedAt !== 'string' || typeof c.contentHash !== 'string')
|
|
916
|
+
continue;
|
|
917
|
+
if (c.repoId !== meta.repoId || (c.scopeRel ?? '') !== scopeRel)
|
|
918
|
+
continue;
|
|
919
|
+
if (String(c.ownerUserId) !== uid)
|
|
920
|
+
continue;
|
|
921
|
+
const arr = out.get(id) ?? [];
|
|
922
|
+
arr.push(r);
|
|
923
|
+
out.set(id, arr);
|
|
924
|
+
}
|
|
925
|
+
return out;
|
|
926
|
+
}
|
|
927
|
+
/** 서명(kid) 검증 ∧ 이 지도의 레코드(repoId·scopeRel = meta.json, 소유자 일치)인가 — 서버 결정 반영(applyServerDecision)의 관문 */
|
|
928
|
+
export function recordTrusted(storeDir, rec, opts = {}) {
|
|
929
|
+
if (!rec || typeof rec !== 'object')
|
|
930
|
+
return false;
|
|
931
|
+
if (!verifyRecord(rec.claims, rec.sig, opts.pubKey ?? recordPubKeys()))
|
|
932
|
+
return false;
|
|
933
|
+
const c = rec.claims;
|
|
934
|
+
const meta = readRepoMeta(storeDir);
|
|
935
|
+
if (typeof meta.repoId !== 'string' || !meta.repoId)
|
|
936
|
+
return false;
|
|
937
|
+
if (c.repoId !== meta.repoId || (c.scopeRel ?? '') !== (typeof meta.scopeRel === 'string' ? meta.scopeRel : ''))
|
|
938
|
+
return false;
|
|
939
|
+
const uid = trustUserId(opts);
|
|
940
|
+
// 소유자를 모르면 불신(fail-closed) — signedRecordsFor 와 같은 규칙
|
|
941
|
+
return !!uid && String(c.ownerUserId) === uid;
|
|
942
|
+
}
|
|
943
|
+
/** 이 지도의 제약 결정 — constraintId → 최신 판정(§3.5) 유효 레코드 claims */
|
|
944
|
+
export function constraintDecisions(storeDir, opts = {}) {
|
|
945
|
+
const out = new Map();
|
|
946
|
+
for (const [id, recs] of signedRecordsFor(storeDir, 'constraint', opts)) {
|
|
947
|
+
const latest = pickLatestDecision(recs.map(r => r.claims));
|
|
948
|
+
if (latest)
|
|
949
|
+
out.set(id, latest);
|
|
950
|
+
}
|
|
951
|
+
return out;
|
|
952
|
+
}
|
|
953
|
+
function readBaselineRaw(storeDir) {
|
|
954
|
+
const b = readJson(path.join(storeDir, 'baseline.json'));
|
|
955
|
+
return b && typeof b === 'object' ? b : null;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* 집행 근거 적용: 최신(§3.5) 유효 레코드가 approved ∧ contentHash(refs 포함) 일치인 제약만 origin:'user', 나머지 user 는 proposed 로 강등.
|
|
959
|
+
* (contentHash 는 origin 을 빼고 계산하므로 승인 전 proposed 였던 제약도 서명 승인이 있으면 user.)
|
|
960
|
+
* base = baseline.json 원본(refs 계산) — 없으면 storeDir 에서 읽는다.
|
|
961
|
+
*/
|
|
962
|
+
export function applyRecordTrust(constraints, storeDir, opts = {}, base) {
|
|
963
|
+
const decisions = constraintDecisions(storeDir, opts);
|
|
964
|
+
const src = base ?? readBaselineRaw(storeDir) ?? {};
|
|
965
|
+
const demoted = [];
|
|
966
|
+
const promoted = [];
|
|
967
|
+
const out = constraints.map(c => {
|
|
968
|
+
if (!c || typeof c !== 'object')
|
|
969
|
+
return c;
|
|
970
|
+
const d = decisions.get(c.id);
|
|
971
|
+
const signed = !!d && d.status === 'approved' && d.contentHash === contentHashConstraint(c, src);
|
|
972
|
+
if (signed) {
|
|
973
|
+
if (c.origin !== 'user')
|
|
974
|
+
promoted.push(c.id);
|
|
975
|
+
return c.origin === 'user' ? c : { ...c, origin: 'user' };
|
|
976
|
+
}
|
|
977
|
+
if (c.origin === 'user') {
|
|
978
|
+
demoted.push(c.id);
|
|
979
|
+
return { ...c, origin: 'proposed' };
|
|
980
|
+
}
|
|
981
|
+
return c;
|
|
982
|
+
});
|
|
983
|
+
return { constraints: out, demoted, promoted };
|
|
984
|
+
}
|
|
985
|
+
/** baseline.json 의 `origin:'user'` 중 서명 승인이 없는 제약(기존 user 제약 이행 고지·`--migrate` 대상) */
|
|
986
|
+
export function unsignedUserConstraints(storeDir, opts = {}) {
|
|
987
|
+
const b = readBaselineRaw(storeDir);
|
|
988
|
+
if (!b || !Array.isArray(b.constraints))
|
|
989
|
+
return [];
|
|
990
|
+
const raw = b.constraints.filter(c => c && typeof c === 'object' && typeof c.id === 'string');
|
|
991
|
+
const { demoted } = applyRecordTrust(raw, storeDir, opts, b);
|
|
992
|
+
const set = new Set(demoted);
|
|
993
|
+
return raw.filter(c => set.has(c.id));
|
|
994
|
+
}
|
|
995
|
+
// ── 타입 플래그 이벤트 (설계 10 §9 — 서버 미배포 동안 append 자체를 하지 않는다) ──────────────
|
|
996
|
+
/** 타입 플래그(방출 시점 판정) — remote-flags.json flags.raw_type_<type>, 부재 = off */
|
|
997
|
+
export function typeFlagOn(type, flagsPath = path.join(homeDir(), '.routinecode', 'remote-flags.json')) {
|
|
998
|
+
const d = readJson(flagsPath);
|
|
999
|
+
return d?.flags?.[`raw_type_${type}`] === true;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* 정비 러너(ROUTINECODE_MAINTENANCE=1) 세션 id 앞 12자 — sync_manager._runner_session_id 와 같은 규칙:
|
|
1003
|
+
* env ROUTINECODE_MAINTENANCE_SESSION_ID 우선, 없으면 ~/.routinecode/maintenance/sessions 의 마지막 항목. 러너 밖이면 null.
|
|
1004
|
+
* session 없는 이벤트를 러너 세션으로 채워 업로드 제외(설계 11 §4.2-3)가 걸리게 한다.
|
|
1005
|
+
*/
|
|
1006
|
+
export function runnerSessionId() {
|
|
1007
|
+
if (process.env.ROUTINECODE_MAINTENANCE !== '1')
|
|
1008
|
+
return null;
|
|
1009
|
+
const env = (process.env.ROUTINECODE_MAINTENANCE_SESSION_ID ?? '').trim();
|
|
1010
|
+
if (env)
|
|
1011
|
+
return env.slice(0, 12);
|
|
1012
|
+
try {
|
|
1013
|
+
const lines = fs.readFileSync(path.join(homeDir(), '.routinecode', 'maintenance', 'sessions'), 'utf-8').split('\n').map(x => x.trim()).filter(Boolean);
|
|
1014
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
1015
|
+
let v = lines[i];
|
|
1016
|
+
if (v.startsWith('{')) {
|
|
1017
|
+
try {
|
|
1018
|
+
const o = JSON.parse(v);
|
|
1019
|
+
v = String(o.session ?? o.sessionId ?? '');
|
|
1020
|
+
}
|
|
1021
|
+
catch {
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
if (v)
|
|
1026
|
+
return v.slice(0, 12);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
catch { /* 목록 없음 */ }
|
|
1030
|
+
return null;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* emit_raw.py 와 같은 봉투로 usage events.jsonl 에 append — 플래그 off 면 아무것도 쓰지 않는다(fail-open, 예외 없음).
|
|
1034
|
+
* 메타는 호출자가 화이트리스트(sync_manager.RAW_METADATA_KEYS)와 같은 키만 넘긴다.
|
|
1035
|
+
*/
|
|
1036
|
+
export function emitTypedEvent(type, metadata, session = 'unknown', opts = {}) {
|
|
1037
|
+
try {
|
|
1038
|
+
if (!typeFlagOn(type, opts.flagsPath))
|
|
1039
|
+
return false;
|
|
1040
|
+
const eventsPath = opts.eventsPath ?? path.join(homeDir(), '.routinecode', 'usage', 'events.jsonl');
|
|
1041
|
+
const at = new Date().toISOString().replace('Z', '+00:00');
|
|
1042
|
+
const sess = session && session !== 'unknown' ? session : (runnerSessionId() ?? 'unknown');
|
|
1043
|
+
const ev = { at, date: at.slice(0, 10), session: String(sess || 'unknown').slice(0, 12) || 'unknown', type, value: 1, metadata: { ...metadata } };
|
|
1044
|
+
fs.mkdirSync(path.dirname(eventsPath), { recursive: true });
|
|
1045
|
+
fs.appendFileSync(eventsPath, JSON.stringify(ev) + '\n');
|
|
1046
|
+
return true;
|
|
1047
|
+
}
|
|
1048
|
+
catch {
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1051
|
+
}
|