mcp-efficiency-engine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +40 -0
- package/.github/GITHUB_MCP_INTEGRATION.md +366 -0
- package/.github/ISSUE_TEMPLATE/bug.md +51 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +45 -0
- package/.github/ISSUE_TEMPLATE/question.md +18 -0
- package/.github/agents/backend.agent.md +18 -0
- package/.github/agents/community-manager.agent.md +18 -0
- package/.github/agents/dba.agent.md +18 -0
- package/.github/agents/frontend-agent.agent.md +18 -0
- package/.github/agents/github-repository-manager.agent.md +338 -0
- package/.github/agents/iot.agent.md +20 -0
- package/.github/agents/legacy.agent.md +18 -0
- package/.github/agents/rag-azure.agent.md +18 -0
- package/.github/agents/rag-local.agent.md +18 -0
- package/.github/agents/snapshot.agent.md +18 -0
- package/.github/agents/ux-ui.agent.md +18 -0
- package/.github/agents/wiki-agent.agent.md +23 -0
- package/.github/copilot-instructions.md +44 -0
- package/.github/instructions/always-on-optimization.instructions.md +54 -0
- package/.github/prompts/auto-route.prompt.md +33 -0
- package/.github/prompts/azure-rag.query.prompt.md +19 -0
- package/.github/prompts/backend.fix-bug.prompt.md +13 -0
- package/.github/prompts/cavecrew.prompt.md +16 -0
- package/.github/prompts/caveman-commit.prompt.md +14 -0
- package/.github/prompts/caveman-compress.prompt.md +15 -0
- package/.github/prompts/caveman-debug.prompt.md +13 -0
- package/.github/prompts/caveman-help.prompt.md +11 -0
- package/.github/prompts/caveman-review.prompt.md +15 -0
- package/.github/prompts/caveman-stats.prompt.md +11 -0
- package/.github/prompts/caveman.prompt.md +11 -0
- package/.github/prompts/community.post.prompt.md +14 -0
- package/.github/prompts/dba.query-review.prompt.md +15 -0
- package/.github/prompts/dev.fix-bug.prompt.md +13 -0
- package/.github/prompts/frontend.code.prompt.md +13 -0
- package/.github/prompts/legacy.impact-analysis.prompt.md +14 -0
- package/.github/prompts/project.kickoff-analysis.prompt.md +51 -0
- package/.github/prompts/rag.knowledge-answer.prompt.md +13 -0
- package/.github/prompts/token-saver-review.prompt.md +14 -0
- package/.github/prompts/ux-ui.review.prompt.md +14 -0
- package/.github/pull_request_template.md +71 -0
- package/.github/skills/ahorro-tokens/SKILL.md +36 -0
- package/.github/skills/azure-rag-enterprise/SKILL.md +24 -0
- package/.github/skills/backend-coding/SKILL.md +24 -0
- package/.github/skills/cavecrew/SKILL.md +17 -0
- package/.github/skills/caveman/SKILL.md +25 -0
- package/.github/skills/caveman-commit/SKILL.md +15 -0
- package/.github/skills/caveman-compress/SKILL.md +14 -0
- package/.github/skills/caveman-help/SKILL.md +19 -0
- package/.github/skills/caveman-mode/SKILL.md +43 -0
- package/.github/skills/caveman-review/SKILL.md +16 -0
- package/.github/skills/caveman-stats/SKILL.md +13 -0
- package/.github/skills/community-content/SKILL.md +22 -0
- package/.github/skills/database-analysis/SKILL.md +23 -0
- package/.github/skills/dev-coding/SKILL.md +24 -0
- package/.github/skills/frontend-coding/SKILL.md +24 -0
- package/.github/skills/human-in-the-loop/SKILL.md +47 -0
- package/.github/skills/iot-architecture/SKILL.md +22 -0
- package/.github/skills/legacy-migration/SKILL.md +22 -0
- package/.github/skills/rag-knowledge/SKILL.md +21 -0
- package/.github/skills/token-saver/SKILL.md +36 -0
- package/.github/skills/ux-ui-governance/SKILL.md +24 -0
- package/.github/skills/wiki-tools.json +24 -0
- package/.github/workflows/auto-devlog.yml +56 -0
- package/.github/workflows/auto-manage-issues.yml +64 -0
- package/.github/workflows/auto-sync.yml +54 -0
- package/.github/workflows/autodocs-sync.yml +114 -0
- package/.github/workflows/ci.yml +68 -0
- package/.github/workflows/pages.yml +59 -0
- package/.github/workflows/routing-evals.yml +59 -0
- package/.github/workflows/techriders-coverage-effective.yml +91 -0
- package/.vscode/mcp.json +44 -0
- package/AGENTS.md +160 -0
- package/ARCHITECTURE.md +57 -0
- package/FINAL_USAGE_GUIDE.md +106 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/README_WIKI.md +130 -0
- package/autodocs/README.md +22 -0
- package/autodocs/schema/wiki-node.schema.json +56 -0
- package/autolearning/feedback-loop.md +90 -0
- package/bin/install-host.js +326 -0
- package/bin/mcpee.js +116 -0
- package/context/repomix/repomix.config.json +20 -0
- package/memory/cross-memory-reasoning.md +17 -0
- package/memory/mempry-registry.yml +16 -0
- package/observability/evals/chat-token-usage-report.json +64 -0
- package/observability/evals/chat-token-usage-report.md +33 -0
- package/observability/evals/iteration-value-report.json +76 -0
- package/observability/evals/iteration-value-report.md +39 -0
- package/observability/evals/learning-loop-report.json +268 -0
- package/observability/evals/learning-loop-report.md +37 -0
- package/observability/evals/repo-intake-eval-cases.md +23 -0
- package/observability/evals/routing-eval-cases.json +68 -0
- package/observability/evals/routing-eval-cases.md +25 -0
- package/observability/evals/routing-eval-report.json +72 -0
- package/observability/evaluation.md +34 -0
- package/observability/logs/copilot-usage-ingest-report.json +13 -0
- package/observability/logs/iteration-metrics.jsonl +75 -0
- package/observability/logs/learning-feedback.jsonl +152 -0
- package/observability/logs/routing-decisions.jsonl +333 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-004146.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-005554.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-010351.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-145829.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-150021.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-154328.log +8 -0
- package/observability/logs/session/bye-20260629-221513.json +39 -0
- package/observability/logs/session/bye-20260629-221545.json +59 -0
- package/observability/logs/session/bye-20260629-222007.json +52 -0
- package/observability/logs/session/bye-20260629-222133.json +59 -0
- package/observability/logs/session/bye-20260629-222412.json +45 -0
- package/observability/logs/session/bye-20260629-223224.json +52 -0
- package/observability/logs/session/bye-20260629-224050.json +59 -0
- package/observability/logs/session/bye-20260630-105732.json +24 -0
- package/observability/logs/session/bye-20260630-211536.json +87 -0
- package/observability/logs/session/bye-20260630-223423.json +87 -0
- package/observability/logs/session/bye-20260630-232534.json +87 -0
- package/observability/logs/session/bye-20260701-003638.json +126 -0
- package/observability/logs/session/bye-20260701-003849.json +126 -0
- package/observability/logs/session/bye-20260701-004315.json +138 -0
- package/observability/logs/session/bye-20260701-004559.json +76 -0
- package/observability/logs/session/bye-20260701-005913.json +138 -0
- package/observability/logs/session/bye-20260701-010753.json +138 -0
- package/observability/logs/session/bye-20260703-194106.json +24 -0
- package/observability/logs/session/bye-20260703-233443.json +76 -0
- package/observability/logs/session/bye-20260703-233653.json +76 -0
- package/observability/logs/session/bye-20260704-150317.json +152 -0
- package/observability/logs/session/bye-20260704-150929.json +75 -0
- package/observability/logs/session/bye-20260704-151050.json +75 -0
- package/observability/logs/session/bye-20260705-115458.json +165 -0
- package/observability/logs/session/codegraph-status-20260701-004228.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-004310.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005637.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005908.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010444.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010747.log +39 -0
- package/observability/logs/session/codegraph-status-20260704-150137.log +26 -0
- package/observability/logs/session/codegraph-status-20260704-150313.log +28 -0
- package/observability/logs/session/codegraph-status-20260704-154445.log +26 -0
- package/observability/logs/session/codegraph-status-20260705-115454.log +27 -0
- package/observability/logs/session/codegraph-sync-20260701-004211.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-004241.log +82 -0
- package/observability/logs/session/codegraph-sync-20260701-005620.log +89 -0
- package/observability/logs/session/codegraph-sync-20260701-005840.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-010419.log +93 -0
- package/observability/logs/session/codegraph-sync-20260701-010609.log +90 -0
- package/observability/logs/session/codegraph-sync-20260704-145856.log +70 -0
- package/observability/logs/session/codegraph-sync-20260704-150047.log +53 -0
- package/observability/logs/session/codegraph-sync-20260704-150204.log +44 -0
- package/observability/logs/session/codegraph-sync-20260704-154353.log +26 -0
- package/observability/logs/session/codegraph-sync-20260705-115337.log +32 -0
- package/observability/logs/session/hi-20260629-221459.json +38 -0
- package/observability/logs/session/hi-20260629-221945.json +59 -0
- package/observability/logs/session/hi-20260629-222108.json +66 -0
- package/observability/logs/session/hi-20260629-222352.json +45 -0
- package/observability/logs/session/hi-20260629-225719.json +59 -0
- package/observability/logs/session/hi-20260629-233722.json +52 -0
- package/observability/logs/session/hi-20260629-233913.json +198 -0
- package/observability/logs/session/hi-20260630-110156.json +177 -0
- package/observability/logs/session/hi-20260630-191243.json +184 -0
- package/observability/logs/session/hi-20260630-230050.json +234 -0
- package/observability/logs/session/hi-20260630-230523.json +227 -0
- package/observability/logs/session/hi-20260630-230855.json +227 -0
- package/observability/logs/session/hi-20260630-231638.json +227 -0
- package/observability/logs/session/hi-20260630-231756.json +219 -0
- package/observability/logs/session/hi-20260701-002842.json +234 -0
- package/observability/logs/session/hi-20260701-003458.json +282 -0
- package/observability/logs/session/hi-20260701-004233.json +290 -0
- package/observability/logs/session/hi-20260701-004554.json +236 -0
- package/observability/logs/session/hi-20260701-005641.json +290 -0
- package/observability/logs/session/hi-20260701-010450.json +290 -0
- package/observability/logs/session/hi-20260703-233854.json +312 -0
- package/observability/logs/session/hi-20260703-234448.json +318 -0
- package/observability/logs/session/hi-20260704-145907.json +353 -0
- package/observability/logs/session/hi-20260704-150141.json +392 -0
- package/observability/logs/session/hi-20260704-154448.json +392 -0
- package/observability/logs/session/iteration-value-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-005907.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-010747.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260704-150312.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260705-115453.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-005906.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-010745.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260704-150309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260705-115450.log +3 -0
- package/observability/logs/session/project-notes-refresh-20260701-004227.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-004308.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005636.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005906.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010443.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010744.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150133.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150309.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-154442.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260705-115449.log +1 -0
- package/observability/logs/session/repo-intake-20260701-004218.log +6 -0
- package/observability/logs/session/repo-intake-20260701-005626.log +6 -0
- package/observability/logs/session/repo-intake-20260701-010433.log +6 -0
- package/observability/logs/session/repo-intake-20260704-150053.log +6 -0
- package/observability/logs/session/repo-intake-20260704-154404.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-004247.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-005847.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-010615.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260704-150209.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260705-115342.log +6 -0
- package/observability/logs/session/repo-registry-validation-20260701-004234.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-004556.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-005833.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-010601.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260704-150155.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260705-115323.log +2 -0
- package/observability/logs/session/repomix-refresh-20260701-003823.log +4236 -0
- package/observability/logs/session/repomix-refresh-20260701-004251.log +4275 -0
- package/observability/logs/session/repomix-refresh-20260701-005850.log +4248 -0
- package/observability/logs/session/repomix-refresh-20260701-010619.log +6531 -0
- package/observability/logs/session/repomix-refresh-20260704-150239.log +652 -0
- package/observability/logs/session/repomix-refresh-20260705-115419.log +178 -0
- package/observability/logs/session/routing-evals-20260701-004221.log +2 -0
- package/observability/logs/session/routing-evals-20260701-004235.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005629.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005834.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010437.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010603.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150125.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150157.log +2 -0
- package/observability/logs/session/routing-evals-20260704-154434.log +2 -0
- package/observability/logs/session/routing-evals-20260705-115327.log +2 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-004250.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-005850.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-010618.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260704-150238.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260705-115418.log +3 -0
- package/observability/logs.schema.json +95 -0
- package/observability/logs.schema.md +26 -0
- package/observability/metrics.md +35 -0
- package/observability/routing-evaluator.md +37 -0
- package/observability/scoring-rubric.md +38 -0
- package/optimization/ALWAYS_ON_OPTIMIZATION.md +98 -0
- package/optimization/caveman-mode.md +62 -0
- package/optimization/examples/login-bug.md +25 -0
- package/optimization/examples/sla-query.md +25 -0
- package/optimization/optimization-routing.md +30 -0
- package/optimization/policies/response-style.policy.md +45 -0
- package/optimization/policies/token-budget.policy.md +28 -0
- package/optimization/profiles/always-on.profile.md +19 -0
- package/optimization/profiles/architecture.profile.md +20 -0
- package/optimization/profiles/debug.profile.md +20 -0
- package/optimization/profiles/enterprise-rag.profile.md +20 -0
- package/optimization/profiles/training.profile.md +20 -0
- package/optimization/token-saver.md +58 -0
- package/orchestrator/corporate-routing.md +51 -0
- package/orchestrator/decision-matrix.md +33 -0
- package/orchestrator/fallback.md +29 -0
- package/orchestrator/repo-routing.md +58 -0
- package/orchestrator/router.md +75 -0
- package/orchestrator/wiki/__init__.py +5 -0
- package/orchestrator/wiki/graph_consolidator.py +506 -0
- package/orchestrator/wiki/incremental_engine.py +57 -0
- package/orchestrator/wiki/plugin_manager.py +40 -0
- package/package.json +70 -0
- package/policies/context-policy.md +25 -0
- package/policies/cost-policy.md +25 -0
- package/policies/repo-intake-policy.md +36 -0
- package/policies/security-policy.md +25 -0
- package/repo-intake/README.md +81 -0
- package/repo-intake/templates/agent.template.md +4 -0
- package/repo-intake/templates/context-manifest.template.md +4 -0
- package/repo-intake/templates/skill.template.md +3 -0
- package/repo-registry/repos.schema.json +102 -0
- package/repo-registry/repos.template.json +26 -0
- package/requirements.txt +1 -0
- package/scripts/README.md +109 -0
- package/scripts/__init__.py +0 -0
- package/scripts/bootstrap-portable.cmd +4 -0
- package/scripts/bootstrap-portable.ps1 +90 -0
- package/scripts/context/azure-rag-mcp-adapter.py +1 -0
- package/scripts/context/build-graphify.ps1 +1 -0
- package/scripts/context/build-repomix.ps1 +1 -0
- package/scripts/discovery/discover-boost-repos.cmd +4 -0
- package/scripts/discovery/discover-boost-repos.py +186 -0
- package/scripts/discovery/refresh-project-notes.py +179 -0
- package/scripts/github/INSTALL.md +295 -0
- package/scripts/github/README.md +455 -0
- package/scripts/github/apply-boost-templates.ps1 +163 -0
- package/scripts/github/apply-single-repo.ps1 +85 -0
- package/scripts/github/create-devlog.ps1 +380 -0
- package/scripts/github/manage-issues.ps1 +332 -0
- package/scripts/github/sync-repo.ps1 +267 -0
- package/scripts/intake/agent-pipeline-preflight.py +151 -0
- package/scripts/intake/init-template-registry.cmd +4 -0
- package/scripts/intake/init-template-registry.ps1 +258 -0
- package/scripts/intake/repo-intake.py +354 -0
- package/scripts/intake/resolve-routing.py +620 -0
- package/scripts/intake/run-repo-intake.cmd +4 -0
- package/scripts/intake/run-repo-intake.ps1 +46 -0
- package/scripts/intake/run-routing-evals.py +147 -0
- package/scripts/intake/validate-database-routing.py +91 -0
- package/scripts/intake/validate-rag-routing.py +85 -0
- package/scripts/intake/validate-repo-registry.ps1 +20 -0
- package/scripts/intake/validate-repo-registry.py +286 -0
- package/scripts/intake/validate-security.py +170 -0
- package/scripts/learning/autolearning-gate.py +71 -0
- package/scripts/learning/chat-token-usage-report.py +326 -0
- package/scripts/learning/ingest-copilot-session-usage.py +421 -0
- package/scripts/learning/iteration-value-report.py +275 -0
- package/scripts/learning/learning-loop-report.py +272 -0
- package/scripts/learning/record-iteration-metrics.py +116 -0
- package/scripts/learning/record-learning-feedback.py +91 -0
- package/scripts/ops/bye.ps1 +620 -0
- package/scripts/ops/compare-demo-results.ps1 +826 -0
- package/scripts/ops/demo1.ps1 +11 -0
- package/scripts/ops/demo2.ps1 +11 -0
- package/scripts/ops/demo3.ps1 +11 -0
- package/scripts/ops/demo4.ps1 +11 -0
- package/scripts/ops/hi.ps1 +1045 -0
- package/scripts/ops/llm-token-probe.py +164 -0
- package/scripts/ops/run-all-demos.ps1 +39 -0
- package/scripts/ops/run-demo-block.ps1 +85 -0
- package/scripts/ops/run-demo-session.ps1 +532 -0
- package/scripts/setup/optimize-engines.ps1 +183 -0
- package/scripts/setup/setup-codegraph.ps1 +3 -0
- package/scripts/setup/setup-gitnexus.ps1 +3 -0
- package/scripts/setup/setup-graphify.ps1 +2 -0
- package/scripts/setup/setup-prerequisites.ps1 +205 -0
- package/scripts/setup/start-gitnexus.ps1 +71 -0
- package/scripts/setup/validate-context.ps1 +361 -0
- package/scripts/wiki/__init__.py +0 -0
- package/scripts/wiki/compiler_main.py +189 -0
- package/scripts/wiki/normalizer.py +206 -0
- package/scripts/wiki/providers/base_provider.py +25 -0
- package/scripts/wiki/providers/codegraph_provider.py +49 -0
- package/scripts/wiki/providers/graphify_provider.py +49 -0
- package/scripts/wiki/providers/repo_content_provider.py +408 -0
- package/scripts/wiki/query_autodocs.py +60 -0
- package/scripts/wiki/validator.py +183 -0
- package/scripts/wiki/wiki_compiler.py +5 -0
- package/specs/architecture.spec.md +32 -0
- package/specs/azure-rag.spec.md +28 -0
- package/specs/coding-standards.spec.md +24 -0
- package/specs/database.spec.md +29 -0
- package/specs/migration.spec.md +26 -0
- package/specs/observability.spec.md +24 -0
- package/specs/optimization.spec.md +31 -0
- package/specs/rag.spec.md +30 -0
- package/specs/repo-intake.spec.md +25 -0
- package/specs/routing.spec.md +24 -0
- package/specs/security.spec.md +30 -0
- package/specs/wiki/provider-contract.json +33 -0
- package/specs/wiki/unified-knowledge-graph.json +25 -0
- package/templates/BOOST_README_TEMPLATE.md +96 -0
- package/templates/CODEOWNERS_TEMPLATE.txt +29 -0
- package/templates/LICENSE_MIT_TEMPLATE.txt +21 -0
- package/templates/PERSONAL_README_TEMPLATE.md +90 -0
- package/templates/README_boost_RAG_Azure.md +46 -0
- package/templates/README_boost_azure_iot_edge.md +48 -0
- package/templates/README_boost_backend.md +47 -0
- package/templates/README_boost_dba.md +57 -0
- package/templates/ci.yml.template +73 -0
- package/tooling/tooling.manifest.json +72 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from collections import defaultdict
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def utc_now() -> str:
|
|
12
|
+
return datetime.now(timezone.utc).isoformat()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def pct(n: float) -> float:
|
|
16
|
+
return round(n * 100.0, 2)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def safe_rate(num: int, den: int) -> float:
|
|
20
|
+
if den <= 0:
|
|
21
|
+
return 0.0
|
|
22
|
+
return num / den
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def parse_events(path: Path) -> list[dict[str, Any]]:
|
|
26
|
+
if not path.exists():
|
|
27
|
+
return []
|
|
28
|
+
|
|
29
|
+
events: list[dict[str, Any]] = []
|
|
30
|
+
for line in path.read_text(encoding="utf-8").splitlines():
|
|
31
|
+
line = line.strip()
|
|
32
|
+
if not line:
|
|
33
|
+
continue
|
|
34
|
+
try:
|
|
35
|
+
obj = json.loads(line)
|
|
36
|
+
except Exception:
|
|
37
|
+
continue
|
|
38
|
+
if isinstance(obj, dict):
|
|
39
|
+
events.append(obj)
|
|
40
|
+
return events
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def parse_feedback(path: Path) -> dict[str, dict[str, Any]]:
|
|
44
|
+
latest_by_event: dict[str, dict[str, Any]] = {}
|
|
45
|
+
if not path.exists():
|
|
46
|
+
return latest_by_event
|
|
47
|
+
|
|
48
|
+
for line in path.read_text(encoding="utf-8").splitlines():
|
|
49
|
+
line = line.strip()
|
|
50
|
+
if not line:
|
|
51
|
+
continue
|
|
52
|
+
try:
|
|
53
|
+
obj = json.loads(line)
|
|
54
|
+
except Exception:
|
|
55
|
+
continue
|
|
56
|
+
if not isinstance(obj, dict):
|
|
57
|
+
continue
|
|
58
|
+
event_id = str(obj.get("event_id", "")).strip()
|
|
59
|
+
if not event_id:
|
|
60
|
+
continue
|
|
61
|
+
latest_by_event[event_id] = obj
|
|
62
|
+
return latest_by_event
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def build_report(
|
|
66
|
+
events: list[dict[str, Any]], source_path: str, feedback_by_event: dict[str, dict[str, Any]], feedback_source: str
|
|
67
|
+
) -> dict[str, Any]:
|
|
68
|
+
total = len(events)
|
|
69
|
+
fallback_count = 0
|
|
70
|
+
grounded_count = 0
|
|
71
|
+
confirmed_count = 0
|
|
72
|
+
success_count = 0
|
|
73
|
+
pending_count = 0
|
|
74
|
+
confidence_sum = 0.0
|
|
75
|
+
confidence_count = 0
|
|
76
|
+
|
|
77
|
+
by_pattern: dict[str, dict[str, Any]] = defaultdict(
|
|
78
|
+
lambda: {
|
|
79
|
+
"total": 0,
|
|
80
|
+
"fallback": 0,
|
|
81
|
+
"grounded": 0,
|
|
82
|
+
"success": 0,
|
|
83
|
+
"pending": 0,
|
|
84
|
+
"confirmed": 0,
|
|
85
|
+
"confidence_sum": 0.0,
|
|
86
|
+
"confidence_count": 0,
|
|
87
|
+
"engines": defaultdict(int),
|
|
88
|
+
"agents": defaultdict(int),
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
for e in events:
|
|
93
|
+
fb = bool(e.get("fallback", False))
|
|
94
|
+
gr = bool(e.get("grounded", False))
|
|
95
|
+
learning = e.get("learning", {}) if isinstance(e.get("learning", {}), dict) else {}
|
|
96
|
+
event_id = str(e.get("event_id", "")).strip()
|
|
97
|
+
|
|
98
|
+
feedback_obj = feedback_by_event.get(event_id, {}) if event_id else {}
|
|
99
|
+
feedback_learning = feedback_obj.get("learning", {}) if isinstance(feedback_obj.get("learning", {}), dict) else {}
|
|
100
|
+
|
|
101
|
+
# Source of truth: confirmed feedback overrides provisional learning state.
|
|
102
|
+
if feedback_learning:
|
|
103
|
+
success_raw = feedback_learning.get("success")
|
|
104
|
+
outcome_status = str(feedback_learning.get("outcome_status", "confirmed"))
|
|
105
|
+
confidence = feedback_learning.get("confidence")
|
|
106
|
+
else:
|
|
107
|
+
success_raw = learning.get("success")
|
|
108
|
+
outcome_status = str(learning.get("outcome_status", "pending"))
|
|
109
|
+
confidence = learning.get("confidence")
|
|
110
|
+
|
|
111
|
+
is_confirmed = outcome_status == "confirmed" and isinstance(success_raw, bool)
|
|
112
|
+
is_pending = not is_confirmed
|
|
113
|
+
success = bool(success_raw) if is_confirmed else False
|
|
114
|
+
|
|
115
|
+
pattern = str(learning.get("used_pattern", "unknown"))
|
|
116
|
+
engine = str(e.get("engine", "unknown"))
|
|
117
|
+
agent = str(e.get("agent", "unknown"))
|
|
118
|
+
|
|
119
|
+
fallback_count += 1 if fb else 0
|
|
120
|
+
grounded_count += 1 if gr else 0
|
|
121
|
+
pending_count += 1 if is_pending else 0
|
|
122
|
+
confirmed_count += 1 if is_confirmed else 0
|
|
123
|
+
success_count += 1 if (is_confirmed and success) else 0
|
|
124
|
+
|
|
125
|
+
if is_confirmed and isinstance(confidence, (int, float)):
|
|
126
|
+
confidence_sum += float(confidence)
|
|
127
|
+
confidence_count += 1
|
|
128
|
+
|
|
129
|
+
p = by_pattern[pattern]
|
|
130
|
+
p["total"] += 1
|
|
131
|
+
p["fallback"] += 1 if fb else 0
|
|
132
|
+
p["grounded"] += 1 if gr else 0
|
|
133
|
+
p["pending"] += 1 if is_pending else 0
|
|
134
|
+
p["confirmed"] += 1 if is_confirmed else 0
|
|
135
|
+
p["success"] += 1 if (is_confirmed and success) else 0
|
|
136
|
+
if is_confirmed and isinstance(confidence, (int, float)):
|
|
137
|
+
p["confidence_sum"] += float(confidence)
|
|
138
|
+
p["confidence_count"] += 1
|
|
139
|
+
p["engines"][engine] += 1
|
|
140
|
+
p["agents"][agent] += 1
|
|
141
|
+
|
|
142
|
+
patterns_out: list[dict[str, Any]] = []
|
|
143
|
+
for pattern, data in sorted(by_pattern.items(), key=lambda kv: kv[0]):
|
|
144
|
+
den = int(data["total"])
|
|
145
|
+
c_count = int(data["confidence_count"])
|
|
146
|
+
c_avg = round((float(data["confidence_sum"]) / c_count), 3) if c_count else 0.0
|
|
147
|
+
patterns_out.append(
|
|
148
|
+
{
|
|
149
|
+
"pattern": pattern,
|
|
150
|
+
"total": den,
|
|
151
|
+
"fallback_rate": round(safe_rate(int(data["fallback"]), den), 4),
|
|
152
|
+
"grounded_rate": round(safe_rate(int(data["grounded"]), den), 4),
|
|
153
|
+
"pending_count": int(data["pending"]),
|
|
154
|
+
"confirmed_count": int(data["confirmed"]),
|
|
155
|
+
"success_rate": round(safe_rate(int(data["success"]), int(data["confirmed"])), 4),
|
|
156
|
+
"confidence_avg": c_avg,
|
|
157
|
+
"engines": dict(sorted(data["engines"].items())),
|
|
158
|
+
"agents": dict(sorted(data["agents"].items())),
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
global_confidence_avg = round((confidence_sum / confidence_count), 3) if confidence_count else 0.0
|
|
163
|
+
report = {
|
|
164
|
+
"timestamp": utc_now(),
|
|
165
|
+
"source": source_path,
|
|
166
|
+
"feedback_source": feedback_source,
|
|
167
|
+
"total_events": total,
|
|
168
|
+
"pending_events": pending_count,
|
|
169
|
+
"confirmed_events": confirmed_count,
|
|
170
|
+
"kpis": {
|
|
171
|
+
"fallback_rate": round(safe_rate(fallback_count, total), 4),
|
|
172
|
+
"grounded_rate": round(safe_rate(grounded_count, total), 4),
|
|
173
|
+
"success_rate": round(safe_rate(success_count, confirmed_count), 4),
|
|
174
|
+
"confidence_avg": global_confidence_avg,
|
|
175
|
+
},
|
|
176
|
+
"thresholds": {
|
|
177
|
+
"fallback_rate_max": 0.20,
|
|
178
|
+
"grounded_rate_min": 0.80,
|
|
179
|
+
"confidence_avg_min": 0.80,
|
|
180
|
+
},
|
|
181
|
+
"health": {
|
|
182
|
+
"fallback_ok": round(safe_rate(fallback_count, total), 4) <= 0.20,
|
|
183
|
+
"grounded_ok": round(safe_rate(grounded_count, total), 4) >= 0.80,
|
|
184
|
+
"confidence_ok": global_confidence_avg >= 0.80,
|
|
185
|
+
},
|
|
186
|
+
"patterns": patterns_out,
|
|
187
|
+
}
|
|
188
|
+
return report
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def report_to_markdown(report: dict[str, Any]) -> str:
|
|
192
|
+
total = int(report.get("total_events", 0))
|
|
193
|
+
pending = int(report.get("pending_events", 0))
|
|
194
|
+
confirmed = int(report.get("confirmed_events", 0))
|
|
195
|
+
kpis = report.get("kpis", {}) if isinstance(report.get("kpis", {}), dict) else {}
|
|
196
|
+
health = report.get("health", {}) if isinstance(report.get("health", {}), dict) else {}
|
|
197
|
+
patterns = report.get("patterns", []) if isinstance(report.get("patterns", []), list) else []
|
|
198
|
+
|
|
199
|
+
lines = [
|
|
200
|
+
"# Learning Loop Report",
|
|
201
|
+
"",
|
|
202
|
+
f"- timestamp: {report.get('timestamp', '')}",
|
|
203
|
+
f"- total_events: {total}",
|
|
204
|
+
f"- pending_events: {pending}",
|
|
205
|
+
f"- confirmed_events: {confirmed}",
|
|
206
|
+
"",
|
|
207
|
+
"## Global KPIs",
|
|
208
|
+
"",
|
|
209
|
+
f"- fallback_rate: {pct(float(kpis.get('fallback_rate', 0.0)))}%",
|
|
210
|
+
f"- grounded_rate: {pct(float(kpis.get('grounded_rate', 0.0)))}%",
|
|
211
|
+
f"- success_rate: {pct(float(kpis.get('success_rate', 0.0)))}%",
|
|
212
|
+
f"- confidence_avg: {kpis.get('confidence_avg', 0.0)}",
|
|
213
|
+
"",
|
|
214
|
+
"## Health",
|
|
215
|
+
"",
|
|
216
|
+
f"- fallback_ok: {health.get('fallback_ok', False)}",
|
|
217
|
+
f"- grounded_ok: {health.get('grounded_ok', False)}",
|
|
218
|
+
f"- confidence_ok: {health.get('confidence_ok', False)}",
|
|
219
|
+
"",
|
|
220
|
+
"## Patterns",
|
|
221
|
+
"",
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
if not patterns:
|
|
225
|
+
lines.append("- none")
|
|
226
|
+
else:
|
|
227
|
+
for p in patterns:
|
|
228
|
+
lines.append(
|
|
229
|
+
f"- {p.get('pattern', 'unknown')}: total={p.get('total', 0)}, "
|
|
230
|
+
f"pending={p.get('pending_count', 0)}, "
|
|
231
|
+
f"confirmed={p.get('confirmed_count', 0)}, "
|
|
232
|
+
f"fallback={pct(float(p.get('fallback_rate', 0.0)))}%, "
|
|
233
|
+
f"grounded={pct(float(p.get('grounded_rate', 0.0)))}%, "
|
|
234
|
+
f"confidence={p.get('confidence_avg', 0.0)}"
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
lines.append("")
|
|
238
|
+
return "\n".join(lines)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def main() -> int:
|
|
242
|
+
parser = argparse.ArgumentParser(description="Build learning loop report from routing decisions log.")
|
|
243
|
+
parser.add_argument("--input", default="observability/logs/routing-decisions.jsonl")
|
|
244
|
+
parser.add_argument("--feedback", default="observability/logs/learning-feedback.jsonl")
|
|
245
|
+
parser.add_argument("--out-json", default="observability/evals/learning-loop-report.json")
|
|
246
|
+
parser.add_argument("--out-md", default="observability/evals/learning-loop-report.md")
|
|
247
|
+
args = parser.parse_args()
|
|
248
|
+
|
|
249
|
+
repo_root = Path(__file__).resolve().parents[2]
|
|
250
|
+
in_path = (repo_root / args.input).resolve()
|
|
251
|
+
feedback_path = (repo_root / args.feedback).resolve()
|
|
252
|
+
out_json = (repo_root / args.out_json).resolve()
|
|
253
|
+
out_md = (repo_root / args.out_md).resolve()
|
|
254
|
+
|
|
255
|
+
events = parse_events(in_path)
|
|
256
|
+
feedback = parse_feedback(feedback_path)
|
|
257
|
+
report = build_report(events, str(in_path), feedback, str(feedback_path))
|
|
258
|
+
|
|
259
|
+
out_json.parent.mkdir(parents=True, exist_ok=True)
|
|
260
|
+
out_md.parent.mkdir(parents=True, exist_ok=True)
|
|
261
|
+
|
|
262
|
+
out_json.write_text(json.dumps(report, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
263
|
+
out_md.write_text(report_to_markdown(report), encoding="utf-8")
|
|
264
|
+
|
|
265
|
+
print(f"Learning events processed: {len(events)}")
|
|
266
|
+
print(f"Report JSON: {out_json}")
|
|
267
|
+
print(f"Report MD: {out_md}")
|
|
268
|
+
return 0
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def utc_now() -> str:
|
|
11
|
+
return datetime.now(timezone.utc).isoformat()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_jsonl(path: Path) -> list[dict[str, Any]]:
|
|
15
|
+
if not path.exists():
|
|
16
|
+
return []
|
|
17
|
+
rows: list[dict[str, Any]] = []
|
|
18
|
+
for line in path.read_text(encoding="utf-8").splitlines():
|
|
19
|
+
line = line.strip()
|
|
20
|
+
if not line:
|
|
21
|
+
continue
|
|
22
|
+
try:
|
|
23
|
+
obj = json.loads(line)
|
|
24
|
+
except Exception:
|
|
25
|
+
continue
|
|
26
|
+
if isinstance(obj, dict):
|
|
27
|
+
rows.append(obj)
|
|
28
|
+
return rows
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def latest_event_id(events: list[dict[str, Any]]) -> str | None:
|
|
32
|
+
for e in reversed(events):
|
|
33
|
+
event_id = str(e.get("event_id", "")).strip()
|
|
34
|
+
if event_id:
|
|
35
|
+
return event_id
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main() -> int:
|
|
40
|
+
parser = argparse.ArgumentParser(description="Record per-iteration cost and execution metrics for a routing event.")
|
|
41
|
+
parser.add_argument("--event-id", default="", help="Routing event_id. If omitted, uses latest routing event with event_id.")
|
|
42
|
+
parser.add_argument("--model", required=True, help="Model used in the iteration, e.g. GPT-5.3-Codex")
|
|
43
|
+
parser.add_argument("--input-tokens", type=int, required=True)
|
|
44
|
+
parser.add_argument("--output-tokens", type=int, required=True)
|
|
45
|
+
parser.add_argument("--local-tools", type=int, default=0, help="Count of local tools used")
|
|
46
|
+
parser.add_argument("--remote-tools", type=int, default=0, help="Count of remote/cloud tools used")
|
|
47
|
+
parser.add_argument("--estimated-cost-usd", type=float, default=0.0)
|
|
48
|
+
parser.add_argument("--notes", default="")
|
|
49
|
+
parser.add_argument("--routing-log", default="observability/logs/routing-decisions.jsonl")
|
|
50
|
+
parser.add_argument("--output", default="observability/logs/iteration-metrics.jsonl")
|
|
51
|
+
args = parser.parse_args()
|
|
52
|
+
|
|
53
|
+
if args.input_tokens < 0 or args.output_tokens < 0:
|
|
54
|
+
print("input/output tokens must be >= 0")
|
|
55
|
+
return 1
|
|
56
|
+
if args.local_tools < 0 or args.remote_tools < 0:
|
|
57
|
+
print("tool counters must be >= 0")
|
|
58
|
+
return 1
|
|
59
|
+
if args.estimated_cost_usd < 0:
|
|
60
|
+
print("estimated-cost-usd must be >= 0")
|
|
61
|
+
return 1
|
|
62
|
+
|
|
63
|
+
repo_root = Path(__file__).resolve().parents[2]
|
|
64
|
+
routing_log = (repo_root / args.routing_log).resolve()
|
|
65
|
+
output_path = (repo_root / args.output).resolve()
|
|
66
|
+
|
|
67
|
+
events = parse_jsonl(routing_log)
|
|
68
|
+
event_id = args.event_id.strip() or (latest_event_id(events) or "")
|
|
69
|
+
if not event_id:
|
|
70
|
+
print("No event_id provided and no eligible routing events found.")
|
|
71
|
+
return 1
|
|
72
|
+
|
|
73
|
+
exists = any(str(e.get("event_id", "")).strip() == event_id for e in events)
|
|
74
|
+
if not exists:
|
|
75
|
+
print(f"event_id not found in routing log: {event_id}")
|
|
76
|
+
return 1
|
|
77
|
+
|
|
78
|
+
total_tokens = args.input_tokens + args.output_tokens
|
|
79
|
+
if args.local_tools > 0 and args.remote_tools == 0:
|
|
80
|
+
tool_mode = "local-only"
|
|
81
|
+
elif args.local_tools == 0 and args.remote_tools > 0:
|
|
82
|
+
tool_mode = "remote-only"
|
|
83
|
+
elif args.local_tools > 0 and args.remote_tools > 0:
|
|
84
|
+
tool_mode = "hybrid"
|
|
85
|
+
else:
|
|
86
|
+
tool_mode = "model-only"
|
|
87
|
+
|
|
88
|
+
metric = {
|
|
89
|
+
"timestamp": utc_now(),
|
|
90
|
+
"event_id": event_id,
|
|
91
|
+
"model": args.model,
|
|
92
|
+
"cost": {
|
|
93
|
+
"input_tokens": args.input_tokens,
|
|
94
|
+
"output_tokens": args.output_tokens,
|
|
95
|
+
"total_tokens": total_tokens,
|
|
96
|
+
"estimated_cost_usd": round(float(args.estimated_cost_usd), 6),
|
|
97
|
+
},
|
|
98
|
+
"execution": {
|
|
99
|
+
"local_tools": args.local_tools,
|
|
100
|
+
"remote_tools": args.remote_tools,
|
|
101
|
+
"tool_mode": tool_mode,
|
|
102
|
+
},
|
|
103
|
+
"notes": args.notes,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
with output_path.open("a", encoding="utf-8") as fh:
|
|
108
|
+
fh.write(json.dumps(metric, ensure_ascii=False) + "\n")
|
|
109
|
+
|
|
110
|
+
print(f"Iteration metrics recorded for event_id: {event_id}")
|
|
111
|
+
print(f"Output: {output_path}")
|
|
112
|
+
return 0
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def utc_now() -> str:
|
|
11
|
+
return datetime.now(timezone.utc).isoformat()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_jsonl(path: Path) -> list[dict[str, Any]]:
|
|
15
|
+
if not path.exists():
|
|
16
|
+
return []
|
|
17
|
+
rows: list[dict[str, Any]] = []
|
|
18
|
+
for line in path.read_text(encoding="utf-8").splitlines():
|
|
19
|
+
line = line.strip()
|
|
20
|
+
if not line:
|
|
21
|
+
continue
|
|
22
|
+
try:
|
|
23
|
+
obj = json.loads(line)
|
|
24
|
+
except Exception:
|
|
25
|
+
continue
|
|
26
|
+
if isinstance(obj, dict):
|
|
27
|
+
rows.append(obj)
|
|
28
|
+
return rows
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def latest_event_id(events: list[dict[str, Any]]) -> str | None:
|
|
32
|
+
for e in reversed(events):
|
|
33
|
+
event_id = str(e.get("event_id", "")).strip()
|
|
34
|
+
if event_id:
|
|
35
|
+
return event_id
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main() -> int:
|
|
40
|
+
parser = argparse.ArgumentParser(description="Record real execution feedback for a routing event.")
|
|
41
|
+
parser.add_argument("--event-id", default="", help="Routing event_id to confirm. If omitted, uses latest event with event_id.")
|
|
42
|
+
parser.add_argument("--success", required=True, choices=["true", "false"], help="Real execution outcome.")
|
|
43
|
+
parser.add_argument("--confidence", type=float, default=0.9, help="Confidence in the feedback (0..1).")
|
|
44
|
+
parser.add_argument("--source", default="human", help="Feedback source: human|ci|runtime|other")
|
|
45
|
+
parser.add_argument("--notes", default="", help="Optional notes")
|
|
46
|
+
parser.add_argument("--routing-log", default="observability/logs/routing-decisions.jsonl")
|
|
47
|
+
parser.add_argument("--output", default="observability/logs/learning-feedback.jsonl")
|
|
48
|
+
args = parser.parse_args()
|
|
49
|
+
|
|
50
|
+
if args.confidence < 0 or args.confidence > 1:
|
|
51
|
+
print("confidence must be between 0 and 1")
|
|
52
|
+
return 1
|
|
53
|
+
|
|
54
|
+
repo_root = Path(__file__).resolve().parents[2]
|
|
55
|
+
routing_log = (repo_root / args.routing_log).resolve()
|
|
56
|
+
output_path = (repo_root / args.output).resolve()
|
|
57
|
+
|
|
58
|
+
events = parse_jsonl(routing_log)
|
|
59
|
+
event_id = args.event_id.strip() or (latest_event_id(events) or "")
|
|
60
|
+
if not event_id:
|
|
61
|
+
print("No event_id provided and no eligible routing events found.")
|
|
62
|
+
return 1
|
|
63
|
+
|
|
64
|
+
exists = any(str(e.get("event_id", "")).strip() == event_id for e in events)
|
|
65
|
+
if not exists:
|
|
66
|
+
print(f"event_id not found in routing log: {event_id}")
|
|
67
|
+
return 1
|
|
68
|
+
|
|
69
|
+
feedback = {
|
|
70
|
+
"timestamp": utc_now(),
|
|
71
|
+
"event_id": event_id,
|
|
72
|
+
"learning": {
|
|
73
|
+
"success": True if args.success == "true" else False,
|
|
74
|
+
"outcome_status": "confirmed",
|
|
75
|
+
"confidence": round(float(args.confidence), 3),
|
|
76
|
+
"feedback_source": args.source,
|
|
77
|
+
"notes": args.notes,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
82
|
+
with output_path.open("a", encoding="utf-8") as fh:
|
|
83
|
+
fh.write(json.dumps(feedback, ensure_ascii=False) + "\n")
|
|
84
|
+
|
|
85
|
+
print(f"Feedback recorded for event_id: {event_id}")
|
|
86
|
+
print(f"Output: {output_path}")
|
|
87
|
+
return 0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
raise SystemExit(main())
|