mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-02 04:00:40 +00:00
feat(explorer): add deterministic rendering E2E example and test (#1037) Adds a deterministic Explorer graph baseline and coverage for the full build -> persist -> API -> frontend hydration -> canvas rendering path, so a regression anywhere along that chain shows up in CI instead manually. examples/explorer_deterministic_rendering_example.py builds the canonical 4-node, 3-edge graph (Alice -WORKS_AT-> Acme, Bob -KNOWS-> Alice, Acme -LOCATED_IN-> New York) with ContextGraph.add_node()/ add_edge(), persists it with save_to_file() and reloads it with GraphSession.from_file(), printing the setup prerequisites and the expected node/edge/label checklist for anyone running it by hand. tests/explorer/test_explorer_deterministic_rendering_e2e.py covers graph construction, the serialize/deserialize round trip, GraphSession loading, and the Explorer API's /api/graph/* responses against the exact expected nodes, edges, and labels, plus all three auth modes (unconfigured, API-key required, anonymous opt-in). fix(explorer): address Qodo review findings for deterministic rendering e2e (#1037) - configure SEMANTICA_ALLOW_ANONYMOUS=true and document SEMANTICA_API_KEY as the alternative in the reproduction instructions, so the documented commands don't 503 on a clean checkout - add clean-checkout prerequisites and a visual verification checklist to the example - add edge-label (WORKS_AT, KNOWS, LOCATED_IN), zoom-tier, and hover-interaction coverage to the frontend test - add an explicit auth-enforcement integration test for the deterministic graph endpoints fix(explorer): connect deterministic rendering E2E path The frontend test built its own node/edge objects directly with batchMergeNodes()/batchMergeEdges(), bypassing the real loading path entirely -- it never went through useLoadGraph, never mounted the canvas, and its fixture didn't even carry the same fields the backend actually returns (e.g. no color values), so a break in API hydration, the edge.type -> edgeType mapping, or canvas label rendering could still pass. Adds deterministicExplorerRendering.e2e.ts, which mounts the real Explorer app in Chromium, serves API-shaped /api/graph/nodes and /api/graph/edges responses through route interception, drives the app through its actual useLoadGraph hydration path into a real Sigma canvas, and asserts on captured canvas fillText() calls that WORKS_AT, KNOWS, and LOCATED_IN are genuinely drawn, both after load and after Zoom In. fix(explorer): preserve upstream markdown dependencies ci(explorer): isolate deterministic backend test dependencies Wires the new Python test into ci.yml as its own focused step (it previously only ran manually), installs Playwright's Chromium browser before the frontend suite, and keeps the deterministic backend test's dependency install separate from the rest of the pipeline so it doesn't pull in unrelated optional extras during collection. fix(explorer): remove redundant edge label hydration An earlier commit in this PR added an explicit `label` field to hydrated edge attributes on the theory that it was needed for edge labels to render. Review traced through GraphCanvas.tsx's label resolution (`attrs.edgeType || data.label || ""`, from the earlier #1009 fix already on main) and found that `edgeType` is set unconditionally on every edge during hydration, so it always wins the `||` before `data.label` is ever consulted -- the added field and its plumbing in useLoadGraph.ts and graphStore.ts never did anything. Removed both; reran the real Chromium E2E test against the reverted code and confirmed all three labels still render identically, closing out the question of whether anything else was actually broken.
98 lines
3.6 KiB
YAML
98 lines
3.6 KiB
YAML
name: CI
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- 'docs_check.py'
|
|
- '**/*.md'
|
|
pull_request:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- 'docs_check.py'
|
|
- '**/*.md'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
|
|
with:
|
|
python-version: '3.11'
|
|
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: explorer/package-lock.json
|
|
- name: Install Explorer frontend dependencies
|
|
working-directory: explorer
|
|
run: npm ci
|
|
- name: Install Playwright Chromium
|
|
working-directory: explorer
|
|
run: npx playwright install --with-deps chromium
|
|
- name: Test Explorer frontend
|
|
working-directory: explorer
|
|
run: |
|
|
npm run test:graph-store
|
|
npm run test:graph-workspace
|
|
npm run test:plugin-registry
|
|
npm run test:deterministic-e2e
|
|
- name: Build Explorer frontend
|
|
working-directory: explorer
|
|
run: npm run build
|
|
- name: Install Explorer backend test dependencies
|
|
run: |
|
|
# Run the deterministic backend path before the all-extras CI
|
|
# environment is installed. The Explorer extra supplies the
|
|
# production API dependencies without importing optional vector
|
|
# providers such as Pinecone during test collection.
|
|
pip install -e ".[explorer]" pytest==9.1.1
|
|
- name: Test deterministic Explorer backend path
|
|
run: |
|
|
pytest -q tests/explorer/test_explorer_deterministic_rendering_e2e.py
|
|
- name: Install pinned Python dependencies
|
|
run: |
|
|
pip install -r requirements-ci.txt
|
|
- name: Verify requirements-ci.txt is up to date
|
|
run: |
|
|
pip install uv==0.12.1
|
|
# Re-resolve with the committed file as a constraint: upstream package
|
|
# releases must NOT fail CI (deps only change when pyproject.toml
|
|
# changes intentionally). Compare only version lines (pkg==ver),
|
|
# ignoring the -c constraint comments and the `\` line continuations
|
|
# that --generate-hashes emits.
|
|
uv pip compile pyproject.toml --python-version 3.11 --extra all \
|
|
--constraint requirements-ci.txt -o /tmp/requirements-ci-check.txt
|
|
diff \
|
|
<(grep -E '^[a-zA-Z0-9._-]+==' requirements-ci.txt | sed 's/ \\$//') \
|
|
<(grep -E '^[a-zA-Z0-9._-]+==' /tmp/requirements-ci-check.txt)
|
|
- run: pip install build
|
|
# wheel is build-time only (not in requirements-ci.txt) — install the
|
|
# same pinned version [build-system] declares so --no-isolation works.
|
|
- run: pip install wheel==0.48.0
|
|
- name: Build package (no isolation — pinned deps)
|
|
run: python -m build --no-isolation
|
|
- name: Verify Explorer frontend is packaged
|
|
run: |
|
|
python - <<'PY'
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
wheels = list(Path("dist").glob("*.whl"))
|
|
assert wheels, "No wheel was built"
|
|
|
|
with zipfile.ZipFile(wheels[0]) as wheel:
|
|
names = set(wheel.namelist())
|
|
|
|
assert "semantica/static/index.html" in names, "Explorer index.html missing from wheel"
|
|
assert any(name.startswith("semantica/static/assets/") for name in names), "Explorer assets missing from wheel"
|
|
|
|
print("Explorer frontend is packaged")
|
|
PY
|