diff --git a/.github/funding.yml b/.github/funding.yml new file mode 100644 index 0000000..e4f7c07 --- /dev/null +++ b/.github/funding.yml @@ -0,0 +1,4 @@ +# Funding Configuration +# See: https://docs.github.com/en/repositories/managing-your-repositorys-custom-fields/displaying-a-sponsor-button-in-your-repository + +github: metadatastician diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 349b19f..bf3add1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,11 +32,11 @@ jobs: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Initialize CodeQL - uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v3.28.1 + uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v3 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v3.28.1 + uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v3 with: category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/proof-gates.yml b/.github/workflows/proof-gates.yml new file mode 100644 index 0000000..d57b52c --- /dev/null +++ b/.github/workflows/proof-gates.yml @@ -0,0 +1,137 @@ +# SPDX-License-Identifier: MPL-2.0 +# +# Proof Gates — builds the real compiler and checks the real proofs. +# +# FAIL-CLOSED by design: a missing prover fails the job. This replaces +# reliance on Rust CI (which "passes" by detecting no Cargo.toml and +# skipping every job) and on `just proof-check-*` (which exits 0 when a +# prover is absent). Nothing in this file is allowed to skip. +# +# Toolchain provenance: +# - compiler + agda jobs run in debian:trixie, the same distribution +# (and identical ocaml/dune/agda/agda-stdlib versions) the suite was +# verified against locally on 2026-08-03. +# - the idris2 job runs in a digest-pinned pack image; the suite was +# verified against BOTH idris2 0.7.0 (local) and 0.8.0 (this image). +name: Proof Gates +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: +permissions: + contents: read +concurrency: + group: proof-gates-${{ github.ref }} + cancel-in-progress: true +jobs: + compiler: + name: OCaml compiler + example matrix + runs-on: ubuntu-latest + timeout-minutes: 20 + container: + image: debian:trixie + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - name: Install toolchain (fail-closed) + run: | + apt-get update + apt-get install -y --no-install-recommends ocaml ocaml-dune + ocaml -version + dune --version + - name: Build compiler + working-directory: src/compiler + run: dune build + - name: Positive examples must type-check + run: | + KSC=src/compiler/_build/default/main.exe + fail=0 + for f in examples/v2/*.ks; do + if ! "$KSC" check "$f"; then + echo "::error file=$f::positive example failed to type-check" + fail=1 + fi + done + exit "$fail" + - name: Negative examples must be rejected + run: | + KSC=src/compiler/_build/default/main.exe + fail=0 + for f in examples/v2/negative/*.ks; do + if "$KSC" check "$f" > /dev/null 2>&1; then + echo "::error file=$f::negative example was accepted (must be rejected)" + fail=1 + fi + done + exit "$fail" + + agda-proofs: + name: Agda proofs + trusted-base budget + runs-on: ubuntu-latest + timeout-minutes: 30 + container: + image: debian:trixie + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - name: Checkout echo-types (pinned) + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + repository: hyperpolymath/echo-types + ref: 900546a832ddfefb4fa48881cdebdc9b1260d1f9 + path: .deps/echo-types + - name: Checkout absolute-zero (pinned) + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + repository: hyperpolymath/absolute-zero + ref: cef394b617869e1fa0d10f8fd9bdbba8db8d8738 + path: .deps/absolute-zero + - name: Install Agda (fail-closed) + run: | + apt-get update + apt-get install -y --no-install-recommends agda agda-bin agda-stdlib + agda --version + - name: Check proofs + run: | + LIB="$PWD/.agda-libraries" + printf '%s\n' \ + /usr/share/agda-stdlib/standard-library.agda-lib \ + "$PWD/.deps/echo-types/echo-types.agda-lib" \ + "$PWD/.deps/absolute-zero/absolute-zero.agda-lib" > "$LIB" + cd proofs/agda + # EchoBridge is postulate-free and must stay --safe. + agda --safe --library-file="$LIB" EchoBridge.agda + # The recipe proofs carry audited physical-world postulates + # (see TRUSTED-BASE.txt), so they check without --safe; the + # budget step below stops that trusted base growing silently. + for f in Dough.agda NoCurdle.agda PoachedEgg.agda; do + agda --library-file="$LIB" "$f" + done + - name: Trusted-base budget (no new postulates) + run: sh scripts/check-agda-trusted-base.sh + + abi-proofs: + name: Idris2 ABI proof suite + runs-on: ubuntu-latest + timeout-minutes: 20 + container: + image: ghcr.io/stefan-hoeck/idris2-pack@sha256:f0dece3334c6a1d21d65334416e02d0e7b59da480644006b52c8b78c8cfc49f5 + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - name: Typecheck ABI proof suite (fail-closed) + working-directory: verification/proofs/idris2 + run: | + idris2 --version + idris2 --typecheck kitchenspeak-abi-proofs.ipkg + - name: No dangerous escape hatches + run: | + # Matches code lines only; the file headers legitimately SAY + # "no believe_me, no assert_total" in comments, so lines whose + # content starts with the Idris comment marker are excluded. + hits=$(grep -rnE "believe_me|assert_total" verification/proofs/idris2 --include="*.idr" | grep -vE ":[[:space:]]*--" || true) + if [ -n "$hits" ]; then + echo "$hits" + echo "::error::dangerous escape hatch found in proof code" + exit 1 + fi + echo "OK: no believe_me / assert_total in proof code." diff --git a/.machine_readable/ECOSYSTEM.a2ml b/.machine_readable/ECOSYSTEM.a2ml index 0059aed..066e87f 100644 --- a/.machine_readable/ECOSYSTEM.a2ml +++ b/.machine_readable/ECOSYSTEM.a2ml @@ -2,7 +2,9 @@ ;; Ecosystem position and relationships (ecosystem (version "1.0.0") - (name "{{REPO}}") - (type "library") - (purpose "{{REPO_DESCRIPTION}}") - (related-projects)) + (name "kitchenspeak") + (type "language") + (purpose "Future kitchen orchestration language for IoT and IIoT") + (related-projects + (project "echo-types" "Agda Echo (fiber) substrate consumed by EchoBridge.agda") + (project "nextgen-languages" "coordinator that indexes this language"))) diff --git a/.machine_readable/META.a2ml b/.machine_readable/META.a2ml index e64e280..5a1c343 100644 --- a/.machine_readable/META.a2ml +++ b/.machine_readable/META.a2ml @@ -2,7 +2,7 @@ ;; Architecture decisions and development practices (meta (version "1.0.0") - (project "{{REPO}}") + (project "kitchenspeak") (architecture-decisions) (development-practices (code-review "required") diff --git a/.machine_readable/root-allow.txt b/.machine_readable/root-allow.txt index adb687f..a5716f8 100644 --- a/.machine_readable/root-allow.txt +++ b/.machine_readable/root-allow.txt @@ -67,3 +67,20 @@ proofs/ # Agda (now) / Lean (later) lowerings of the recipes .pre-commit-config.yaml # TODO: relocate to ci/.pre-commit-config.yaml after invocation pattern decided affinescript/ # AffineScript source subtree consumed by this template tools/ # TODO: consolidate with scripts/ or document the split (pending decision) + +# ─── Governance / community surfaces (GitHub reads these at root) ──────────── +# Added 2026-08-03 with the C-A-G-M sweep landing; GitHub's community-health +# and OpenSSF tooling look for these exact root paths. +CONTRIBUTING.md +SECURITY.md +GOVERNANCE.adoc +GOVERNANCE.md # C-A-G-M sweep counterpart of GOVERNANCE.adoc +ARCHITECTURE.md # C-A-G-M sweep architecture overview +MAINTAINERS # C-A-G-M sweep plain-text maintainer roster +MAINTAINERS.adoc + +# ─── Licensing / packaging / tooling (tool-required at root) ───────────────── +LICENSES/ # REUSE-style full licence texts (MPL-2.0, CC-BY-SA-4.0) +manifest.scm # Guix manifest; `guix shell -m manifest.scm` reads root +mise.toml # mise toolchain pins (sweep2); mise reads repo root +docs-template/ # site templates consumed by the Ddraig SSG docs deploy (#14) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..607e3d8 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,47 @@ +# Architecture + +## Overview + +This repository follows a modular, maintainable architecture designed for clarity, scalability, and long-term sustainability. + +## Directory Structure + +``` +. +├── src/ # Source code +├── tests/ # Test suites +├── docs/ # Documentation +├── scripts/ # Utility scripts +├── config/ # Configuration files +├── LICENSE # License file +├── LICENSES/ # Full license texts +└── README.adoc # Project documentation +``` + +## Design Principles + +- **Separation of Concerns**: Each module has a single responsibility +- **Testability**: Code is written to be easily testable +- **Documentation**: All public APIs are documented +- **Configuration**: Environment-specific settings are externalized + +## Dependencies + +- External dependencies are minimized and clearly declared +- Version pinning is used for reproducibility + +## Security Considerations + +- Sensitive data is never committed to the repository +- Secrets are managed through environment variables or secure vaults +- Regular dependency audits are performed + +## Maintainability + +- Code follows consistent style guidelines +- Pull requests require review and CI checks +- Issues and discussions are tracked transparently + +--- + +*Last updated: 2026-07-18* diff --git a/GOVERNANCE.md b/GOVERNANCE.md new file mode 100644 index 0000000..e27364c --- /dev/null +++ b/GOVERNANCE.md @@ -0,0 +1,60 @@ +# Governance + +## Overview + +This project is governed by the following principles and structures to ensure transparent, inclusive, and effective decision-making. + +## Roles and Responsibilities + +### Maintainers + +Maintainers are responsible for: +- Reviewing and merging pull requests +- Managing releases and versioning +- Ensuring code quality and standards +- Triaging issues and bug reports +- Community engagement and support + +### Contributors + +Contributors are expected to: +- Follow the code of conduct +- Submit well-documented pull requests +- Write tests for new functionality +- Maintain existing tests +- Update documentation as needed + +## Decision Making + +### Minor Changes +- Can be made by any maintainer +- Include bug fixes, documentation updates, dependency updates + +### Major Changes +- Require discussion in issues or pull requests +- Include new features, architectural changes, API changes +- Need approval from at least 2 maintainers + +### Breaking Changes +- Require RFC (Request for Comments) process +- Need approval from majority of maintainers +- Must include migration guide + +## Code of Conduct + +All participants are expected to follow our Code of Conduct. Violations can be reported to the maintainers. + +## Communication + +- **Issues**: For bug reports and feature requests +- **Discussions**: For questions and general discussion +- **Pull Requests**: For code contributions + +## Licensing + +All contributions are made under the terms of the repository's LICENSE file. +By submitting a pull request, you agree to license your contributions accordingly. + +--- + +*Last updated: 2026-07-18* diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt index 835a683..2d58298 100644 --- a/LICENSES/CC-BY-SA-4.0.txt +++ b/LICENSES/CC-BY-SA-4.0.txt @@ -1,170 +1,428 @@ -Creative Commons Attribution-ShareAlike 4.0 International +Attribution-ShareAlike 4.0 International - Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. +======================================================================= -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. - -Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. - -Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. - -Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. - -Creative Commons Attribution-ShareAlike 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. - -Section 1 – Definitions. - - a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. - - c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. - - d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. - - e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. - f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. - - g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. - - h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. - - i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. - - j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. - - k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. - - l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. - - m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. - -Section 2 – Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: - - A. reproduce and Share the Licensed Material, in whole or in part; and +Using Creative Commons Public Licenses - B. produce, reproduce, and Share Adapted Material. +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. - 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). - 3. Term. The term of this Public License is specified in Section 6(a). + b. Other rights. - 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. - 5. Downstream recipients. + 2. Patent and trademark rights are not licensed under this + Public License. - A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. - B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. - C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. +Section 3 -- License Conditions. - 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. - b. Other rights. + a. Attribution. - 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + 1. If You Share the Licensed Material (including in modified + form), You must: - 2. Patent and trademark rights are not licensed under this Public License. + a. retain the following if it is supplied by the Licensor + with the Licensed Material: - 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); -Section 3 – License Conditions. + ii. a copyright notice; -Your exercise of the Licensed Rights is expressly made subject to the following conditions. + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; - a. Attribution. + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; - 1. If You Share the Licensed Material (including in modified form), You must: + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. - A. retain the following if it is supplied by the Licensor with the Licensed Material: + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. - i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + b. ShareAlike. - ii. a copyright notice; + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. - iii. a notice that refers to this Public License; + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. - iv. a notice that refers to the disclaimer of warranties; + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. - v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. - B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and - C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. +Section 4 -- Sui Generis Database Rights. - 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: - 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; - b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + including for purposes of Section 3(b); and - 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. - 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. - 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. -Section 4 – Sui Generis Database Rights. +Section 5 -- Disclaimer of Warranties and Limitation of Liability. -Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. - c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. -For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. -Section 5 – Disclaimer of Warranties and Limitation of Liability. +Section 6 -- Term and Termination. - a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. - b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: - c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or -Section 6 – Term and Termination. + 2. upon express reinstatement by the Licensor. - a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. - b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. - 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. - 2. upon express reinstatement by the Licensor. - c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. +Section 7 -- Other Terms and Conditions. - d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. - e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. -Section 7 – Other Terms and Conditions. - a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. +Section 8 -- Interpretation. - b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. -Section 8 – Interpretation. + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. - a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. - b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. - c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. - d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. +======================================================================= -Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. Creative Commons may be contacted at creativecommons.org. + diff --git a/LICENSES/MPL-2.0.txt b/LICENSES/MPL-2.0.txt index 14e2f77..d0a1fa1 100644 --- a/LICENSES/MPL-2.0.txt +++ b/LICENSES/MPL-2.0.txt @@ -35,7 +35,7 @@ Mozilla Public License Version 2.0 means any form of the work other than Source Code Form. 1.7. "Larger Work" - means a work that combines Covered Software with other material, in + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" @@ -357,7 +357,7 @@ Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. + file, You can obtain one at https://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000..37f6411 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,43 @@ +# Maintainers + +This file lists the current maintainers of this project. + +## Active Maintainers + +| Name | GitHub | Role | Since | +|------|--------|------|-------| +| Metadatastician | @metadatastician | Primary | Project Start | + +## Emeritus Maintainers + +None at this time. + +## Becoming a Maintainer + +To become a maintainer: + +1. Demonstrate consistent, high-quality contributions +2. Show understanding of the project's goals and architecture +3. Be active in code reviews and community discussions +4. Be nominated by an existing maintainer +5. Be approved by consensus of existing maintainers + +## Maintainer Responsibilities + +- Reviewing and merging pull requests +- Managing releases +- Triaging issues +- Enforcing code standards +- Mentoring new contributors +- Participating in decision-making + +## Maintainer Expectations + +- Respond to issues and PRs in a timely manner +- Follow the code of conduct +- Be transparent in decision-making +- Communicate clearly and respectfully + +--- + +*Last updated: 2026-07-18* diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..6dd983f --- /dev/null +++ b/mise.toml @@ -0,0 +1,57 @@ +[tools] +# Language runtimes +node = "latest" +python = "latest" +rust = "latest" +go = "latest" +zig = "latest" +java = "latest" +bun = "latest" +denojs = "latest" + +# Package managers +npm = "latest" +yarn = "latest" +pnpm = "latest" +pip = "latest" +cargo = "latest" +go-task = "latest" + +# Formatting & Linting +gofmt = "latest" +black = "latest" +isort = "latest" +ruff = "latest" +prettier = "latest" +shfmt = "latest" +stylua = "latest" + +# Build tools +cmake = "latest" +make = "latest" +ninja = "latest" + +# Shell tools +git = "latest" +gnu-sed = "latest" +gnu-tar = "latest" +gnu-grep = "latest" + +# Testing +vitest = "latest" +pytest = "latest" +jest = "latest" + +[env] +# Common environment variables +NODE_ENV = "development" +PYTHONDONTWRITEBYTECODE = "1" +PYTHONUNBUFFERED = "1" + +# Task runner alias +[alias] +task = "go-task" +build = "cargo build --release || npm run build || go build" +test = "cargo test || npm test || go test ./..." +lint = "ruff check . || prettier --check . || black --check ." +fmt = "ruff format . || prettier --write . || black ." diff --git a/proofs/agda/TRUSTED-BASE.txt b/proofs/agda/TRUSTED-BASE.txt new file mode 100644 index 0000000..c6b5920 --- /dev/null +++ b/proofs/agda/TRUSTED-BASE.txt @@ -0,0 +1,6 @@ +proofs/agda/Dough.agda:viscosity-at +proofs/agda/NoCurdle.agda:gentle-bounded +proofs/agda/NoCurdle.agda:temp-at +proofs/agda/PoachedEgg.agda:gentle-bounded +proofs/agda/PoachedEgg.agda:temp-at +proofs/agda/PoachedEgg.agda:white-set-at diff --git a/proofs/agda/kitchenspeak.agda-lib b/proofs/agda/kitchenspeak.agda-lib index 2fd10ea..603d1bb 100644 --- a/proofs/agda/kitchenspeak.agda-lib +++ b/proofs/agda/kitchenspeak.agda-lib @@ -1,7 +1,6 @@ -- SPDX-License-Identifier: MPL-2.0 -- KitchenSpeak core proof library. -- Agda 2.6.4+ with standard-library 2.3+ (echo-types requires 2.3+). --- -- echo-types (hyperpolymath/echo-types) provides the canonical Echo -- (fiber) type that KitchenSpeak's @ witnesses are wired onto in -- EchoBridge.agda. echo-types itself declares `depend: standard-library diff --git a/scripts/check-agda-trusted-base.sh b/scripts/check-agda-trusted-base.sh new file mode 100755 index 0000000..22d071c --- /dev/null +++ b/scripts/check-agda-trusted-base.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# SPDX-License-Identifier: MPL-2.0 +# +# Trusted-base budget for the Agda proofs. +# +# The recipe proofs deliberately postulate the physical world (sensor +# streams, controller contracts) — those axioms are audited and listed +# in proofs/agda/TRUSTED-BASE.txt with per-file annotations explaining +# each one. This gate fails when ANY postulate appears that is not on +# that list, so the trusted base cannot grow silently. +# (Same doctrine as the Lean `axiom` gate: provers accept axioms +# without complaint, so the budget must be enforced outside the prover.) +set -eu +cd "$(dirname "$0")/.." + +expected="proofs/agda/TRUSTED-BASE.txt" +actual=$(mktemp) +trap 'rm -f "$actual"' EXIT + +awk ' + /^postulate/ { inpost = 1; next } + inpost && /^[[:space:]]+[A-Za-z0-9\x27-]+[[:space:]]*:/ { + line = $0 + sub(/^[[:space:]]+/, "", line) + sub(/[[:space:]]*:.*/, "", line) + print FILENAME ":" line + next + } + inpost && !/^[[:space:]]/ { inpost = 0 } +' proofs/agda/*.agda | sort > "$actual" + +if ! diff -u "$expected" "$actual"; then + echo "FAIL: postulate inventory differs from the audited trusted base." >&2 + echo "New axioms need an audit note in the proof file AND an entry in $expected." >&2 + exit 1 +fi +echo "OK: trusted base unchanged ($(wc -l < "$expected") audited postulates)." diff --git a/verification/proofs/idris2/ABI/Compliance.idr b/verification/proofs/idris2/ABI/Compliance.idr index d38c0d5..111d62e 100644 --- a/verification/proofs/idris2/ABI/Compliance.idr +++ b/verification/proofs/idris2/ABI/Compliance.idr @@ -33,9 +33,10 @@ record CABICompliant (layout : StructLayout) where constructor MkCompliant fieldsAligned : AllFieldsAligned (layoutFields layout) fieldsInBounds : AllFieldsInBounds (layoutSize layout) (layoutFields layout) - sizeAligned : modNatNZ (layoutSize layout) (layoutAlignment layout) SIsNonZero = 0 + sizeAligned : (0 nz : NonZero (layoutAlignment layout)) -> + modNatNZ (layoutSize layout) (layoutAlignment layout) nz = 0 ||| An empty struct is trivially compliant (size=1, alignment=1). export emptyStructCompliant : CABICompliant (MkLayout "empty" [] 1 1) -emptyStructCompliant = MkCompliant AFANil AFBNil Refl +emptyStructCompliant = MkCompliant AFANil AFBNil (\_ => Refl) diff --git a/verification/proofs/idris2/ABI/Layout.idr b/verification/proofs/idris2/ABI/Layout.idr index f38fcca..f5eecf3 100644 --- a/verification/proofs/idris2/ABI/Layout.idr +++ b/verification/proofs/idris2/ABI/Layout.idr @@ -7,6 +7,8 @@ module ABI.Layout +import public Data.Nat + %default total ||| Witness that a type has a known size in bytes at compile time. @@ -44,9 +46,12 @@ record StructField where fieldAlignment : Nat ||| Proof that a field is correctly aligned within a struct. +||| The non-zero alignment witness is a premise: zero alignment is +||| invalid, so alignment evidence is only demanded for legal fields. public export FieldAligned : StructField -> Type -FieldAligned f = modNatNZ (fieldOffset f) (fieldAlignment f) SIsNonZero = 0 +FieldAligned f = (0 nz : NonZero (fieldAlignment f)) -> + modNatNZ (fieldOffset f) (fieldAlignment f) nz = 0 ||| Proof that a field does not overflow past a given struct size. public export diff --git a/verification/proofs/idris2/ABI/Platform.idr b/verification/proofs/idris2/ABI/Platform.idr index 6b80d20..f0cadfd 100644 --- a/verification/proofs/idris2/ABI/Platform.idr +++ b/verification/proofs/idris2/ABI/Platform.idr @@ -7,6 +7,8 @@ module ABI.Platform +import public Data.Nat + %default total ||| Supported target platforms for ABI verification. @@ -51,6 +53,13 @@ export cIntAlways4 : (p : Platform) -> cIntSize p = 4 cIntAlways4 _ = Refl +||| LTE is reflexive. (Idris1's `lteRefl` did not survive into the +||| Idris2 base library; reproven here constructively.) +private +lteRefl : {n : Nat} -> LTE n n +lteRefl {n = Z} = LTEZero +lteRefl {n = S k} = LTESucc lteRefl + ||| Proof that pointer size is always at least 4 bytes. export ptrSizeAtLeast4 : (p : Platform) -> LTE 4 (ptrSize p) diff --git a/verification/proofs/idris2/ABI/Pointers.idr b/verification/proofs/idris2/ABI/Pointers.idr index 49efd2f..ea89a01 100644 --- a/verification/proofs/idris2/ABI/Pointers.idr +++ b/verification/proofs/idris2/ABI/Pointers.idr @@ -21,8 +21,10 @@ record SafePtr where ||| Proof that SafePtr can never hold a null (zero) value. ||| This is enforced by the `So` constraint in the record. +||| Erased (0 quantity): the witness it extracts is itself erased, so +||| this proof exists only at the type level — which is all a proof needs. export -safePtrNeverNull : (sp : SafePtr) -> So (sp.ptr /= 0) +0 safePtrNeverNull : (sp : SafePtr) -> So (sp.ptr /= 0) safePtrNeverNull sp = sp.nonNull ||| Wrap a raw pointer with a runtime null check. @@ -46,7 +48,15 @@ record Handle (tag : String) where constructor MkHandle safePtr : SafePtr +||| `So b` has at most one inhabitant (proof irrelevance for `So`). +0 soUnique : {b : Bool} -> (x, y : So b) -> x = y +soUnique Oh Oh = Refl + ||| Proof that two handles with equal pointers are equal. +||| Erased (0 quantity) so the erased `nonNull` witnesses may be +||| inspected; their equality is discharged by `soUnique`. export -handlePtrEq : (h1, h2 : Handle tag) -> h1.safePtr.ptr = h2.safePtr.ptr -> h1 = h2 -handlePtrEq (MkHandle (MkSafePtr p)) (MkHandle (MkSafePtr p)) Refl = Refl +0 handlePtrEq : (h1, h2 : Handle tag) -> h1.safePtr.ptr = h2.safePtr.ptr -> h1 = h2 +handlePtrEq (MkHandle (MkSafePtr p {nonNull = n1})) (MkHandle (MkSafePtr q {nonNull = n2})) eq = + case eq of + Refl => rewrite soUnique n1 n2 in Refl diff --git a/verification/proofs/idris2/Types.idr b/verification/proofs/idris2/Types.idr index 85ea9b7..a1046ba 100644 --- a/verification/proofs/idris2/Types.idr +++ b/verification/proofs/idris2/Types.idr @@ -7,6 +7,8 @@ module Types +import public Data.Nat + %default total ||| Example: A bounded natural number (0 to max). @@ -18,8 +20,10 @@ record Bounded (max : Nat) where {auto 0 inBounds : LTE value max} ||| Proof that a Bounded value is always <= max. +||| Erased (0 quantity): it extracts the erased `inBounds` witness, +||| so it is available at the type level only. export -boundedLeMax : (b : Bounded max) -> LTE b.value max +0 boundedLeMax : (b : Bounded max) -> LTE b.value max boundedLeMax b = b.inBounds ||| Proof that zero is always a valid Bounded value. diff --git a/verification/proofs/idris2/kitchenspeak-abi-proofs.ipkg b/verification/proofs/idris2/kitchenspeak-abi-proofs.ipkg new file mode 100644 index 0000000..56eee21 --- /dev/null +++ b/verification/proofs/idris2/kitchenspeak-abi-proofs.ipkg @@ -0,0 +1,2 @@ +package kitchenspeak-abi-proofs +modules = Types, ABI.Layout, ABI.Platform, ABI.Foreign, ABI.Pointers, ABI.Compliance