Spaces:
Running
Running
Commit History
4 days ago
-
fix(sonar): wave 7 - cleanup round from live scan (93 findings across 65 files)
Z User- 34 in-scope follow-ups exposed by the 17:59 scan (refactor residuals: S3776 helper splits, S4323 type aliases, S6759 readonly on extracted components, S8786 bounded-regex justifications, S6551 scrub patterns, S9440/S7924 CSS at new positions) - python leftovers: 29x S1481 positional _, S8786 regex canonicalization (fuzz-verified), S3776 task24 step-fn hoisting, S1192 dialog/content-type consts - operator tooling: S9382 documented NOSONARs for deliberate poll/throttle loops + Promise.all for independent probes, S8689 second log site routed through redact(), S5144 second fetch site behind UPSTREAM_HOST_ALLOWLIST Verified: tsc clean, vitest 1394/1394, node --check + py_compile on touched scripts.6780540 -
fix(sonar): wave 1 - resolve 511 in-scope findings across 15 app files
Z UserRoot-cause refactors per SonarCloud rules (behavior-preserving): - S3776 cognitive complexity: extracted cohesive helpers in ai-router, chatbot-router, chatbot-refs, chatbot-cables, Admin, ChatBot, skillnet, saadat, pdf, db-init, chat-render, Profile - S3358 nested ternaries -> Record lookups / if-chains / bilingual helper - S7780 String.raw for regex-source literals; S7781 replaceAll - S6594 match->exec / matchAll; S6557 startsWith/endsWith; S7755 .at() - S8786 backtracking: split overlapping-quantifier regexes (citation, refusal, promise/delivery detectors), linear rewrites, documented bounded-pattern NOSONARs where grammar is provably linear - S9382: Promise.all for independent DB upserts; documented NOSONAR for order-dependent/throttled loops only - S3923 real bug: identical-branch ternary in chatbot-cables depthFactor - S6551: honest typed rows instead of String(object) in db-init/sld fence - Source-contract tests re-pinned to the refactored equivalents (admission-gate…9ce5991
9 days ago
-
feat(chatbot-docgen): permanent in-chat document generation — PDF/DOCX/MD (v3.9.0)
ahmdelbaz28-uxOwner directive (2026-11-24): the bot must ALWAYS be able to build real files for the user inside the chat — no external skill loading, ever. - docgen skill 'docgen-file-export' in SKILL_REGISTRY (category export, thinking+instant): routed on file/export intent, emits a ```docgen DocSpec fence with the immediate-execution contract (file in the FIRST reply, verified numbers only, mandatory citations). - api/lib/docgen/: dependency-free deterministic renderers — PDF written from scratch (Type0/Identity-H CID fonts, two embedded GNU FreeFont subsets, full Arabic presentation-form shaping + simplified UAX#9 bidi with N0 bracket-pair + N1/N2 neutral resolution, RTL tables, page footers), DOCX as stored-ZIP OOXML (bidiVisual RTL tables, w:bidi paragraphs, Word-native shaping), and GFM Markdown. - POST /api/docs/gen: public, stateless, size-capped (60k content chars), typed 422 diagnostics — the /api/diagrams/sld contract. - Chat UI: renderDocgenFence download card (format …aea6c23
-
fix(sld): root-cause repairs — server-side spec repair + img-failure fallback + detector depth
Z UserRoot review of d37025f found two real holes, both closed at the source: 1) 422 → broken <img> in chat: the diagrams GET rendered nothing for a lint-failing spec (overlap, bad/duplicate ids), violating the router's own 'chat never breaks' contract at the last step, and the draw-now chip hid because a shape-valid fence was treated as delivered. Root fix: api/lib/sld/repair.ts — deterministic repair pass (sanitize ids, dedupe with first-occurrence wire mapping, drop dead wires, first-fit overlap relocation down/right/diag). Router GET/POST render the repaired spec; X-Sld-Repair header carries the audit trail; only a still-failing repair answers 422. renderSld/lintSpec untouched. 2) Residual broken-image icons: MessageBubble now attaches error listeners to SLD imgs and swaps failures for a localized note (createElement + textContent only — no model content). Detector depth: past-tense delivery claims (جهزت/حضرت/رسمت + المخطط), 'المخطط التالي/الآتي', EN 'the…e3276d9 -
feat(chat): SLD immediate-draw prompt rule + one-tap 'draw it now' chip
Z UserPrompt (v3.4.0): sldSkill AR/EN gain the IMMEDIATE EXECUTION RULE — sufficient data -> draw the spec board in the FIRST reply (promises, deferrals and permission-asking banned verbatim); one missing essential fact -> exactly ONE question; assumable -> assume + state one line. UI: detectUnfulfilledDiagramPromise() in chat-render.ts flags the last assistant reply when it promised/offered a diagram but carries no valid sld board (token-cap cut, broken fence, bare offer); ChatBot renders the 📐 ارسمها دلوقتي chip under it — one tap sends a language-mirrored follow-up that re-anchors the immediate-draw rule. Tests: 25 renderer cases (promise/offer/delivery vs teaching/imperative phrasing, board-invariance) + 6 quality contracts (happy/edge/failure matrix, thinking-only composition, changelog traceability). 478 total. Metrics snapshot: scripts/prompt-metrics/v3.4.0-sld-draw-now.json.d37025f -
fix(sld): rtl base direction for labels + self-collision and dense-row escapes
Z UserLive visual audit follow-up to 37435b7, found by re-reviewing the shipped screenshots: 1) Bidi: diagrams are consumed as <img> (no inherited page direction), so mixed Arabic+Latin labels rendered LTR and split the number from its unit — 'محرك 500kW' showed as '500 محركkW'. Every label/title now carries direction=rtl + unicode-bidi=isolate with a start<->end anchor flip that preserves the exact scored box (Chromium-verified). 2) Placement hole: clampCandidateX could push a label ONTO its own symbol because placeLabels exempted the label's own body from collision scoring. Self-bodies now count. 3) Dense-row escapes: side candidates now include up/down diagonals and below/above spots get a depth ladder (3 tiers x 3 shifts) — a packed bottom row ('فيوز 100A' boxed in by neighbors' bodies/labels) always finds a zero-collision spot instead of falling onto fan-out wires. 4) sheetSize side band scales with the LONGEST label instead of a fixed 96px, so full-wid…82358cc -
fix(sld): zero-overlap label placement — labels sit BESIDE their element
Z UserVisual audit found labels painted on wires/symbols and colliding with the sheet title (G1 label vs title, 66/11kV across the breaker, Main 11kV cut by its feed wire). - placeLabels(): every label is scored against title/bodies/labels/wires/ sheet edges; first zero-collision spot wins (right > left > below > above; busbars prefer left). Deterministic least-collision fallback. - Busbar fan-out dots stagger LEFTWARD so connection dots stay ON the bar. - sheetSize() reserves a side band (96px) when labels exist; geometry shifts half-band right so left-side labels never clip. - Over-long titles squeeze via textLength instead of spilling over row 0. - chat-render: append &v=3 to SLD URLs to bust stale immutable caches. - New regression suite parses the rendered SVG and asserts every label is clear of wires, symbols, other labels and the title (dark/light/dense).37435b7 -
feat(sld): draw single-line diagrams — spec-in, SVG-out, model text never becomes markup
Z UserPhase 1 of the electrical-diagram capability, architecture ported from abduznik/electrical-schematics-skill (grid layout, orthogonal routing, generate→audit→fix discipline) onto our Node runtime: - api/lib/sld/: types (grid→px placement, terminals), symbols (12 ETAP power elements, dark/light themes), lint (bounds/overlap/refs/grid), render (deterministic SVG, monotonic 3-segment routing with per-source fan-out columns, gap-clamped turns) - api/diagrams-router.ts: GET image/svg+xml (lint-fail = 422 + findings, immutable cache), POST JSON (svg + findings + canonical url) — public, read-only, zero storage, spec capped at 4k chars/40 elements - chat: sldSkill (Ar+En) injected THINKING-mode only — instant untouched; the model emits a sld JSON fence, never pixels; chat-render synthesizes the ONLY allowed img: same-origin /api/diagrams/... whose SVG comes exclusively from our linted renderer — malformed fences fall back to the escaped code block (streaming-safe) - tests: 1…ccfdb3c
-
fix(security): remediate audit run-1 confirmed findings (20)
Z UserCloudflare security-audit skill, full audit of 8ea551b (quick profile, source-only): 34 coverage units, 8 hunter domains, 6 independent verifiers, 21 confirmed + 7 needs_validation records. Artifacts: security-audit-skill/elbaz-platform/run-1/{REPORT,FINDINGS-DETAIL, NEEDS-VALIDATION}.md + findings.json (schema-validated) + coverage-ledger.json. HIGH (both XSS): - chat renderer: extract pure renderer to src/lib/chat-render.ts and escape EVERY text segment before markdown transformation (was: code fences only); href attribute breakout closed; biome-ignore safety claims made true; regression tests (img/script/href-breakout/table-cell payloads) - seo-meta: jsonLdSafeStringify escapes < > U+2028/2029 so stored course titles/FAQ questions cannot break out of the JSON-LD <script> element (the nonce stamper previously re-armed the injected script); tests MEDIUM: - CSRF: same-origin gate in security middleware for POST/PUT/PATCH (Origin/ Referer must match the CORS allowlist when…e5934c3