Skip to content

Experiment with F* formally verified components generated via Claude#3236

Draft
Stringy wants to merge 18 commits intomasterfrom
giles/formal-verification
Draft

Experiment with F* formally verified components generated via Claude#3236
Stringy wants to merge 18 commits intomasterfrom
giles/formal-verification

Conversation

@Stringy
Copy link
Copy Markdown
Collaborator

@Stringy Stringy commented Apr 17, 2026

Description

A detailed explanation of the changes in your PR.

Feel free to remove this section if it is overkill for your PR, and the title of your PR is sufficiently descriptive.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

TODO(replace-me)
Use this space to explain how you tested your PR, or, if you didn't test it, why you did not do so. (Valid reasons include "CI is sufficient" or "No testable changes")
In addition to reviewing your code, reviewers must also review your testing instructions, and make sure they are sufficient.

For more details, ref the Confluence page about this section.

Stringy and others added 18 commits April 17, 2026 16:44
Mark all functions in NRadixSpec as [@@noextract_to "krml"] and remove
inline_for_extraction annotations. This module serves as the ghost
specification for the Pulse heap implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Spec (admitted)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Define the heap-level node type, tree pointer, find result, and the
recursive is_tree slprop that links heap state to the NRadixSpec
functional tree. Include ghost helper functions (elim/intro for leaf
and node, case analysis) following the Pulse AVL tree pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement heap allocation/deallocation for the verified radix tree,
validating the Pulse + Box workflow with the is_tree ghost invariant.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement read-only tree traversal (find_walk, find, find_addr) with
full proof that results equal the ghost spec's find_aux/find/find_addr.
No admits required — all verification conditions discharged by Z3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement verified insert_walk and insert functions that mutate the
heap tree to add a network, proving the result matches
NRadixSpec.insert_aux. All verification conditions discharged with
no admits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Update Makefile with Pulse include paths and shared NetworkTypes bundle
- Restore inline_for_extraction on NRadixSpec functions called by NRadixPulse
- Add KRML_HOST_MALLOC/FREE to krml_compat.h for Pulse Box allocation
- Successfully extracts NRadixPulse.c/h with all tree operations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Create a unified 'verified' static library from the extracted F*/Pulse
C code, replacing the per-test library targets. Move
add_subdirectory(verified) before add_subdirectory(lib) so collector_lib
can link against it. Add missing NetworkTypes_ipnet struct definition
to the extracted headers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the hand-written C++ radix tree with wrappers that forward to
the formally verified NRadixPulse C library. The public API is
unchanged except Insert is no longer const (tree_ is mutable to
preserve const Find semantics).

Phase 1 behavior changes:
- Insert always returns true (verified code silently ignores duplicates)
- GetAll walks the verified tree structure directly
- IsAnyIPNetSubset uses GetAll + Find instead of parallel tree walk

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The collector's add_definitions for INTERESTING_SUBSYS contains commas
that break C compilation of the extracted verified code. Use
remove_definitions to isolate the verified library from these.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NRadixPulse.try_insert calls find (to check for existing network at
the same position) then insert. The C++ wrapper now correctly returns
false on duplicate insert, matching the original C++ semantics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Find(Address) checks if any network contains the address, but
IsAnyIPNetSubset needs to check if any network fully contains another
network. Find(IPNet) walks only to the query's prefix depth, giving
the correct "is superset" semantics.

Also simplify test_nradix.cpp to test properties directly rather
than cross-comparing wrapper vs raw API.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ignore .checked (F* cache) and .krml (Karamel intermediate) files.
Extracted C and F* sources are kept.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These existing modules define the pure types (address, ipnet) and
classification functions (IsLocal, IsPublic, etc.) used by both
NRadixSpec and NRadixPulse.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skill guiding the process of adding new formally verified F*/Pulse
components to the collector's verified library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reflects what we learned building the NRadix verified component:
- Ghost-spec-as-invariant architecture (spec + Pulse + wrapper)
- Pulse.Lib.Box for heap allocation (not algebraic recursive types)
- option(box) pattern for nullable pointers
- Karamel extraction conventions and known limitations
- CMake integration with remove_definitions workaround
- Lessons learned section

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.55056% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.82%. Comparing base (c320b8c) to head (ef2e14e).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
collector/lib/NRadix.cpp 57.14% 11 Missing and 25 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3236      +/-   ##
==========================================
- Coverage   27.38%   26.82%   -0.56%     
==========================================
  Files          95       95              
  Lines        5427     5383      -44     
  Branches     2548     2520      -28     
==========================================
- Hits         1486     1444      -42     
- Misses       3214     3216       +2     
+ Partials      727      723       -4     
Flag Coverage Δ
collector-unit-tests 26.82% <59.55%> (-0.56%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Copy Markdown

/retest collector-on-push

2 similar comments
@github-actions
Copy link
Copy Markdown

/retest collector-on-push

@github-actions
Copy link
Copy Markdown

/retest collector-on-push

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.

2 participants