Skip to content

Commit 3de90a7

Browse files
committed
Scientra Copilot V2.6
1 parent d63481d commit 3de90a7

45 files changed

Lines changed: 5988 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Scripts/check_environment.py‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
"""P6.6.1 Environment Check. Usage:
3+
python Scripts/check_environment.py
4+
python Scripts/check_environment.py --json
5+
python Scripts/check_environment.py --verbose
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import argparse
11+
import json
12+
import sys
13+
from pathlib import Path
14+
15+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
16+
17+
18+
def main() -> int:
19+
p = argparse.ArgumentParser(description="P6.6.1 Environment Check")
20+
p.add_argument("--json", action="store_true", help="Output as JSON")
21+
p.add_argument("--verbose", action="store_true", help="Show all details")
22+
p.add_argument("--root", type=Path, default=None, help="Project root path")
23+
args = p.parse_args()
24+
25+
from scientra.environment.diagnostics import run_diagnostics
26+
from scientra.environment.repair import generate_repair_suggestions
27+
28+
diag = run_diagnostics(args.root)
29+
repair = generate_repair_suggestions(args.root)
30+
31+
if args.json:
32+
output = {**diag, "repair_suggestions": repair}
33+
print(json.dumps(output, ensure_ascii=False, indent=2))
34+
if diag["failed"] > 0:
35+
return 1
36+
return 0
37+
38+
# Text output
39+
score = diag["health_score"]
40+
status = diag["status"]
41+
icon = "🟢" if status == "healthy" else ("🟡" if status == "degraded" else "🔴")
42+
43+
print(f"\n{'='*55}")
44+
print(f" Scientra Copilot — Environment Check")
45+
print(f" {icon} Health Score: {score}/100 ({status.upper()})")
46+
print(f"{'='*55}")
47+
print(f"\n ✅ {diag['passed']} passed ⚠️ {diag['warnings']} warnings ❌ {diag['failed']} failed ℹ️ {diag['info']} info\n")
48+
49+
for c in diag["checks"]:
50+
icon_map = {"PASS": "✅", "WARN": "⚠️ ", "FAIL": "❌", "INFO": "ℹ️ "}
51+
icon_c = icon_map.get(c["status"], "❓")
52+
print(f" {icon_c} {c['name']}: {c.get('detail', '')[:100]}")
53+
if args.verbose and c.get("fix"):
54+
print(f" Fix: {c['fix']}")
55+
56+
if repair:
57+
print(f"\n {'─'*50}")
58+
print(f" Repair Suggestions ({len(repair)} issues):")
59+
for s in repair:
60+
sev = "🔴" if s["severity"] == "FAIL" else "🟡"
61+
print(f" {sev} {s['problem']}: {s['fix'][:120]}")
62+
63+
print(f"\n Full report: python Scripts/health_report.py\n")
64+
65+
return 1 if diag["failed"] > 0 else 0
66+
67+
68+
if __name__ == "__main__":
69+
raise SystemExit(main())

‎Scripts/health_report.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
"""P6.6.1 Health Report Generator. Usage:
3+
python Scripts/health_report.py
4+
python Scripts/health_report.py --json
5+
"""
6+
7+
from __future__ import annotations
8+
9+
import argparse
10+
import sys
11+
from pathlib import Path
12+
13+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
14+
15+
16+
def main() -> int:
17+
p = argparse.ArgumentParser(description="P6.6.1 Health Report Generator")
18+
p.add_argument("--json", action="store_true", help="Output report paths as JSON")
19+
p.add_argument("--root", type=Path, default=None, help="Project root path")
20+
args = p.parse_args()
21+
22+
from scientra.environment.report_builder import build_all_health_reports
23+
from scientra.environment.diagnostics import run_diagnostics
24+
25+
reports = build_all_health_reports(args.root)
26+
diag = run_diagnostics(args.root)
27+
28+
if args.json:
29+
import json
30+
print(json.dumps({
31+
"health_score": diag["health_score"],
32+
"status": diag["status"],
33+
"reports": reports,
34+
}, ensure_ascii=False, indent=2))
35+
return 0
36+
37+
score = diag["health_score"]
38+
status = diag["status"]
39+
icon = "🟢" if status == "healthy" else ("🟡" if status == "degraded" else "🔴")
40+
41+
print(f"\n{'='*55}")
42+
print(f" Scientra Copilot — Health Report")
43+
print(f" {icon} Score: {score}/100 — {status.upper()}")
44+
print(f"{'='*55}")
45+
print(f"\n Reports generated:")
46+
for name, path in reports.items():
47+
print(f" {path}")
48+
print(f"\n ✅ {diag['passed']} passed ⚠️ {diag['warnings']} warnings ❌ {diag['failed']} failed")
49+
print()
50+
51+
return 0
52+
53+
54+
if __name__ == "__main__":
55+
raise SystemExit(main())

‎Scripts/repair_environment.py‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
"""P6.6.1 Repair Suggestions. Usage:
3+
python Scripts/repair_environment.py
4+
python Scripts/repair_environment.py --json
5+
"""
6+
7+
from __future__ import annotations
8+
9+
import argparse
10+
import json
11+
import sys
12+
from pathlib import Path
13+
14+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
15+
16+
17+
def main() -> int:
18+
p = argparse.ArgumentParser(description="P6.6.1 Repair Suggestions")
19+
p.add_argument("--json", action="store_true")
20+
p.add_argument("--root", type=Path, default=None)
21+
args = p.parse_args()
22+
23+
from scientra.environment.repair import generate_repair_report
24+
25+
report = generate_repair_report(args.root)
26+
27+
if args.json:
28+
print(json.dumps(report, ensure_ascii=False, indent=2))
29+
return 0
30+
31+
print(f"\n{'='*55}")
32+
print(f" Scientra Copilot — Repair Suggestions")
33+
print(f" {report['critical']} critical, {report['warnings']} warnings")
34+
print(f"{'='*55}\n")
35+
36+
if not report["suggestions"]:
37+
print(" ✅ No issues found! Your environment is ready.\n")
38+
return 0
39+
40+
for s in report["suggestions"]:
41+
sev = "🔴 CRITICAL" if s["severity"] == "FAIL" else "🟡 WARNING"
42+
print(f" {sev}: {s['problem']}")
43+
print(f" Cause: {s.get('cause', 'Unknown')}")
44+
print(f" Fix: {s.get('fix', 'No fix available')}")
45+
print()
46+
47+
return 0
48+
49+
50+
if __name__ == "__main__":
51+
raise SystemExit(main())

‎Scripts/run_benchmark.py‎

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/usr/bin/env python
2+
"""P6.5 Performance Benchmark & Runtime Profiling. Usage:
3+
python Scripts/run_benchmark.py --all --verbose
4+
python Scripts/run_benchmark.py --modules --queries --graph
5+
python Scripts/run_benchmark.py --large-file --max-synthetic-rows 100000
6+
python Scripts/run_benchmark.py --agent --json
7+
python Scripts/run_benchmark.py --all --skip-large-file --export
8+
"""
9+
10+
from __future__ import annotations
11+
12+
import argparse
13+
import json
14+
import sys
15+
from pathlib import Path
16+
17+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
18+
19+
20+
def build_arg_parser() -> argparse.ArgumentParser:
21+
p = argparse.ArgumentParser(
22+
description="P6.5 Performance Benchmark & Runtime Profiling",
23+
)
24+
# Category flags
25+
p.add_argument("--all", action="store_true", help="Run all benchmarks")
26+
p.add_argument("--modules", action="store_true", help="Run module loading benchmark")
27+
p.add_argument("--queries", action="store_true", help="Run query latency benchmark")
28+
p.add_argument("--graph", action="store_true", help="Run graph benchmark")
29+
p.add_argument("--datasets", action="store_true", help="Run dataset benchmark")
30+
p.add_argument("--agent", action="store_true", help="Run agent benchmark (evidence_only)")
31+
p.add_argument("--large-file", action="store_true", help="Run large-file safety benchmark")
32+
33+
# Skip flags
34+
p.add_argument("--skip-modules", action="store_true")
35+
p.add_argument("--skip-queries", action="store_true")
36+
p.add_argument("--skip-graph", action="store_true")
37+
p.add_argument("--skip-datasets", action="store_true")
38+
p.add_argument("--skip-agent", action="store_true")
39+
p.add_argument("--skip-large-file", action="store_true")
40+
p.add_argument("--skip-vector", action="store_true", help="Skip vector search in queries")
41+
42+
# Options
43+
p.add_argument("--include-llm", action="store_true", help="Allow LLM usage in agent benchmark")
44+
p.add_argument("--max-synthetic-rows", type=int, default=100_000,
45+
help="Max synthetic CSV rows for large-file test (default: 100000)")
46+
p.add_argument("--root", type=Path, default=None, help="Project root path")
47+
p.add_argument("--json", action="store_true", help="Output results as JSON")
48+
p.add_argument("--verbose", action="store_true", help="Verbose output")
49+
p.add_argument("--export", action="store_true", help="Export results to 09_Exports/benchmarks/")
50+
51+
return p
52+
53+
54+
def main() -> int:
55+
args = build_arg_parser().parse_args()
56+
57+
from scientra.benchmark.benchmark_runner import BenchmarkRunner
58+
from scientra.benchmark.benchmark_report_builder import _serialize_run
59+
60+
# Determine what to run
61+
run_all = args.all
62+
if not any([run_all, args.modules, args.queries, args.graph, args.datasets, args.agent, args.large_file]):
63+
# If no specific flag, default to --all
64+
run_all = True
65+
66+
runner = BenchmarkRunner(root=args.root)
67+
68+
try:
69+
benchmark_run = runner.run_all(
70+
skip_modules=args.skip_modules or (not run_all and not args.modules),
71+
skip_queries=args.skip_queries or (not run_all and not args.queries),
72+
skip_graph=args.skip_graph or (not run_all and not args.graph),
73+
skip_datasets=args.skip_datasets or (not run_all and not args.datasets),
74+
skip_agent=args.skip_agent or (not run_all and not args.agent),
75+
skip_large_file=args.skip_large_file or (not run_all and not args.large_file),
76+
include_llm=args.include_llm,
77+
max_synthetic_rows=args.max_synthetic_rows,
78+
keep_synthetic_files=True,
79+
)
80+
except Exception as exc:
81+
print(f"Fatal benchmark error: {exc}", file=sys.stderr)
82+
return 1
83+
84+
# Generate reports
85+
try:
86+
reports = runner.generate_reports()
87+
except Exception as exc:
88+
print(f"Warning: Report generation failed: {exc}", file=sys.stderr)
89+
reports = {}
90+
91+
# Export if requested
92+
if args.export:
93+
try:
94+
exported = runner.export_results()
95+
if args.verbose:
96+
for path, name in exported.items():
97+
print(f" Exported: {path}")
98+
except Exception as exc:
99+
print(f"Warning: Export failed: {exc}", file=sys.stderr)
100+
101+
# Output
102+
if args.json:
103+
print(json.dumps(_serialize_run(benchmark_run), ensure_ascii=False, indent=2))
104+
else:
105+
print(f"\n{'='*60}")
106+
print(f" Scientra Copilot P6.5 Performance Benchmark")
107+
print(f" Run ID: {benchmark_run.run_id}")
108+
print(f" Duration: {benchmark_run.total_duration_ms:.1f} ms")
109+
print(f"{'='*60}")
110+
print(f"\n Summary:")
111+
print(f" Tasks: {benchmark_run.total_tasks}")
112+
print(f" Passed: {benchmark_run.total_passed} ✅")
113+
print(f" Warnings: {benchmark_run.total_warnings} ⚠️")
114+
print(f" Failed: {benchmark_run.total_failed} ❌")
115+
print(f"\n Slowest Module: {benchmark_run.slowest_module} ({benchmark_run.slowest_module_ms:.1f} ms)")
116+
print(f" Slowest Query: {benchmark_run.slowest_query} ({benchmark_run.slowest_query_ms:.1f} ms)")
117+
print(f" Large-File Safety: {'✅ Passed' if benchmark_run.large_file_safety_passed else '❌ Failed'}")
118+
119+
if args.verbose:
120+
print(f"\n Per-Category Results:")
121+
for key, result in benchmark_run.results.items():
122+
status = "✅" if result.success else "❌"
123+
print(f" [{status}] {key}: {result.passed} passed, {result.warning_count} warnings, {result.failed} failed ({result.total_duration_ms:.1f} ms)")
124+
125+
if benchmark_run.cache_recommendations:
126+
print(f"\n Cache Recommendations ({len(benchmark_run.cache_recommendations)}):")
127+
for rec in benchmark_run.cache_recommendations[:5]:
128+
print(f" [{rec['priority']}] {rec['target']}: {rec['recommendation'][:80]}...")
129+
130+
if benchmark_run.incremental_update_recommendations:
131+
print(f"\n Incremental Update Recommendations ({len(benchmark_run.incremental_update_recommendations)}):")
132+
for rec in benchmark_run.incremental_update_recommendations[:5]:
133+
print(f" [{rec['priority']}] {rec['target']}: {rec['recommendation'][:80]}...")
134+
135+
if benchmark_run.p7_readiness_warnings:
136+
print(f"\n P7 Readiness Warnings ({len(benchmark_run.p7_readiness_warnings)}):")
137+
for w in benchmark_run.p7_readiness_warnings:
138+
print(f" ⚠️ {w}")
139+
140+
if reports:
141+
print(f"\n Reports Generated:")
142+
for name, path in reports.items():
143+
print(f" {name}: {path}")
144+
145+
if benchmark_run.errors:
146+
print(f"\n Errors:")
147+
for e in benchmark_run.errors:
148+
print(f" ❌ {e}")
149+
150+
print(f"\n Full report: 10_System/benchmarks/benchmark_report.md\n")
151+
152+
# Return non-zero if there were hard failures
153+
if benchmark_run.total_failed > 0:
154+
return 1
155+
return 0
156+
157+
158+
if __name__ == "__main__":
159+
raise SystemExit(main())

0 commit comments

Comments
 (0)