Skip to content

Capability ledger: feature docs generated from tested facts - #27

Open
evertonfraga wants to merge 9 commits into
feat/inheritancefrom
docs/capability-ledger
Open

evertonfraga wants to merge 9 commits into
feat/inheritancefrom
docs/capability-ledger

Conversation

@evertonfraga

Copy link
Copy Markdown
Contributor

Stack: based on feat/inheritance (#21) · merge after #21

Summary

Capability ledger

  • docs/capabilities.toml: every feature (87 entries, by area) with its status (verified, partly verified, unknown values, not verified, rejected, fails), notes, the baseline GAP it concerns, and witnesses: obligations of test/examples/ fixtures as their golden files report them, translation errors, warnings, or tests that CI runs. It also lists the annotations, the command-line options and the baseline gaps.
  • scripts/capabilities.py: checks that every witness holds in the golden files, that the witnesses fit the status, that gap statuses agree with the entries citing them, and that the option and annotation lists match StrataSolidityMain.lean and SpecParser.lean; renders the generated sections (<!-- capabilities:begin VIEW --> … end). --check fails on any mismatch or stale section.
  • CI: a step runs python3 scripts/capabilities.py --check.

Generated from the ledger

  • LIMITATIONS.md: the status legend and the full feature table, replacing the hand-written tables.
  • Guide: supported_features.md and limitations.md (by area), the option table in first_verification.md.
  • README.md: the annotation table (without forall/exists, which are expressions), a works / not-yet list, the option table.
  • FAQ.md: the project-state summary. Landing page: the annotation table and the two status lists, rendered by build.py.
  • Next-spec: the status of GAP-001..012 and the limitations found since.

Translator (SpecParser.lean)

  • An annotation's text ends at the first //, so ensures x == v // note works. Such a line stopped the translation of the whole file, including the guide's own examples.
  • The spec tokenizer scans characters instead of byte positions. Non-ASCII text (✅, é) had produced filler characters and cut the following tokens short. Tabs and no-break spaces separate tokens.

Fixtures (test/examples/)

  • spec_comments.sol, plus true/false pairs for features that had no fixture: old() in loop invariants, msg.sender in constructors, push, delete, hash keys.
  • incomplete_assumptions.sol and modifies_nested_key.sol: facts that are not assumed, and a frame that is not checked.
  • 21 gap_*.sol files, one per construct that is rejected or fails to translate. Each golden file pins the current error.
  • Cases appended to five existing fixtures.

Documentation corrections

  • README: z3 only (no cvc5); real plain-text output; the token example's mint bug makes the result ❓ unknown, not ❌ refuted.
  • FAQ: the in-Lean pipeline (not Python/Ion); @custom:strata; translator size; aliasing through storage references; hosting in strata-org.
  • Guide:
    • The transfer examples require to != msg.sender.
    • transferFrom has a frame that is actually checked; the loop-invariant constant is inside its contract.
    • old() in loop invariants is supported.
    • exists caveats; modifies is not equivalent to a forall frame; specification operators.
    • Output formats: ❌ means refuted; the errors section; exit status per format; --pipeline-json.
    • A SARIF workflow that builds what it runs.
  • examples/: overflow_token.sol now fails, as its README row says.
  • CHANGELOG: PRs Report annotations and functions that are not verified #3 and SARIF: the CLI's verdicts, conforming to SARIF 2.1.0 #5–External calls may re-enter the contract #14, this branch, and caveats on stale claims.
  • CONTRIBUTING:
    • A ledger section.
    • The real merge practice (it claimed rebase-only was enforced).
    • REQ-NEXT citations instead of the untracked REQ-FEIL spec.
  • STRATA_REFERENCE.md removed (a stale 8-line fragment).
  • Migration plan: tag label, phase status, resolved gaps.
  • Specs:
    • Next-spec Requirements 2–6: soundness corrections, annotation text, CLI and exit status, the in-Lean frontend decision record, documentation generated from the ledger.
    • .kiro/specs/README.md no longer claims a baseline tag.
    • Baseline task group 5 marked superseded.
  • Source comments that described removed code or cited the untracked spec. Comments only.

Not supported

The ledger lists these, each with a fixture: pop, revert("…"), library calls, strings and dynamic bytes, positional struct constructors, tuple assignment, a constructor calling an internal function that uses state, delete of non-integers, if/else branches assigning different types, overloads differing only between integer and address parameters, a local named result, type conversions and bitwise operators in specifications, and others. Each stops the translation of the whole file.

Known issues

  • lake build gen-dialect-summary fails to compile (Invalid dotted identifier notation: .syncat), also before this branch. It is not a default target.
  • Not changed, pending an owner decision:
    • the Asana links in LIMITATIONS.md;
    • the "Internal FAQ" title and its JVerify comparison;
    • LICENSE-APACHE;
    • SECURITY.md's reporting channel (private vulnerability reporting is off);
    • the Brazil Config file.

Testing

  • lake build strataSolidity, lake test, python3 -m pytest Tools/Solidity/test (15 passed), lake run pbt-determinism.
  • CI=true bash test/run_tests.sh 15: 106 passed with z3 4.15.4, and 106 passed with z3 4.8.12.
  • python3 scripts/capabilities.py --check: 87 entries, every witness holds.
  • python3 docs/site/_src/capture_outputs.py && python3 docs/site/_src/build.py: the landing outputs are unchanged.
  • Every guide example changed here was run: each verifies or fails as its page says.

Notes

An annotation line such as

    /// @Custom:strata ensures x == v  // ✅ the stored value

stopped the translation of the whole file ("Unexpected tokens after spec
expression: [✅AA, the, stored, val]"). The guide's own examples use that
form (contract_invariants.md, limitations.md, mappings.md).

- SpecParser: the text of an annotation ends at the first `//`
  (`stripSpecComment`); no spec expression contains `//`. A keyword
  followed only by a comment has no body and is reported as before.
- SpecParser: the tokenizer scans characters instead of byte positions.
  It indexed the string by byte but stepped and stopped by character
  count, so a multi-byte character produced `A` filler characters and
  cut the following tokens short. Tabs and no-break spaces now separate
  tokens.
- ContractTranslator: `sum(m)` detection ignores the comment too.
- Tests: tokenizer and annotation cases in SpecParserTest;
  test/examples/spec_comments.sol (true and false properties with
  comments after requires, ensures and modifies).
Fixtures that the capability ledger cites as evidence, each with intent
comments.

- Verified features without a fixture so far, each with a true and a
  false property: `old()` in a loop invariant (function entry, not loop
  entry), `msg.sender` in a constructor, `push` (length, value, earlier
  elements), `delete` of integers, addresses and mapping entries, hashes
  as mapping keys (and that collisions are not excluded).
- Facts Solidity guarantees that are not assumed, each reported as a
  spurious failure: enum ranges, array index ranges, `msg.value == 0` in
  a non-payable function (incomplete_assumptions.sol); a two-index
  `modifies` key, whose frame is not checked (modifies_nested_key.sol).
- gap_*.sol: one fixture per construct that is rejected or fails to
  translate (`pop`, `revert("…")`, library calls, strings, positional
  struct constructors, tuple assignment, a constructor calling `_mint`,
  …). Their golden files pin the current error, so supporting one
  changes its golden file.
- Appended to existing fixtures: an `exists` whose witness z3 finds, a
  callee without a specification (its result is unknown), a lemma
  annotation (reported), a sum invariant broken by `mint` (unknown), a
  false property over `$` identifiers.

The golden suite passes with z3 4.15.4 and 4.8.12.
docs/capabilities.toml lists every feature with its status (verified,
partly verified, unknown values, not verified, rejected, fails), notes,
the baseline GAP it concerns, and witnesses: obligations of
test/examples fixtures as their golden files report them, translation
errors, warnings, or tests that CI runs. It also lists the annotations,
the command-line options and the baseline gaps with their status now.

scripts/capabilities.py checks the ledger and renders views of it:
- every witness holds in the golden files, which test/run_tests.sh
  compares with the binary;
- the witnesses fit the status (a verified entry has a proven obligation
  and a refuted or unproven one, or a test; a rejected one an error; a
  skipped one a warning);
- a gap marked closed is cited only by verified entries, and an open or
  narrowed one by an entry that is not verified;
- the options listed are those StrataSolidityMain.lean reads, and the
  annotations those SpecParser.lean reads;
- the sections between `<!-- capabilities:begin VIEW -->` and
  `<!-- capabilities:end VIEW -->` markers in the docs equal what the
  ledger renders (with --check; without it, they are rewritten).

CI runs `python3 scripts/capabilities.py --check` after the docs build.
Generated from docs/capabilities.toml (scripts/capabilities.py):
- LIMITATIONS.md: the status legend and every feature with its status,
  by area. The "Supported Patterns", "Not Yet Supported" and "Storage
  References" sections it replaces said that `old()` in loop invariants
  and `msg.sender` in constructors do not work (they do), that `pop` is
  "not modeled" (it stops the translation of the file), and that struct
  fields through mappings fail only in specifications (a function using a
  struct-valued mapping is not verified at all).
- docs/guide supported_features.md and limitations.md: what is verified,
  and what is not, by area. They had contradicted each other and the
  binary (counterexamples listed as a gap, `push` as not modelled, `**`
  without the restriction to constants).
- README.md: the annotation table (it listed `forall` and `exists` as
  annotations, which the binary ignores with a warning), a short list of
  what works and what does not, and the option table; also in
  first_verification.md, which lacked `--strict`'s effect on unknown
  results.
- FAQ.md: the summary of the project's state.
- Landing page: the annotation table and the two status lists, rendered
  by build.py.

Corrected by hand in the same files:
- README.md: z3 is the only solver (cvc5 was listed); the plain-text
  output shown is the binary's (the old one had another format); deleting
  `totalSupply += amount` makes the invariant unprovable (❓), not
  refuted; the directory layout and test commands include the golden
  suite and the ledger check.
- FAQ.md: the pipeline is solc's JSON AST parsed in Lean, in one binary
  (not Python and Ion); the tag is `@custom:strata`; the translator is six
  files, not one; Solidity has aliasing through storage references and
  memory values; the repository is in strata-org.
Each changed example was run, and verifies as the page now says.

- overview, pre_and_postconditions, old_expressions: the `transfer`
  examples require `to != msg.sender`; without it both postconditions are
  refuted (a self-transfer leaves the balance unchanged), which the pages
  now say.
- mappings: `transferFrom` uses `modifies allowance[from], balances[from],
  balances[to]`. Its `modifies allowance[from][msg.sender]` was not read
  (a two-index key), so the frame of `allowance` was not checked, and the
  `balances` it writes were missing. The page explains one-index keys, and
  that a function using a struct-valued mapping is not verified at all.
- loop_invariants: the constant is inside its contract (outside, the file
  failed to translate); a section on `old()` in loop invariants (function
  entry) and on loops that write state.
- old_expressions: `old()` works in loop invariants (it was listed as
  unsupported) and is rejected in invariants.
- quantifiers: a true `exists` is often unknown; the variable ranges over
  its type. modifies: `modifies` and the `forall` frame are not
  equivalent (`modifies` also frames the other variables).
- annotation_reference: `//` comments, one line per annotation, one-index
  `modifies` keys, specification arithmetic, and the operators and
  conversions specifications do not have.
- contract_invariants: what the CLI reports per function, instead of the
  markers of an IDE extension that is not in this repository.
- output_formats: four formats; ❌ means refuted (it said "could not be
  proven", which is ❓); the errors section, the not-verified line,
  `--pipeline-json`, and the exit status of each format.
- sarif: the workflow builds StrataSolidity, installs solc and z3, asks
  for `security-events: write`, and uploads only a SARIF document the run
  wrote (it used a wrapper that does not exist in a user's repository).
- examples: overflow_token.sol wraps in `unchecked`, so it fails as its
  table row says (it was proven); the table gives each file's result and
  says that CI does not run these.
strata-solidity-next/requirements.md, besides Requirement 1
(inheritance):
- Requirement 2: the soundness corrections (invariants over msg.*,
  require's message, quantifier ranges, bitwise results, constant
  expressions, unchecked division and powers, specification division,
  storage parameters, halting calls, struct copies, storage references),
  with the baseline IDs each modifies.
- Requirement 3: annotation text ends at `//`; the tokenizer reads
  characters.
- Requirement 4: the input, the options (the ledger's list, checked
  against the code), the exit status per format (REQ-CLI-050/051 and
  REQ-PBT-007 hold only in plain text), and the plain-text errors
  section and not-verified line.
- Requirement 5: a decision record of the in-Lean frontend that replaced
  the Python/Ion one, superseding REQ-PY-* and the wrapper and CLI
  requirements that described it, and what was kept on purpose (the Ion
  reader, the shell harnesses).
- Requirement 6: documented capabilities are generated from the ledger
  and checked in CI; gap fixtures replace the XFAIL registry.
- Requirement 7: the status of GAP-001..012, generated from the ledger
  (003 and 006 closed, 011 obsolete, 001, 007, 008 and 009 narrowed), and
  the limitations found since, by capability id.

specs/README.md no longer says the baseline is tagged (it never was) and
current; baseline tasks.md marks group 5 (publish and tag the baseline)
as superseded.
- Adds PRs #3 and #5–#14 (not verified annotations reported, --strict,
  SARIF verdicts, names in user terms, internal-call arguments, and the
  soundness fixes to statements, loops, assembly, evaluation order,
  aliasing, integer semantics, modifiers and re-entrancy), with a
  Soundness subsection.
- Adds this branch: the capability ledger, the gap fixtures, `//`
  comments in annotations, and the documentation corrections.
- Marks the 2026-03 feature list as first reported (several items no
  longer hold), the corpus numbers as measured outside the repository,
  and the pin's upstream tag as nightly-20261009.
… are

- CONTRIBUTING.md: a section on the capability ledger (what to update
  when behavior changes, and what `--check` enforces); the branch
  workflow says what the repository does (rebased branches, stacked pull
  requests merged with merge commits, no merge method enforced) instead
  of claiming that only "Rebase and merge" is allowed; PR links cite
  REQ-NEXT-* instead of REQ-FEIL-* from an untracked spec; "Where else to
  look" points to LIMITATIONS.md, the next-spec's gap table and the
  annotation reference.
- STRATA_REFERENCE.md removed: an eight-line fragment about struct fields
  through mappings, which CONTRIBUTING described as the annotation
  reference; docs/guide/src/annotation_reference.md is that reference.
- upstream-strata-migration-plan.md: the pin is tagged nightly-20261009
  upstream (not 20261008); a status per phase; the pre-existing gaps it
  lists are marked resolved; array theory is the default.
- SolcAstParser.lean called itself a scaffold with TODO stubs (it is the
  frontend of every .sol input) and laid out a migration plan that is
  done; SolcRunner.lean said the parser was a scaffold. Both, and
  DialectSummary.lean and test/Runner.lean, cited
  `.kiro/specs/pipeline-language-rationalization/`, which is not in the
  repository; they now cite strata-solidity-next's Requirement 5.
- DialectSummary.lean pointed to the deleted base_dialect.py;
  test/Runner.lean says it is not built and partly obsolete.
- lakefile.lean named StrataSolidity/SolidityDialectLean.lean and a
  snapshots/ directory, neither of which exists.

No code changes.
@evertonfraga
evertonfraga added this pull request to stack #28 October 27, 2026 19:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant