EKOS — Enterprise Knowledge Operating System

A compiled app, no source.
Same results in Python.

EKOS reads a compiled .NET library it has never seen the source of, recovers what every method does, and a Python rewrite is written from that. The rewrite is then checked against the running original and produces byte-identical output. Below is every step, with the real screen for each.

MarkdownSharp.dll→ ekos recover→ statement-level spec→ Python rewrite→ characterize + fuzz
§ 00 / why this app

Open source, real, deterministic, and small enough to check completely.

MarkdownSharp is the Markdown engine that powered Stack Overflow. It is a text-to-HTML function with no files, network or database, so "same results" means identical bytes. It leans on regular expressions, which is where a port most easily goes wrong.

  • InputThe compiled net40 assembly from NuGet, MIT licensed.
  • Recovered99 of 101 method bodies as fully structured statements, 98%.
  • Scope.NET only today. A Java jar would stop at structural facts; see the last slide.
§ 01 / start

A DLL and nothing else

MarkdownSharp 2.0.5 (MIT), a 51 KB compiled .NET assembly. No repository, no source. Only its string constants are readable.

The starting point: a compiled library and nothing else
§ 02 / baseline

Run the original: this is the behaviour to reproduce

A 12-line harness calls new Markdown().Transform(text). It runs on wine-mono, with no .NET SDK installed.

Run the original as-is: this is the behaviour to reproduce
§ 03 / observe

ekos build reads the bytes

The assembly is parsed, never executed. It becomes a content-addressed artifact.

ekos build: observe the binary (bytes only, nothing is executed)
§ 04 / recover

Recovery: 101 method bodies, 99 fully structured

A hand-written CIL decoder builds control-flow graphs and structures them into if/loop/switch/try statements. No LLM key was set, so none was used.

ekos recover / resolve / compile / commit: knowledge into the ledger
§ 05 / ledger

The result is queryable knowledge

Types, methods and the call graph are evidence-backed objects in the append-only ledger.

The compiled knowledge is queryable: types, methods, call graph
§ 06 / plan

The spec, and the order to port it in

ekos_binary_explain over MCP, the same server an AI agent uses. Callees come first, so every port step only depends on finished work.

ekos_binary_explain on the type: what it is, and the order to port it in
§ 07 / spec

One method, statement by statement

Every recovered line cites its IL offset. Regexes and replacement templates arrive as exact constants.

ekos_binary_explain on one method: the spec the rewrite is written from
§ 08 / honesty

Where recovery falls short, it says so

Normalize is control_flow with one unstructured goto. EKOS marks it partial and tells the porter not to guess. Two of 101 methods are in this state.

Where recovery is incomplete, it says so — and refuses to guess
§ 09 / rewrite

The Python port

Written callees-first from the recovered statements. Long regex literals were lifted from the spec by a script, and every method cites its token.

The rewrite: written callees-first from the recovered statements
§ 10 / static check

What the rewrite touches vs what the original touches

Evidence, not a verdict. It caught the config-file constructor that was left out on purpose. The rest are constants that moved files.

ekos_binary_migration_check: what the rewrite touches vs what the original touches
§ 11 / sandbox

Executing untrusted code, so prove the sandbox first

Five escape attempts, all blocked. The probe was itself validated by running it unsandboxed, where all five succeed.

Before running any untrusted code: prove the sandbox holds
§ 12 / characterize

Record the original, check the rewrite

The original runs once in the sandbox and its results become a golden file. The check needs only Python.

Record what the original does, then check the rewrite against the record
§ 13 / compare

Same inputs, both programs, byte for byte

wine mdcli.exe against python -m mdport. Identical sha256 on all 15 fixtures.

Same inputs through both programs, compared byte for byte
§ 14 / rendered

What a user sees

The HTML of both programs rendered in a browser. Identical output, not just similar-looking output.

What a user sees: the original's HTML and the port's HTML, renderedWhat a user sees: the original's HTML and the port's HTML, rendered
§ 15 / fuzz

3,000 generated documents, and a planted bug

Identical on every one. To show the fuzzer can fail, one regex flag was removed from a copy of the port. It found 44 differences in 300 documents.

Beyond hand-picked inputs: 3,000 generated documents, and a planted bug
§ 16 / limits

The one non-deterministic path

The original builds System.Random for email obfuscation. The spec shows it, so the port is random too, and the comparison decodes entities.

The one place the original is not deterministic — EKOS flagged it in the spec
§ 17 / part 2
How EKOS helps in this demo

EKOS does not write the port. It makes the input trustworthy and the output checkable.

StepWhat EKOS did hereWhat you would do without it
Read the binaryIn-process CIL decoder, control-flow graphs, structuring: 101 method bodies, 99 as full statements. No SDK, nothing executed.A PE file is not text an LLM can read. You need a decompiler first, and its output has no per-line evidence.
Constants37 regex and format literals, 12,009 characters, delivered verbatim and copied into the port by a script.Recall or retype them. One wrong character in a verbose regex changes behaviour and nothing complains.
EvidenceEvery statement cites its IL offset; every fact is a ledger object with provenance.Claims about what a method does cannot be traced back to anything.
Gaps2 methods marked control_flow / partial, with "do not fill the gaps by guessing".A model fills a gap with plausible code, and nobody sees where.
OrderMigration order, callees first, for all 78 methods of the type.Ad hoc, and easy to port a caller before what it depends on.
VerifyStatic check, sandboxed record of the original, replay against the port, and a fuzz that caught a planted bug."Looks right" review of code that was never compared to the running original.
§ 17 / part 2
Why this is harder for a plain LLM

Knowing Markdown is not the same as knowing this program.

Honest limits: no head-to-head against an LLM was run, and the rewrite here was itself written by an LLM using EKOS's spec, check and harness. The generic libraries are a proxy. A plain LLM given a general decompiler such as ILSpy would do better than that proxy; it would still lack per-line IL evidence, fidelity flags, callee ordering, and the run-against-the-original loop.
§ 17 / baseline

What general Markdown knowledge produces instead

Two mature generic libraries against the original's output. This is a proxy, not an LLM run. It shows how far Markdown the concept is from this program.

Why the spec matters: what general Markdown knowledge produces instead
§ 18 / result

Scoreboard, and what this does not prove

Numbers come from the frames, not from this page.

Scoreboard — and what this does not prove
Reproduce it

Every screenshot comes from one script.

terminal
# runs all 18 stages, real commands, writes frames/NN-*.txt
$ demo/binary-demo/run_demo.sh

# renders each frame to a PNG (and the browser comparison)
$ python3 demo/binary-demo/capture.py

# later: string the frames into a GIF or video
$ demo/binary-demo/tools/make_gif.sh 3

The code: Recovered pseudo-code, all types · Python rewrite: markdown.py · _literals.py · __main__.py

Not proven here: behaviour on the .NET Framework itself (the original ran on wine-mono); inputs outside the fuzzer's grammar; the app.config constructor (not ported). The decompiler is a private RFC 0149 extension; the screenshots show its output.