Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

edge-workbench

Takes an EDGE algorithm specification and produces a verified, explorable page: step through the cascade one Einsum at a time and watch each one execute over its iteration space.

The page is built by executing the specification with edge-core-ir's evaluator, which is the source of truth for EDGE semantics. The workbench records what that evaluator computed and the page renders it; nothing is evaluated a second time, in the browser or anywhere else.

Setup

Needs Python 3.10+, and node for the headless page checks only.

# edge-core-ir, beside this repo, on the branch the workbench runs on
git clone -b fixes_for_edge_workbench https://github.com/edge-einsums/edge-core-ir.git
git clone <this repo> edge-workbench
cd edge-workbench
pip install -e '.[oracles,dev]'   # scipy + networkx (verifiers), pytest
npm install                       # jsdom, for the headless page checks

Use the fixes_for_edge_workbench branch of edge-core-ir (known good: c8bcbdd), not main. It adds what the examples need and upstream does not have yet: a reduce inside parentheses, a reduce over an empty fiber writing nothing, case statements, conditional cascades and inner cascades (issues 2, 7, 8, 9 and 10 in docs/issues-for-edge-core-ir.md). Everything else the page needs (macro expansion, select-any, the record of each Populate round) is built here, around the evaluator (docs/evaluator-needs.md). They go upstream one pull request per issue; until then, on main most examples fail. The workbench finds edge-core-ir via EDGE_IR_REPO, then a checkout beside this repo, then ~/Projects/edge-core-ir.

python3 -m edge_workbench check examples/maximum-flow   # writes examples/maximum-flow/index.html
npm test                                                # domain views, every example page, pytest

The workflow

An algorithm becomes a published page in six steps. Each step names who does it; only the parts marked you need a person.

  1. Draft (agent, with you). In Claude Code in this repository, ask for an EDGE tutorial and give one of: an algorithm's name, pseudocode, a program, or an existing tutorial (e.g. edge-algorithms/_algorithms/<name>.md). The write-edge-tutorial skill (.claude/skills/write-edge-tutorial/) writes the tutorial .md (with its ranks: block and meaning lines) and einsum.edge into examples/<slug>/, asking whenever something is unclear. You approve at two checkpoints: (A) the pseudocode, worked example and its expected answer; (B) the cascade.

  2. Verifier (you choose). The skill offers the verifier kinds (definition, library, certificate, different-algorithm, user-reference); you pick one. It drafts verifier.py only for a library check or a wrapper around your own code, or if you ask it to.

  3. Check (agent):

    python3 -m edge_workbench check examples/<slug>
    

    Every stage lists all its problems, then stops. The builder and tutorial-data steps write a prompt; the agent answers it in the same session (or you paste it into a chat) and the reply is checked like anything else. Anything about the cascade, the example or the answer comes back to you with evidence. A verifier that has never been approved does not stop the run: check carries on and ends with … approval.

  4. Approve (you, checkpoint C), once, when check asks. Either:

    • in Claude Code: the agent shows you the whole verifier.py, its sha and the published answer, then runs approve-verifier examples/<slug> --confirm "<METHOD>" --sha <sha>. .claude/settings.json makes that command always ask you first: clicking allow is your approval. The same settings forbid the agent to write verifier.lock or the approvals file itself. If verifier.py changed after you were shown it, the command refuses.
    • in your own terminal: python3 -m edge_workbench approve-verifier examples/<slug>, typing the METHOD when asked.

    This pins verifier.py and the tutorial's published answer together in verifier.lock (which records how it was approved). Commit both, run check again, and index.html is written. A verifier or answer that changes after approval stops check until you approve again.

  5. Look: open examples/<slug>/index.html.

  6. Publish (agent or you):

    python3 -m edge_workbench publish examples/<slug>
    

    Runs check again and refuses unless it passes, copies the page to edge-algorithms/assets/viz/<slug>/ (or --site <dir>), and adds the viz: link to the site's tutorial. --with-tutorial also replaces the site's tutorial with this one. Nothing is committed.

Without an agent: write the three files yourself (tutorial .md, einsum.edge, verifier.py) and run steps 3-6, pasting the two prompts into a chat. AUTHORING.md is the step-by-step guide.

Other commands: python3 -m edge_workbench verify-instance <dir> <k> reruns one random instance of the answer check.

Gates

Two run before the page is written, and there is no flag to skip them.

gate question
coverage did every Einsum the author wrote actually execute?
answer is what the run produced right?

Coverage is the one that replaced comparing against a recording. Its failure mode is silent: an Einsum that never runs produces no wrong value and raises nothing, it just leaves a page whose step list looks complete. It works off the driver's per-IR-node tally rather than the emitted steps, because the two differ on purpose — initialization runs four Einsums and emits one step. A case statement is one Einsum whose arms are tallied separately: everything outside an arm must run on the worked example, and each arm (of a case statement or a conditional cascade) on the worked example or on one of the verifier's random instances.

The answer check is the author's verifier.py, because only the algorithm knows what right means; the tool runs it on the worked example, the published answer and 12 random instances. A person approves each verifier with python3 -m edge_workbench approve-verifier <dir> (AUTHORING.md), and check refuses one that has changed since.

check also validates the program against the IR (Layer 1 and Layer 2) and against einsum.edge. npm run gates runs the test suite; the tests that need an edge-core-ir checkout or generated example files skip without them.

Layout

edge_workbench/        the tool. Contains no algorithm.
  author.py    `check`: every stage, in order
  driver/      run.py: runs edge-core-ir's evaluator and records the trace
  render/      build_page.py, annotate.py, display.js (glyphs only; no evaluation)
  verifier.py, approval.py    the verifier contract and its approval
  rank_kinds.py, domain_shape.py    which picture a program gets
  spec_surface.py   reads einsum.edge (labels, macros, constants)
  publish.py        `publish`: copies a passing page to the site
examples/<alg>/        tutorial .md, einsum.edge, verifier.py (+ verifier.lock);
                       `check` writes workbench/ and index.html beside them
tests/                 generic gates
.claude/skills/write-edge-tutorial/   the agent's skill (SKILL.md, rules.md)
docs/                  DESIGN.md (decisions, build plan),
                       issues-for-edge-core-ir.md (language questions only),
                       evaluator-needs.md (what the page needs, built here),
                       tutorial-notes/<alg>.md (questions for one tutorial)

Adding an algorithm is adding a directory with those three files. The tool does not know what any algorithm computes.

Free choices

A populate names a choice function the IR does not define. Some of those choices are genuinely free and some are the algorithm, and mapping a free one to a fixed rule would make the spec claim something it does not.

Ranking operators (select-min-val, select-max-val) are part of the algorithm: the better value wins, ties go to the lower coordinate, and the result does not depend on the schedule. Any other populate name is a free choice: max-flow's pick-admissible-edge says ANY admissible edge, so it runs as seeded select-any (the first arrival wins). The page shows the sequential schedule; the answer check also runs every free choice under shuffled schedules and requires the same answer from each. An unknown name stops the cascade rather than being guessed at.

Known limitations

  • I is hard-coded as the generational rank (undecided for SpMV).
  • Long runs (DOBFS, set-cover) show every step; choosing which to show is not built yet.
  • set-cover's E02 writes an operation with no merge; giving it the paper's default (pass-through) is not settled.
  • One test fails: tests/test_robustness.py::test_a_value_equal_to_empty_is_reported.
  • No CI.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages