Spaces:
Paused
Paused
File size: 2,440 Bytes
89bab68 7717949 89bab68 7717949 89bab68 7717949 89bab68 7717949 89bab68 7717949 6297b0e 7717949 f7c2b23 89bab68 7717949 89bab68 7717949 89bab68 7717949 89bab68 7717949 45c8940 7717949 89bab68 7717949 89bab68 7717949 f7c2b23 89bab68 7717949 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | import gradio as gr
from phases.phase1_ingest import ingest
from phases.phase2_rules import load_rules
from phases.phase3_static import static_scan
from phases.phase4_runtime import runtime_risks
from ci_guard import run_ci
with gr.Blocks(title="SpecGuard AI Lab", theme=gr.themes.Soft()) as app:
gr.Markdown("## π§ SpecGuard AI Lab")
gr.Markdown("Rulebook β Code Deep Research & Verification System")
# ββ Sidebar βββββββββββββββββββββββββββββββββββββββββ
with gr.Sidebar():
rulebook_input = gr.Textbox(
label="π Rulebook (paste)",
lines=12,
placeholder="Paste specification or rulebook text here"
)
code_zip = gr.File(label="π¦ Source Code (ZIP)")
ci_mode = gr.Checkbox(
label="π§ͺ CI Mode (Fail on CRITICAL)",
value=False
)
run_btn = gr.Button("π Start Deep Research", variant="primary")
# ββ Outputs βββββββββββββββββββββββββββββββββββββββββ
status = gr.Markdown()
output = gr.Markdown()
# ββ Core runner βββββββββββββββββββββββββββββββββββββ
def run_all(rulebook, zipfile, ci):
ingest(rulebook, zipfile)
rules = load_rules()
findings = static_scan(rules)
risks = runtime_risks()
# CI enforcement
if ci:
try:
run_ci()
except SystemExit:
return (
"β CI FAILED",
"Critical rule violation detected. Fix CRITICAL issues to proceed."
)
# Build report (THIS is where f-strings belong)
report = f"""
### β
Research Complete
- **Rules Loaded:** {len(rules.get("rules", []))}
- **Static Findings:** {len(findings)}
- **Runtime Risks Identified:** {len(risks)}
π Artifacts saved in `/artifacts/`
"""
return "β
Done", report
# ββ Button binding ββββββββββββββββββββββββββββββββββ
run_btn.click(
run_all,
inputs=[rulebook_input, code_zip, ci_mode],
outputs=[status, output]
)
if __name__ == "__main__":
app.launch()
|